././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/0000755023477200000240000000000014574564663013627 5ustar00fajardoostaffs././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350830.0 pyreadstat-1.2.7/LICENSE0000644023477200000240000003114714574360756014637 0ustar00fajardoostaffsThe pyreadstat package as a whole is distributed under Apache License Vesrion 2 (see below). The pyreadstat package also includes the following open source software components: - ReadStat; https://github.com/WizardMac/ReadStat, distributed under MIT license ReadStat license: --------------------------------------------------------------------------- Copyright (c) 2013-2016 Evan Miller (except where otherwise noted) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. pyreadstat liscence: --------------------------------------------------------------------------- Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350830.0 pyreadstat-1.2.7/MANIFEST.in0000644023477200000240000000025214574360756015361 0ustar00fajardoostaffsinclude *.h recursive-include src *.h recursive-include pyreadstat *.h include *.pyx recursive-include pyreadstat *.pyx include *.pxd recursive-include pyreadstat *.pxd ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/PKG-INFO0000644023477200000240000000177314574564663014734 0ustar00fajardoostaffsMetadata-Version: 2.1 Name: pyreadstat Version: 1.2.7 Summary: Reads and Writes SAS, SPSS and Stata files into/from pandas data frames. Home-page: https://github.com/Roche/pyreadstat Download-URL: https://github.com/Roche/pyreadstat/dist Author: Otto Fajardo Author-email: pleasecontactviagithub@notvalid.com License: Apache License Version 2.0 Classifier: Programming Language :: Python Classifier: Programming Language :: Cython Classifier: Programming Language :: C Classifier: License :: OSI Approved :: Apache Software License Classifier: Intended Audience :: Science/Research Classifier: Topic :: Scientific/Engineering Classifier: Environment :: Console Description-Content-Type: text/markdown License-File: LICENSE A Python package to read and write SAS (sas7bdat, sas7bcat, xport/xpt), SPSS (sav, zsav, por) and Stata (dta) files into/from pandas data frames. It is a wrapper around the C library readstat.
Please visit out project home page for more information:
https://github.com/Roche/pyreadstat ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710411123.0 pyreadstat-1.2.7/README.md0000644023477200000240000012163414574546563015114 0ustar00fajardoostaffs# pyreadstat A python package to read and write sas (sas7bdat, sas7bcat, xport), spps (sav, zsav, por) and stata (dta) data files into/from pandas dataframes.
This module is a wrapper around the excellent [Readstat](https://github.com/WizardMac/ReadStat) C library by [Evan Miller](https://www.evanmiller.org/). Readstat is the library used in the back of the R library [Haven](https://github.com/tidyverse/haven), meaning pyreadstat is a python equivalent to R Haven. Detailed documentation on all available methods is in the [Module documentation](https://ofajardo.github.io/pyreadstat_documentation/_build/html/index.html) If you would like to read R RData and Rds files into python in an easy way, take a look to [pyreadr](https://github.com/ofajardo/pyreadr), a wrapper around the C library [librdata](https://github.com/WizardMac/librdata) **DISCLAIMER** **Pyreadstat is not a validated package. The results may have inaccuracies deriving from the fact most of the data formats are not open. Do not use it for critical tasks such as reporting to the authorities. Pyreadstat is not meant to replace the original applications in this regard.** ## Table of Contents * [Motivation](#motivation) * [Dependencies](#dependencies) * [Installation](#installation) + [Using pip](#using-pip) + [Using conda](#using-conda) + [From the latest sources](#from-the-latest-sources) + [Compiling on Windows and Mac](#compiling-on-windows-and-mac) * [Usage](#usage) + [Basic Usage](#basic-usage) - [Reading Files](#reading-files) - [Writing Files](#writing-files) + [More reading options](#more-reading-options) - [Reading only the headers](#reading-only-the-headers) - [Reading selected columns](#reading-selected-columns) - [Reading files in parallel processes](#reading-files-in-parallel-processes) - [Reading rows in chunks](#reading-rows-in-chunks) - [Reading value labels](#reading-value-labels) - [Missing Values](#missing-values) + [SPSS](#spss) + [SAS and STATA](#sas-and-stata) - [Reading datetime and date columns](#reading-datetime-and-date-columns) - [Other options](#other-options) + [More writing options](#more-writing-options) - [File specific options](#file-specific-options) - [Writing value labels](#writing-value-labels) - [Writing user defined missing values](#writing-user-defined-missing-values) - [Setting variable formats](#setting-variable-formats) - [Variable type conversion](#variable-type-conversion) * [Roadmap](#roadmap) * [CD/CI and wheels](#cdci_and_wheels) * [Known limitations](#known-limitations) * [Python 2.7 support.](#python-27-support) * [Change log](#change-log) * [License](#license) * [Contributing](#contributing) * [People](#people) ## Motivation The original motivation came from reading sas7bdat files in python. That is already possible using either the (pure python) package [sas7bdat](https://pypi.org/project/sas7bdat/) or the (cythonized) method [read_sas](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_sas.html) from pandas. However, those methods are slow (important if you want to read several large files), do not give the possibility to recover value labels (stored in the file itself in the case of spss or stata, or in catalog files in sas), convert both dates and datetime variables to datetime, and you have to specify the encoding otherwise in python 3 instead of strings you get bytes. This package corrects those problems. **1. Good Performance:** Here a comparison of reading a 190 Mb sas7dat file having 202 K rows by 70 columns with numeric, character and date-like columns using different methods. As you can see pyreadstat is the fastest for python and matches the speeds of R Haven. | Method | time | | :----- | :-----------------: | | Python 3 - sas7bdat | 6 min | | Python 3- pandas | 42 s | | Python 3- pyreadstat | 7 s | | R - Haven | 7 s | **2. Reading Value Labels** Neither sas7bdat and pandas.read_sas gives the possibility to read sas7bcat catalog files. Pyreadstat can do that and also extract value labels from SPSS and STATA files. **3. Reading dates and datetimes** sas7bdat and pandas.read_sas convert both date and datetime variables into datetime. That means if you have a date such a '01-01-2018' it will be transformed to '01-01-2018 00:00:00' (it always inserts a time), making it impossible to know looking only at the data if the variable was originally a datetime (if it had a time) or not. Pyreadstat transforms dates to dates and datetimes to datetimes, so that you have a better correspondence with the original data. However, it is possible to keep the original pandas behavior and get always datetimes. **4. Encoding** On python 3, pandas.read_sas reads all strings as bytes. If you want strings you have to specify the encoding manually. pyreadstat read strings as str. Thas is possible because readstat extracts the original encoding and translates to utf-8, so that you don't have to care about that anymore. However it is still possible to manually set the encoding. In addition pyreadstat exposes the variable labels in an easy way (see later). As pandas dataframes cannot handle value labels, you as user will have to take the decision whether to use those values or not. Pandas read_sas reads those labels, but in order to recover them you have to work a bit harder. Compared to R Haven, pyreadstat offers the possibility to read only the headers: Sometimes you want to take a look to many (sas) files looking for the datasets that contain some specific columns, and you want to do it quick. This package offers the possibility to read only the metadata making it possible a very fast metadata scraping (Pandas read_sas can also do it if you pass the value iterator=True). In addition it offers the capability to read sas7bcat files separately from the sas7bdat files. More recently there has been a lot of interest from users on using pyreadstat to read SPSS sav files. After improvements in pyreadstat 1.0.3 below some benchmarks are presented. The small file is 200K rows x 100 columns (152 Mb) containing only numeric columns and the big file is 294K rows x 666 columns (1.5 Gb). There are two versions of the big file: one containing numeric columns only and one with a mix of numeric and character. Pyreadstat gives two ways to read files: reading in a single process using read_sav and reading it in multiple processes using read_file_multiprocessing (see later in the readme for more information). | Method | small | big numeric | big mixed | | :----- | :----: | :---------: | :-------: | | pyreadstat read_sav | 2.3 s | 28 s | 40 s | | pyreadstat read_file_multiprocessing | 0.8 s | 10 s | 21 s | As you see performance degrades in pyreadstat when reading a table with both numeric and character types. This is because numpy and pandas do not have a native type for strings but they use a generic object type which brings a big hit in performance. The situation can be improved tough by reading files in multiple processes. ## Dependencies The module depends on pandas, which you normally have installed if you got Anaconda (highly recommended.) In order to compile from source you will need a C compiler (see installation). Only if you want to do changes to the cython source code, you will need cython (normally not necessary). If you want to compile for python 2.7 or windows, you will need cython (see python 2.7 support later). Readstat depends on the C library iconv to handle character encodings. On mac, the library is found on the system, but users have sometimes reported problems. In those cases it may help to install libiconv with conda (see later, compilation on mac). Readstat also depends on zlib; it was reported not to be installed by default on Lubuntu. If you face this problem installing the library solves it. ## Installation ### Using pip Probably the easiest way: from your conda, virtualenv or just base installation do: ``` pip install pyreadstat ``` If you are running on a machine without admin rights, and you want to install against your base installation you can do: ``` pip install pyreadstat --user ``` At the moment we offer pre-compiled wheels for windows, mac and linux. Look at the [pypi webpage](https://pypi.org/project/pyreadstat/) to find out which python versions are currently supported. If there is no pre-compiled wheel available, pip will attempt to compile the source code. ### Using conda The package is also available in [conda-forge](https://anaconda.org/conda-forge/pyreadstat) for windows, mac and linux 64 bit. Visit the Conda forge webpage to find out which python versions are currently supported. In order to install: ``` conda install -c conda-forge pyreadstat ``` ### From the latest sources Download or clone the repo, open a command window and type: ``` python3 setup.py install ``` If you don't have admin privileges to the machine (for example on Bee) do: ``` python3 setup.py install --user ``` You can also install from the github repo directly (without cloning). Use the flag --user if necessary. ``` pip install git+https://github.com/Roche/pyreadstat.git ``` You need a working C compiler and cython >=3.0.0. ### Compiling on Windows and Mac Compiling on linux is very easy, but on windows you need some extra preparation. Some instructions are found [here](https://github.com/Roche/pyreadstat/blob/master/windows_compilation.md) Compiling on mac is usually easy. Readstat depends however on the C library iconv to handle character encodings; while on linux is part of gclib, on mac it is a separated shared library found on the system (h file is in /usr/include and shared library on /usr/lib). While compiling against this usually works fine, some users have reported problems (for example missing symbol _iconv, or libiconv version too old). In those cases it helped to install libiconv with conda: ``` conda install libiconv ``` and then recompile again (be sure to delete any cache, if using pip do pip --no-cache-dir, if using setup.py remove the folder build, otherwise you may be installing the old compilation again). ## Usage ### Basic Usage #### Reading files Pass the path to a file to any of the functions provided by pyreadstat. It will return a pandas data frame and a metadata object.
The dataframe uses the column names. The metadata object contains the column names, column labels, number_rows, number_columns, file label (if any), file encoding (if applicable), notes and objects about value labels (if present). Be aware that file_label and file_encoding may be None, not all columns may have labels, notes may not be present and there may be no value labels. For example, in order to read a sas7bdat file: ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bdat') # done! let's see what we got print(df.head()) print(meta.column_names) print(meta.column_labels) print(meta.column_names_to_labels) print(meta.number_rows) print(meta.number_columns) print(meta.file_label) print(meta.file_encoding) # there are other metadata pieces extracted. See the documentation for more details. ``` You can replace the column names by column labels very easily (but check first that all columns have distinct labels!): ```python # replace column names with column labels df.columns = meta.column_labels # to go back to column names df.columns = meta.column_names ``` #### Writing files Pyreadstat can write STATA (dta), SPSS (sav and zsav, por currently nor supported) and SAS (Xport, sas7bdat and sas7bcat currently not supported) files from pandas data frames. write functions take as first argument a pandas data frame (other data structures are not supported), as a second argument the path to the destination file. Optionally you can also pass a file label and a list with column labels. ```python import pandas as pd import pyreadstat df = pd.DataFrame([[1,2.0,"a"],[3,4.0,"b"]], columns=["v1", "v2", "v3"]) # column_labels can also be a dictionary with variable name as key and label as value column_labels = ["Variable 1", "Variable 2", "Variable 3"] pyreadstat.write_sav(df, "path/to/destination.sav", file_label="test", column_labels=column_labels) ``` Some special arguments are available depending on the function. write_sav can take also notes as string, wheter to compress or not as zsav or apply row compression, variable display widths and variable measures. write_dta can take a stata version. write_xport a name for the dataset. User defined missing values and value labels are also supported. See the [Module documentation](https://ofajardo.github.io/pyreadstat_documentation/_build/html/index.html) for more details. Here there is a relation of all functions available. You can also check the [Module documentation](https://ofajardo.github.io/pyreadstat_documentation/_build/html/index.html). | Function in this package | Purpose | | ------------------- | ----------- | | read_sas7dat | read SAS sas7bdat files | | read_xport | read SAS Xport (XPT) files | | read_sas7bcat | read SAS catalog files | | read_dta | read STATA dta files | | read_sav | read SPSS sav and zsav files | | read_por | read SPSS por files | | set_catalog_to_sas | enrich sas dataframe with catalog formats | | set_value_labels | replace values by their labels | | read_file_in_chunks | generator to read files in chunks | | write_sav | write SPSS sav and zsav files | | write_por | write SPSS Portable (POR) files | | write_dta | write STATA dta files | | write_xport | write SAS Xport (XPT) files version 8 and 5 | ### More reading options #### Reading only the headers All functions accept a keyword argument "metadataonly" which by default is False. If True, then no data will be read, but still both the metadata and the dataframe will be returned. The metadata will contain all fields as usual, but the dataframe will be emtpy, although with the correct columns names. Sometimes number_rows may be None if it was not possible to determine the number of rows without reading the data. ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bdat', metadataonly=True) ``` #### Reading selected columns All functions accept a keyword "usecols" which should be a list of column names. Only the columns which names match those in the list will be imported (case sensitive). This decreases memory consumption and speeds up the process. Usecols must always be a list, even if there is only one member. ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bdat', usecols=["variable1", "variable2"]) ``` #### Reading files in parallel processes A challenge when reading large files is the time consumed in the operation. In order to alleviate this pyreadstat provides a function "read\_file\_multiprocessing" to read a file in parallel processes using the python multiprocessing library. As it reads the whole file in one go you need to have enough RAM for the operation. If that is not the case look at Reading rows in chunks (next section) Speed ups in the process will depend on a number of factors such as number of processes available, RAM, content of the file etc. ```python import pyreadstat fpath = "path/to/file.sav" df, meta = pyreadstat.read_file_multiprocessing(pyreadstat.read_sav, fpath, num_processes=4) ``` num_processes is the number of workers and it defaults to 4 (or the number of cores if less than 4). You can play with it to see where you get the best performance. You can also get the number of all available workers like this: ``` import multiprocessing num_processes = multiprocessing.cpu_count() ``` **Notes for Xport, Por and some defective SAV files not having the number of rows in the metadata** 1. In all Xport, Por and some defective SAV files, the number of rows cannot be determined from the metadata. In such cases, you can use the parameter num\_rows to be equal or larger to the number of rows in the dataset. This number can be obtained reading the file without multiprocessing, reading in another application, etc. **Notes for windows** 1. For this to work you must include a __name__ == "__main__" section in your script. See [this issue](#85) for more details. ``` import pyreadstat if __name__ == "__main__": df, meta = pyreadstat.read_file_multiprocessing(pyreadstat.read_sav, 'sample.sav') ``` 2. If you include too many workers or you run out of RAM you main get a message about not enough page file size. See [this issue](#87) #### Reading rows in chunks Reading large files with hundred of thouseds of rows can be challenging due to memory restrictions. In such cases, it may be helpful to read the files in chunks. Every reading function has two arguments row_limit and row_offset that help achieving this. row_offset makes to skip a number of rows before start reading. row_limit makes to stop after a number of rows are read. Combining both you can read the file in chunks inside or outside a loop. ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat("/path/to/file.sas7bdat", row_offset=1, row_limit=1) # df will contain only the second row of the file ``` Pyreadstat also has a convienence function read_file_in_chunks, which returns a generator that helps you to iterate through the file in chunks. This function takes as first argument a pyreadstat reading function and a second argument a path to a file. Optionally you can change the size of the chunks with chunksize (default to 100000), and also add an offset and limit. You can use any keyword argument you wish to pass to the pyreadstat reading function. ```python import pyreadstat fpath = "path/to/file.sas7bdat" reader = pyreadstat.read_file_in_chunks(pyreadstat.read_sas7bdat, fpath, chunksize= 10, offset=2, limit=100, disable_datetime_conversion=True) for df, meta in reader: print(df) # df will contain 10 rows except for the last one # do some cool calculations here for the chunk ``` For very large files it may be convienient to speed up the process by reading each chunks in parallel. For this purpose you can pass the argument multiprocess=True. This is a combination of read_file_in_chunks and read_file_multiprocessing. Here you can use the arguments row_offset and row_limit to start reading the file from an offest and stop after a row_offset+row_limit. ```python import pyreadstat fpath = "path/to/file.sav" reader = pyreadstat.read_file_in_chunks(pyreadstat.read_sav, fpath, chunksize= 10000, multiprocess=True, num_processes=4) for df, meta in reader: print(df) # df will contain 10000 rows except for the last one # do some cool calculations here for the chunk ``` **If using multiprocessing, please read the notes in the previous section regarding Xport, Por and some defective SAV files not having the number of rows in the metadata** **For Windows, please check the notes on the previous section reading files in parallel processes** #### Reading value labels For sas7bdat files, value labels are stored in separated sas7bcat files. You can use them in combination with the sas7bdat or read them separately. If you want to read them in combination with the sas7bdat files, pass the path to the sas7bcat files to the read_sas7bdat function. The original values will be replaced by the values in the catalog. ```python import pyreadstat # formats_as_category is by default True, and it means the replaced values will be transformed to a pandas category column. There is also formats_as_ordered_category to get an ordered category, this by default is False. df, meta = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bdat', catalog_file='/path/to/a/file.sas7bcat', formats_as_category=True, formats_as_ordered_category=False) ``` If you prefer to read the sas7bcat file separately, you can apply the formats later with the function set_catalog_to_sas. In this way you can have two copies of the dataframe, one with catalog and one without. ```python import pyreadstat # this df will have the original values df, meta = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bdat') # read_sas7bdat returns an emtpy data frame and the catalog df_empty, catalog = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bcat') # enrich the dataframe with the catalog # formats_as_category is by default True, and it means the replaced values will be transformed to a pandas category column. formats_as_ordered_category is by default False meaning by default categories are not ordered. df_enriched, meta_enriched = pyreadstat.set_catalog_to_sas(df, meta, catalog, formats_as_category=True, formats_as_ordered_category=False) ``` For SPSS and STATA files, the value labels are included in the files. You can choose to replace the values by the labels when reading the file using the option apply_value_formats, ... ```python import pyreadstat # apply_value_formats is by default False, so you have to set it to True manually if you want the labels # formats_as_category is by default True, and it means the replaced values will be transformed to a pandas category column. formats_as_ordered_category is by default False meaning by default categories are not ordered. df, meta = pyreadstat.read_sav("/path/to/sav/file.sav", apply_value_formats=True, formats_as_category=True, formats_as_ordered_category=False) ``` ... or to do it later with the function set_value_labels: ```python import pyreadstat # This time no value labels. df, meta = pyreadstat.read_sav("/path/to/sav/file.sav", apply_value_formats=False) # now let's add them to a second copy df_enriched = pyreadstat.set_value_labels(df, meta, formats_as_category=True, formats_as_ordered_category=False) ``` Internally each variable is associated with a label set. This information is stored in meta.variable_to_label. Each label set contains a map of the actual value in the variable to the label, this informtion is stored in meta.variable_value_labels. By combining both you can get a dictionary of variable names to a dictionary of actual values to labels. For SPSS and STATA: ```python import pyreadstat df, meta = pyreadstat.read_sav("test_data/basic/sample.sav") # the variables mylabl and myord are associated to the label sets labels0 and labels1 respectively print(meta.variable_to_label) #{'mylabl': 'labels0', 'myord': 'labels1'} # labels0 and labels1 contain a dictionary of actual value to label print(meta.value_labels) #{'labels0': {1.0: 'Male', 2.0: 'Female'}, 'labels1': {1.0: 'low', 2.0: 'medium', 3.0: 'high'}} # both things have been joined by pyreadstat for convienent use print(meta.variable_value_labels) #{'mylabl': {1.0: 'Male', 2.0: 'Female'}, 'myord': {1.0: 'low', 2.0: 'medium', 3.0: 'high'}} ``` SAS is very similar except that meta.variable_to_label comes from the sas7bdat file and meta.value_labels comes from the sas7bcat file. That means if you read a sas7bdat file and a sas7bcat file togheter meta.variable_value_labels will be filled in. If you read only the sas7bdat file only meta.variable_to_label will be available and if you read the sas7bcat file only meta.value_labels will be available. If you read a sas7bdat file and there are no associated label sets, SAS will assign by default the variable format as label sets. ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat("test_data/sas_catalog/test_data_linux.sas7bdat") meta.variable_to_label {'SEXA': '$A', 'SEXB': '$B'} df2, meta2 = pyreadstat.read_sas7bcat("test_data/sas_catalog/test_formats_linux.sas7bcat") meta2.value_labels {'$A': {'1': 'Male', '2': 'Female'}, '$B': {'2': 'Female', '1': 'Male'}} ``` #### Missing Values There are two types of missing values: system and user defined. System are assigned by the program by default. User defined are valid values that the user decided to give the meaning of missing in order to differentiate between several situations.For example if one has a categorical variable representing if the person passed a test, you could have 0 for did not pass, 1 for pass, and as user defined missing variables 2 for did not show up for the test, 3 for unable to process the results, etc. **By default both cases are represented by NaN when read with pyreadstat**. Notice that the only possible missing value in pandas is NaN (Not a Number) for both string and numeric variables, date, datetime and time variables have NaT (Not a Time). ##### SPSS In the case of SPSS sav files, the user can assign to a numeric variable either up to three discrete missing values or one range plus one discrete missing value. As mentioned by default all of these possiblities are translated into NaN, but one can get those original values by passing the argument user_missing=True to the read_sav function: ```python # user set with default missing values import pyreadstat df, meta = pyreadstat.read_sav("/path/to/file.sav") print(df) >> test_passed 1 0 NaN NaN ``` Now, reading the user defined missing values: ```python # user set with user defined missing values import pyreadstat df, meta = pyreadstat.read_sav("/path/to/file.sav", user_missing=True) print(df) >> test_passed 1 0 2 3 ``` As you see now instead o NaN the values 2 and 3 appear. In case the dataset had value labels, we could bring those in ```python # user set with user defined missing values and labels import pyreadstat df, meta = pyreadstat.read_sav("/path/to/file.sav", user_missing=True, apply_value_formats=True) print(df) >> test_passed "passed" "not passed" "not shown" "not processed" ``` Finally, the information about what values are user missing is stored in the meta object, in the variable missing_ranges. This is a dicitonary with the key being the name of the variable, and as value a list of dictionaries, each dictionary contains the elements "hi" and "lo" to represent the lower and upper bound of the range, however for discrete values as in the example, both boundaries are also present although the value is the same in both cases. ```python # user set with default missing values import pyreadstat df, meta = pyreadstat.read_sav("/path/to/file.sav", user_missing=True, apply_value_formats=True) print(meta.missing_ranges) >>> {'test_passed':[{'hi':2, 'lo':2}, {'hi':3, 'lo':3}]} ``` SPSS sav files also support up to 3 discrete user defined missing values for non numeric (character) variables. Pyreadstat is able to read those and the behavior is the same as for discrete numerical user defined missing values. That means those values will be translated as NaN by default and to the correspoding string value if user_missing is set to True. meta.missing_ranges will show the string value as well. If the value in a character variable is an empty string (''), it will not be translated to NaN, but will stay as an empty string. This is because the empty string is a valid character value in SPSS and pyreadstat preserves that property. You can convert empty strings to nan very easily with pandas if you think it is appropiate for your dataset. ##### SAS and STATA In SAS the user can assign values from .A to .Z and ._ as user defined missing values. In Stata values from .a to .z. As in SPSS, those are normally translated to NaN. However, using user_missing=True with read_sas7bdat or read_dta will produce values from A to Z and _ for SAS and a to z for dta. In addition a variable missing_user_values will appear in the metadata object, being a list with those values that are user defined missing values. ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat("/path/to/file.sas7bdat", user_missing=True) df, meta = pyreadstat.read_dta("/path/to/file.dta", user_missing=True) print(meta.missing_user_values) ``` The user may also assign a label to user defined missing values. In such case passing the corresponding sas7bcat file to read_sas7bdat or using the option apply_value_formats to read_dta will show those labels instead of the user defined missing value. ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat("/path/to/file.sas7bdat", catalog_file="/path/to/file.sas7bcat", user_missing=True) df, meta = pyreadstat.read_dta("/path/to/file.dta", user_missing=True, apply_value_formats=True) ``` Empty strings are still transtaled as empty strings and not as NaN. The information about what values are user missing is stored in the meta object, in the variable missing_user_values. This is a list listing all user defined missing values. User defined missing values are currently not supported for file types other than sas7bdat, sas7bcat and dta. #### Reading datetime and date columns SAS, SPSS and STATA represent datetime, date and other similar concepts as a numeric column and then applies a display format on top. Roughly speaking, internally there are two possible representations: one for concepts with a day or lower granularity (date, week, quarter, year, etc.) and those with a higher granularity than a day (datetime, time, hour, etc). The first group is suceptible to be converted to a python date object and the second to a python datetime object. Pyreadstat attempts to read columns with datetime, date and time formats that are convertible to python datetime, date and time objects automatically. However there are other formats that are not fully convertible to any of these formats, for example SAS "YEAR" (displaying only the year), "MMYY" (displaying only month and year), etc. Because there are too many of these formats and these keep changing, it is not possible to implement a rule for each of those, therefore these columns are not transformed and the user will obtain a numeric column. In order to cope with this issue, there are two options for each reader function: extra\_datetime\_formats and extra\_date\_formats that allow the user to pass these datetime or date formats, to transform the numeric values into datetime or date python objects. Then, the user can format those columns appropiately; for example extracting the year only to an integer column in the case of 'YEAR' or formatting it to a string 'YYYY-MM' in the case of 'MMYY'. The choice between datetime or date format depends on the granularity of the data as explained above. This arguments are also useful in the case you have a valid datetime, date or time format that is currently not recognized in pyreadstat. In those cases, feel free to file an issue to ask those to be added to the list, in the meantime you can use these arguments to do the conversion. ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bdat', extra_date_formats=["YEAR", "MMYY"]) ``` #### Other options You can set the encoding of the original file manually. The encoding must be a [iconv-compatible encoding](https://gist.github.com/hakre/4188459). This is absolutely necessary if you are handling old xport files with non-ascii characters. Those files do not have stamped the encoding in the file itself, therefore the encoding must be set manually. For SPSS POR files it is not possible to set the encoding and files are assumed to be always encoded in UTF-8. ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bdat', encoding="LATIN1") ``` You can preserve the original pandas behavior regarding dates (meaning dates are converted to pandas datetime) with the dates_as_pandas_datetime option ```python import pyreadstat df, meta = pyreadstat.read_sas7bdat('/path/to/a/file.sas7bdat', dates_as_pandas_datetime=True) ``` You can get a dictionary of numpy arrays instead of a pandas dataframe when reading any file format. In order to do that, set the parameter output_format='dict' (default is 'pandas'). This is useful if you want to transform the data to some other format different to pandas, as transforming the data to pandas is a costly process both in terms of speed and memory. Here for example an efficient way to transform the data to a polars dataframe: ```python import pyreadstat import polars dicdata, meta = pyreadstat.read_sav('/path/to/a/file.sav', output_format='dict') df = polars.DataFrame(dicdata) ``` For more information, please check the [Module documentation](https://ofajardo.github.io/pyreadstat_documentation/_build/html/index.html). ### More writing options #### File specific options Some special arguments are available depending on the function. write_sav can take also notes as string, wheter to compress or not as zsav or apply row compression, variable display widths and variable measures. write_dta can take a stata version. write_xport a name for the dataset. See the [Module documentation](https://ofajardo.github.io/pyreadstat_documentation/_build/html/index.html) for more details. #### Writing value labels The argument variable_value_labels can be passed to write_sav and write_dta to write value labels. This argument must be a dictionary where keys are variable names (names must match column names in the pandas data frame). Values are another dictionary where keys are the value present in the dataframe and values are the labels (strings). ```python import pandas as pd import pyreadstat df = pd.DataFrame([[1,1],[2,2],[1,3]], columns=['mylabl', 'myord']) variable_value_labels = {'mylabl': {1: 'Male', 2: 'Female'}, 'myord': {1: 'low', 2: 'medium', 3: 'high'}} path = "/path/to/somefile.sav" pyreadstat.write_sav(df, path, variable_value_labels=variable_value_labels) ``` #### Writing user defined missing values ##### SPSS The argument missing_ranges can be passed to write_sav to write user defined missing values. This argument be a dictionary with keys as variable names matching variable names in the dataframe. The values must be a list. Each element in that list can either be either a discrete numeric or string value (max 3 per variable) or a dictionary with keys 'hi' and 'lo' to indicate the upper and lower range for numeric values (max 1 range value + 1 discrete value per variable). hi and lo may also be the same value in which case it will be interpreted as a discrete missing value. For this to be effective, values in the dataframe must be the same as reported here and not NaN. ```python import pandas as pd import pyreadstat df = pd.DataFrame([["a",1],["c",2],["c",3]], columns=['mychar', 'myord']) missing_ranges = {'mychar':['a'], 'myord': [{'hi':2, 'lo':1}]} path = "/path/to/somefile.sav" pyreadstat.write_sav(df, path, missing_ranges=missing_ranges) ``` ##### STATA The argument missing_user_values can be passed to write_dta to write user defined missing values only for numeric variables. This argument be a dictionary with keys as variable names matching variable names in the dataframe. The values must be a list of missing values, valid values are single character strings between a and z. Optionally a value label can also be attached to those missing values using variable_value_labels. ```python import pandas as pd import pyreadstat df = pd.DataFrame([["a", 1],[2.2, 2],[3.3, "b"]], columns=['Var1', 'Var2']) variable_value_labels = {'Var1':{'a':'a missing value'} missing_ranges = {'Var1':['a'], 'Var2': ['b']} path = "/path/to/somefile.sav" pyreadstat.write_sav(df, path, missing_ranges=missing_ranges, variable_value_labels=variable_value_labels) ``` #### Setting variable formats Numeric types in SPSS, SAS and STATA can have formats that affect how those values are displayed to the user in the application. Pyreadstat automatically sets the formatting in some cases, as for example when translating dates or datetimes (which in SPSS/SAS/STATA are just numbers with a special format). The user can however specify custom formats for their columns with the argument "variable_format", which is a dictionary with the column name as key and a string with the format as values: ```python import pandas as pd import pyreadstat path = "path/where/to/write/file.sav" df = pd.DataFrame({'restricted':[1023, 10], 'integer':[1,2]}) formats = {'restricted':'N4', 'integer':'F1.0'} pyreadstat.write_sav(df, path, variable_format=formats) ``` The appropiate formats to use are beyond the scope of this documentation. Probably you want to read a file produced in the original application and use meta.original_value_formats to get the formats. Otherwise look for the documentation of the original application. ##### SPSS In the case of SPSS we have some presets for some formats: * restricted_integer: with leading zeros, equivalent to N + variable width (e.g N4) * integer: Numeric with no decimal places, equivalent to F + variable width + ".0" (0 decimal positions). A pandas column of type integer will also be translated into this format automatically. ```python import pandas as pd import pyreadstat path = "path/where/to/write/file.sav" df = pd.DataFrame({'restricted':[1023, 10], 'integer':[1,2]}) formats = {'restricted':'restricted_integer', 'integer':'integer'} pyreadstat.write_sav(df, path, variable_format=formats) ``` There is some information about the possible formats [here](https://www.gnu.org/software/pspp/pspp-dev/html_node/Variable-Record.html). #### Variable type conversion The following rules are used in order to convert from pandas/numpy/python types to the target file types: | Python Type | Converted Type | | ------------------- | --------- | | np.int32 or lower | integer (stata), numeric (spss, sas) | | int, np.int64, np.float | double (stata), numeric (spss, sas) | | str | character | | bool | integer (stata), numeric (spss, sas) | | datetime, date, time | numeric with datetime/date/time formatting | | category | depends on the original dtype | | any other object | character | | column all missing | integer (stata), numeric (spss, sas) | | column with mixed types | character | Columns with mixed types are translated to character. This does not apply to column cotaining np.nan, where the missing values are correctly translated. It also does not apply to columns with user defined missing values in stata/sas where characters (a to z, A to Z, \_) will be recorded as numeric. ## Roadmap * Include latest releases from Readstat as they come out. ## CD/CI and Wheels A CD/CI pipeline producing the wheels is available [here](https://github.com/ofajardo/pyreadstat_wheels4). Contributions are welcome. ## Known limitations pyreadstat builds on top of Readstat and therefore inherits its limitations. Currently those include: * Cannot write SAS sas7bdat. Those files can be written but not read in SAS and therefore are not supported in pyreadstat. (see [here](https://github.com/WizardMac/ReadStat/issues/98)) Converting data types from foreign applications into python some times also bring some limitations: * Pyreadstat transforms date, datetime and time like variables which are internally represented in the original application as numbers to python datetime objects. Python datetime objects are however limited in the range of dates they can represent (for example the max year is 10,000), while in other applications it is possible (although probably an error in the data) to have very high or very low dates. In this cases pyreadstat would raise an error: ``` OverflowError: date value out of range ``` The workaround is to deal with this include using the keyword argument disable_datetime_conversion so that you will get numbers instead of datetime objects or skipping reading such columns with the argument usecols. ## Python 2.7 support. As version 1.2.3 Python 2.7 is not supported. In previous versions it was possible to compile it for mac and linux but not for windows, but no wheels were provided. In linux and mac it will fail if the path file contains non-ascii characters. ## Change log A log with the changes for each version can be found [here](https://github.com/Roche/pyreadstat/blob/master/change_log.md) ## License pyreadstat is distributed under Apache 2.0 license. Readstat is distributed under MIT license. See the License file for more information. ## Contributing Contributions are welcome! Those include corrections to the documentation, bugs reporting, testing, and of course code pull requests. For code pull requests please consider opening an issue explaining what you plan to do, so that we can get aligned before you start investing time on it (this also avoids duplicated efforts). The ReadStat code in this repo (under the subfolder src) is coming from the main Readstat trunk and should not be modified in order to keep full compatibility with the original. In that way improvements in ReadStat can be taken here with almost no effort. If you would like to propose new features involving changes in the ReadStat code, please submit a pull request to ReadStat first. ## People [Otto Fajardo](https://github.com/ofajardo) - author, maintainer [Matthew Brett](http://matthew.dynevor.org/) - contributor [python wheels](https://github.com/MacPython/pyreadstat-wheels) [Jonathon Love](https://jona.thon.love/) - contributor: open files with international characters. Function to open files for writing. [Clemens Brunner](https://github.com/cbrnr) - integration with pandas.read_spss [Thomas Grainger](https://github.com/graingert) - corrections and suggestions to source code [benjello](https://github.com/benjello), [maxwell8888](https://github.com/maxwell8888), [drcjar](https://github.com/drcjar), [labenech](https://github.com/labenech): improvements to documentation [alchemyst](https://github.com/alchemyst): improvements to docstrings [bmwiedemann](https://github.com/bmwiedemann), [toddrme2178 ](https://github.com/toddrme2178), [Martin Thorsen Ranang](https://github.com/mtr): improvements to source code ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/pyproject.toml0000644023477200000240000000016214574360757016540 0ustar00fajardoostaffs[build-system] requires = [ "setuptools", "wheel", "cython" ] build-backend = "setuptools.build_meta" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/pyreadstat/0000755023477200000240000000000014574564663016007 5ustar00fajardoostaffs././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350845.0 pyreadstat-1.2.7/pyreadstat/__init__.py0000644023477200000240000000232014574360775020113 0ustar00fajardoostaffs# ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# from .pyreadstat import read_sas7bdat, read_xport, read_dta, read_sav, read_por, read_sas7bcat from .pyreadstat import write_sav, write_dta, write_xport, write_por #from .pyreadstat import set_value_labels, set_catalog_to_sas #from .pyreadstat import set_catalog_to_sas from .pyreadstat import read_file_in_chunks, read_file_multiprocessing from ._readstat_parser import ReadstatError, metadata_container from .pyfunctions import set_value_labels, set_catalog_to_sas __version__ = "1.2.7" ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418353.0 pyreadstat-1.2.7/pyreadstat/_readstat_parser.c0000644023477200000240000412525114574564661021505 0ustar00fajardoostaffs/* Generated by Cython 3.0.9 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ "pyreadstat/conditional_includes.h", "src/readstat.h", "src/readstat_io_unistd.h" ], "extra_compile_args": [ "-Ireadstat", "-DHAVE_ZLIB=1" ], "include_dirs": [ "pyreadstat", "src", "src/stata", "src/spss", "src/sas", "." ], "libraries": [ "m", "z" ], "name": "pyreadstat._readstat_parser", "sources": [ "pyreadstat/_readstat_parser.pyx", "./src/CKHashTable.c", "./src/readstat_bits.c", "./src/readstat_convert.c", "./src/readstat_error.c", "./src/readstat_io_unistd.c", "./src/readstat_malloc.c", "./src/readstat_metadata.c", "./src/readstat_parser.c", "./src/readstat_value.c", "./src/readstat_variable.c", "./src/readstat_writer.c", "./src/sas/ieee.c", "./src/sas/readstat_sas.c", "./src/sas/readstat_sas7bcat_read.c", "./src/sas/readstat_sas7bcat_write.c", "./src/sas/readstat_sas7bdat_read.c", "./src/sas/readstat_sas7bdat_write.c", "./src/sas/readstat_sas_rle.c", "./src/sas/readstat_xport.c", "./src/sas/readstat_xport_parse_format.c", "./src/sas/readstat_xport_read.c", "./src/sas/readstat_xport_write.c", "./src/spss/readstat_por.c", "./src/spss/readstat_por_parse.c", "./src/spss/readstat_por_read.c", "./src/spss/readstat_por_write.c", "./src/spss/readstat_sav.c", "./src/spss/readstat_sav_compress.c", "./src/spss/readstat_sav_parse.c", "./src/spss/readstat_sav_parse_timestamp.c", "./src/spss/readstat_sav_read.c", "./src/spss/readstat_sav_write.c", "./src/spss/readstat_spss.c", "./src/spss/readstat_spss_parse.c", "./src/spss/readstat_zsav_compress.c", "./src/spss/readstat_zsav_read.c", "./src/spss/readstat_zsav_write.c", "./src/stata/readstat_dta.c", "./src/stata/readstat_dta_parse_timestamp.c", "./src/stata/readstat_dta_read.c", "./src/stata/readstat_dta_write.c" ] }, "module_name": "pyreadstat._readstat_parser" } END: Cython Metadata */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ #if defined(CYTHON_LIMITED_API) && 0 #ifndef Py_LIMITED_API #if CYTHON_LIMITED_API+0 > 0x03030000 #define Py_LIMITED_API CYTHON_LIMITED_API #else #define Py_LIMITED_API 0x03030000 #endif #endif #endif #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02070000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.7+ or Python 3.3+. #else #if defined(CYTHON_LIMITED_API) && CYTHON_LIMITED_API #define __PYX_EXTRA_ABI_MODULE_NAME "limited" #else #define __PYX_EXTRA_ABI_MODULE_NAME "" #endif #define CYTHON_ABI "3_0_9" __PYX_EXTRA_ABI_MODULE_NAME #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." #define CYTHON_HEX_VERSION 0x030009F0 #define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG #define HAVE_LONG_LONG #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX #if defined(GRAALVM_PYTHON) /* For very preliminary testing purposes. Most variables are set the same as PyPy. The existence of this section does not imply that anything works or is even tested */ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 1 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3) #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(PYPY_VERSION) #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3) #endif #if PY_VERSION_HEX < 0x03090000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1 && PYPY_VERSION_NUM >= 0x07030C00) #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(CYTHON_LIMITED_API) #ifdef Py_LIMITED_API #undef __PYX_LIMITED_VERSION_HEX #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API #endif #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 1 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_CLINE_IN_TRACEBACK #define CYTHON_CLINE_IN_TRACEBACK 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 1 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #endif #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 1 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(Py_GIL_DISABLED) || defined(Py_NOGIL) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 1 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #ifndef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #ifndef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #ifndef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #ifndef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #ifndef CYTHON_FAST_GIL #define CYTHON_FAST_GIL (PY_MAJOR_VERSION < 3 || PY_VERSION_HEX >= 0x03060000 && PY_VERSION_HEX < 0x030C00A6) #endif #ifndef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL (PY_VERSION_HEX >= 0x030700A1) #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #if PY_VERSION_HEX < 0x030400a1 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #elif !defined(CYTHON_USE_TP_FINALIZE) #define CYTHON_USE_TP_FINALIZE 1 #endif #if PY_VERSION_HEX < 0x030600B1 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #elif !defined(CYTHON_USE_DICT_VERSIONS) #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5) #endif #if PY_VERSION_HEX < 0x030700A3 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #elif !defined(CYTHON_USE_EXC_INFO_STACK) #define CYTHON_USE_EXC_INFO_STACK 1 #endif #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if !defined(CYTHON_VECTORCALL) #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL && PY_VERSION_HEX >= 0x030800B1) #endif #define CYTHON_BACKPORT_VECTORCALL (CYTHON_METH_FASTCALL && PY_VERSION_HEX < 0x030800B1) #if CYTHON_USE_PYLONG_INTERNALS #if PY_MAJOR_VERSION < 3 #include "longintrepr.h" #endif #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED #if defined(__cplusplus) /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(maybe_unused) #define CYTHON_UNUSED [[maybe_unused]] #endif #endif #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_UNUSED_VAR # if defined(__cplusplus) template void CYTHON_UNUSED_VAR( const T& ) { } # else # define CYTHON_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x) #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #ifndef CYTHON_USE_CPP_STD_MOVE #if defined(__cplusplus) && (\ __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) #define CYTHON_USE_CPP_STD_MOVE 1 #else #define CYTHON_USE_CPP_STD_MOVE 0 #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifdef _MSC_VER #ifndef _MSC_STDINT_H_ #if _MSC_VER < 1300 typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #else typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; #endif #endif #if _MSC_VER < 1300 #ifdef _WIN64 typedef unsigned long long __pyx_uintptr_t; #else typedef unsigned int __pyx_uintptr_t; #endif #else #ifdef _WIN64 typedef unsigned __int64 __pyx_uintptr_t; #else typedef unsigned __int32 __pyx_uintptr_t; #endif #endif #else #include typedef uintptr_t __pyx_uintptr_t; #endif #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifdef __cplusplus template struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL::value) #else #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0) #endif #if CYTHON_COMPILING_IN_PYPY == 1 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x030A0000) #else #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000) #endif #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_DefaultClassType PyClass_Type #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyObject *exception_table = NULL; PyObject *types_module=NULL, *code_type=NULL, *result=NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030B0000 PyObject *version_info; PyObject *py_minor_version = NULL; #endif long minor_version = 0; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); #if __PYX_LIMITED_VERSION_HEX >= 0x030B0000 minor_version = 11; #else if (!(version_info = PySys_GetObject("version_info"))) goto end; if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; minor_version = PyLong_AsLong(py_minor_version); Py_DECREF(py_minor_version); if (minor_version == -1 && PyErr_Occurred()) goto end; #endif if (!(types_module = PyImport_ImportModule("types"))) goto end; if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; if (minor_version <= 7) { (void)p; result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOO", a, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else if (minor_version <= 10) { result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOO", a,p, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else { if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOO", a,p, k, l, s, f, code, c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); } end: Py_XDECREF(code_type); Py_XDECREF(exception_table); Py_XDECREF(types_module); if (type) { PyErr_Restore(type, value, traceback); } return result; } #ifndef CO_OPTIMIZED #define CO_OPTIMIZED 0x0001 #endif #ifndef CO_NEWLOCALS #define CO_NEWLOCALS 0x0002 #endif #ifndef CO_VARARGS #define CO_VARARGS 0x0004 #endif #ifndef CO_VARKEYWORDS #define CO_VARKEYWORDS 0x0008 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x0200 #endif #ifndef CO_GENERATOR #define CO_GENERATOR 0x0020 #endif #ifndef CO_COROUTINE #define CO_COROUTINE 0x0080 #endif #elif PY_VERSION_HEX >= 0x030B0000 static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyCodeObject *result; PyObject *empty_bytes = PyBytes_FromStringAndSize("", 0); if (!empty_bytes) return NULL; result = #if PY_VERSION_HEX >= 0x030C0000 PyUnstable_Code_NewWithPosOnlyArgs #else PyCode_NewWithPosOnlyArgs #endif (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, empty_bytes); Py_DECREF(empty_bytes); return result; } #elif PY_VERSION_HEX >= 0x030800B2 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif #endif #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE) #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type) #else #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is) #define __Pyx_Py_Is(x, y) Py_Is(x, y) #else #define __Pyx_Py_Is(x, y) ((x) == (y)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone) #define __Pyx_Py_IsNone(ob) Py_IsNone(ob) #else #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue) #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob) #else #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse) #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob) #else #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False) #endif #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o) #else #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o) #endif #ifndef CO_COROUTINE #define CO_COROUTINE 0x80 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x200 #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef Py_TPFLAGS_SEQUENCE #define Py_TPFLAGS_SEQUENCE 0 #endif #ifndef Py_TPFLAGS_MAPPING #define Py_TPFLAGS_MAPPING 0 #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #if PY_VERSION_HEX >= 0x030d00A4 # define __Pyx_PyCFunctionFast PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords #else # define __Pyx_PyCFunctionFast _PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #endif #if CYTHON_METH_FASTCALL #define __Pyx_METH_FASTCALL METH_FASTCALL #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords #else #define __Pyx_METH_FASTCALL METH_VARARGS #define __Pyx_PyCFunction_FastCall PyCFunction #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords #endif #if CYTHON_VECTORCALL #define __pyx_vectorcallfunc vectorcallfunc #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n)) #elif CYTHON_BACKPORT_VECTORCALL typedef PyObject *(*__pyx_vectorcallfunc)(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames); #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET ((size_t)1 << (8 * sizeof(size_t) - 1)) #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(((size_t)(n)) & ~__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)) #else #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) #endif #if PY_MAJOR_VERSION >= 0x030900B1 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) #else #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) #endif #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) #elif !CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; } #endif static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void *cfunc) { #if CYTHON_COMPILING_IN_LIMITED_API return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; #else return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; #endif } #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) #if __PYX_LIMITED_VERSION_HEX < 0x030900B1 #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); #else #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b) #define __Pyx_PyCMethod PyCMethod #endif #ifndef METH_METHOD #define METH_METHOD 0x200 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyThreadState_Current PyThreadState_Get() #elif !CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() #elif PY_VERSION_HEX >= 0x03060000 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #elif PY_VERSION_HEX >= 0x03000000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #else #define __Pyx_PyThreadState_Current _PyThreadState_Current #endif #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE void *__Pyx_PyModule_GetState(PyObject *op) { void *result; result = PyModule_GetState(op); if (!result) Py_FatalError("Couldn't find the module state"); return result; } #endif #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE(obj), name, func_ctype) #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name)) #else #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name) #endif #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) #include "pythread.h" #define Py_tss_NEEDS_INIT 0 typedef int Py_tss_t; static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { *key = PyThread_create_key(); return 0; } static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); *key = Py_tss_NEEDS_INIT; return key; } static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { PyObject_Free(key); } static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { return *key != Py_tss_NEEDS_INIT; } static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { PyThread_delete_key(*key); *key = Py_tss_NEEDS_INIT; } static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { return PyThread_set_key_value(*key, value); } static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { return PyThread_get_key_value(*key); } #endif #if PY_MAJOR_VERSION < 3 #if CYTHON_COMPILING_IN_PYPY #if PYPY_VERSION_NUM < 0x07030600 #if defined(__cplusplus) && __cplusplus >= 201402L [[deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")]] #elif defined(__GNUC__) || defined(__clang__) __attribute__ ((__deprecated__("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6"))) #elif defined(_MSC_VER) __declspec(deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")) #endif static CYTHON_INLINE int PyGILState_Check(void) { return 0; } #else // PYPY_VERSION_NUM < 0x07030600 #endif // PYPY_VERSION_NUM < 0x07030600 #else static CYTHON_INLINE int PyGILState_Check(void) { PyThreadState * tstate = _PyThreadState_Current; return tstate && (tstate == PyGILState_GetThisThreadState()); } #endif #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B4 && PY_VERSION_HEX < 0x030d0000 && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); if (res == NULL) PyErr_Clear(); return res; } #elif PY_MAJOR_VERSION >= 3 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000) #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError #define __Pyx_PyDict_GetItemStr PyDict_GetItem #else static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { #if CYTHON_COMPILING_IN_PYPY return PyDict_GetItem(dict, name); #else PyDictEntry *ep; PyDictObject *mp = (PyDictObject*) dict; long hash = ((PyStringObject *) name)->ob_shash; assert(hash != -1); ep = (mp->ma_lookup)(mp, name, hash); if (ep == NULL) { return NULL; } return ep->me_value; #endif } #define __Pyx_PyDict_GetItemStr PyDict_GetItem #endif #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0) #define __Pyx_PyObject_GetIterNextFunc(obj) (Py_TYPE(obj)->tp_iternext) #else #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) #define __Pyx_PyObject_GetIterNextFunc(obj) PyIter_Next #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_SetItemOnTypeDict(tp, k, v) PyObject_GenericSetAttr((PyObject*)tp, k, v) #else #define __Pyx_SetItemOnTypeDict(tp, k, v) PyDict_SetItem(tp->tp_dict, k, v) #endif #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX >= 0x03080000 #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ PyTypeObject *type = Py_TYPE((PyObject*)obj);\ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ PyObject_GC_Del(obj);\ Py_DECREF(type);\ } #else #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GetLength(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U) #define __Pyx_PyUnicode_KIND(u) ((void)u, (0)) #define __Pyx_PyUnicode_DATA(u) ((void*)u) #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i)) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u)) #elif PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_READY(op) (0) #else #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #endif #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u)) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch) #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #else #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #endif #else #define CYTHON_PEP393_ENABLED 0 #define PyUnicode_1BYTE_KIND 1 #define PyUnicode_2BYTE_KIND 2 #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535U : 1114111U) #define __Pyx_PyUnicode_KIND(u) ((int)sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = (Py_UNICODE) ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY #if !defined(PyUnicode_DecodeUnicodeEscape) #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors) #endif #if !defined(PyUnicode_Contains) || (PY_MAJOR_VERSION == 2 && PYPY_VERSION_NUM < 0x07030500) #undef PyUnicode_Contains #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) #define PyObject_ASCII(o) PyObject_Repr(o) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #ifndef PyObject_Unicode #define PyObject_Unicode PyObject_Str #endif #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #else #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) #else #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) #endif #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #else static CYTHON_INLINE PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *module = PyImport_AddModule(name); Py_XINCREF(module); return module; } #endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define __Pyx_Py3Int_Check(op) PyLong_Check(op) #define __Pyx_Py3Int_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #else #define __Pyx_Py3Int_Check(op) (PyLong_Check(op) || PyInt_Check(op)) #define __Pyx_Py3Int_CheckExact(op) (PyLong_CheckExact(op) || PyInt_CheckExact(op)) #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t #endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef __Pyx_PyAsyncMethodsStruct typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #endif #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) #if !defined(_USE_MATH_DEFINES) #define _USE_MATH_DEFINES #endif #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #define __PYX_MARK_ERR_POS(f_index, lineno) \ { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifdef CYTHON_EXTERN_C #undef __PYX_EXTERN_C #define __PYX_EXTERN_C CYTHON_EXTERN_C #elif defined(__PYX_EXTERN_C) #ifdef _MSC_VER #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.") #else #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead. #endif #else #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__pyreadstat___readstat_parser #define __PYX_HAVE_API__pyreadstat___readstat_parser /* Early includes */ #include #include #include #include "readstat.h" #include "readstat_io_unistd.h" #include "conditional_includes.h" #include #include #include "datetime.h" /* Backport for Python 2.x */ #if PY_MAJOR_VERSION < 3 #ifndef PyDateTime_DELTA_GET_DAYS #define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)o)->days) #endif #ifndef PyDateTime_DELTA_GET_SECONDS #define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)o)->seconds) #endif #ifndef PyDateTime_DELTA_GET_MICROSECONDS #define PyDateTime_DELTA_GET_MICROSECONDS(o) (((PyDateTime_Delta*)o)->microseconds) #endif #endif /* Backport for Python < 3.6 */ #if PY_VERSION_HEX < 0x030600a4 #ifndef PyDateTime_TIME_GET_FOLD #define PyDateTime_TIME_GET_FOLD(o) ((void)(o), 0) #endif #ifndef PyDateTime_DATE_GET_FOLD #define PyDateTime_DATE_GET_FOLD(o) ((void)(o), 0) #endif #endif /* Backport for Python < 3.6 */ #if PY_VERSION_HEX < 0x030600a4 #define __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) ((void)(fold), PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, minute, second, microsecond, tz, PyDateTimeAPI->DateTimeType)) #define __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) ((void)(fold), PyDateTimeAPI->Time_FromTime(hour, minute, second, microsecond, tz, PyDateTimeAPI->TimeType)) #else /* For Python 3.6+ so that we can pass tz */ #define __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) PyDateTimeAPI->DateTime_FromDateAndTimeAndFold(year, month, day, hour, minute, second, microsecond, tz, fold, PyDateTimeAPI->DateTimeType) #define __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) PyDateTimeAPI->Time_FromTimeAndFold(hour, minute, second, microsecond, tz, fold, PyDateTimeAPI->TimeType) #endif /* Backport for Python < 3.7 */ #if PY_VERSION_HEX < 0x030700b1 #define __Pyx_TimeZone_UTC NULL #define __Pyx_TimeZone_FromOffsetAndName(offset, name) ((void)(offset), (void)(name), (PyObject*)NULL) #else #define __Pyx_TimeZone_UTC PyDateTime_TimeZone_UTC #define __Pyx_TimeZone_FromOffsetAndName(offset, name) PyTimeZone_FromOffsetAndName(offset, name) #endif /* Backport for Python < 3.10 */ #if PY_VERSION_HEX < 0x030a00a1 #ifndef PyDateTime_TIME_GET_TZINFO #define PyDateTime_TIME_GET_TZINFO(o) ((((PyDateTime_Time*)o)->hastzinfo) ? ((PyDateTime_Time*)o)->tzinfo : Py_None) #endif #ifndef PyDateTime_DATE_GET_TZINFO #define PyDateTime_DATE_GET_TZINFO(o) ((((PyDateTime_DateTime*)o)->hastzinfo) ? ((PyDateTime_DateTime*)o)->tzinfo : Py_None) #endif #endif #include #ifdef _OPENMP #include #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 1 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) #define __PYX_DEFAULT_STRING_ENCODING "utf8" #define __Pyx_PyObject_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #else #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #endif #if CYTHON_USE_PYLONG_INTERNALS #if PY_VERSION_HEX >= 0x030C00A7 #ifndef _PyLong_SIGN_MASK #define _PyLong_SIGN_MASK 3 #endif #ifndef _PyLong_NON_SIZE_BITS #define _PyLong_NON_SIZE_BITS 3 #endif #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK) #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0) #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x)) #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1) #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0) #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_SignedDigitCount(x)\ ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x)) #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue) #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x) #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x) #else #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0]) #endif typedef Py_ssize_t __Pyx_compact_pylong; typedef size_t __Pyx_compact_upylong; #else #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0) #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x)) #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x) #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1) #define __Pyx_PyLong_CompactValue(x)\ ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0])) typedef sdigit __Pyx_compact_pylong; typedef digit __Pyx_compact_upylong; #endif #if PY_VERSION_HEX >= 0x030C00A5 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) #else #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) #endif #endif #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #include static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = (char) c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #include static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } #if !CYTHON_USE_MODULE_STATE static PyObject *__pyx_m = NULL; #endif static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm = __FILE__; static const char *__pyx_filename; /* #### Code section: filename_table ### */ static const char *__pyx_f[] = { "pyreadstat/_readstat_parser.pyx", "", "datetime.pxd", "type.pxd", }; /* #### Code section: utility_code_proto_before_types ### */ /* ForceInitThreads.proto */ #ifndef __PYX_FORCE_INIT_THREADS #define __PYX_FORCE_INIT_THREADS 0 #endif /* #### Code section: numeric_typedefs ### */ /* #### Code section: complex_type_declarations ### */ /* #### Code section: type_declarations ### */ /*--- Type declarations ---*/ struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container; struct __pyx_opt_args_7cpython_8datetime_time_new; struct __pyx_opt_args_7cpython_8datetime_datetime_new; struct __pyx_opt_args_7cpython_8datetime_timezone_new; struct __pyx_opt_args_7cpython_8datetime_datetime_from_timestamp; /* "cpython/datetime.pxd":292 * # Create time object using DateTime CAPI factory function * # Note, there are no range checks for any of the arguments. * cdef inline time time_new(int hour, int minute, int second, int microsecond, object tz, int fold=0): # <<<<<<<<<<<<<< * return __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) * */ struct __pyx_opt_args_7cpython_8datetime_time_new { int __pyx_n; int fold; }; /* "cpython/datetime.pxd":297 * # Create datetime object using DateTime CAPI factory function. * # Note, there are no range checks for any of the arguments. * cdef inline datetime datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz, int fold=0): # <<<<<<<<<<<<<< * return __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) * */ struct __pyx_opt_args_7cpython_8datetime_datetime_new { int __pyx_n; int fold; }; /* "cpython/datetime.pxd":306 * * # Create timedelta object using DateTime CAPI factory function. * cdef inline object timezone_new(object offset, object name=None): # <<<<<<<<<<<<<< * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') */ struct __pyx_opt_args_7cpython_8datetime_timezone_new { int __pyx_n; PyObject *name; }; /* "cpython/datetime.pxd":312 * * # Create datetime object using DB API constructor. * cdef inline datetime datetime_from_timestamp(timestamp, tz=None): # <<<<<<<<<<<<<< * return PyDateTimeAPI.DateTime_FromTimestamp( * PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL) */ struct __pyx_opt_args_7cpython_8datetime_datetime_from_timestamp { int __pyx_n; PyObject *tz; }; /* "pyreadstat/_readstat_parser.pxd":22 * * # Definitions of enum types * ctypedef enum py_file_extension: # <<<<<<<<<<<<<< * FILE_EXT_SAV * FILE_EXT_SAS7BDAT */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension { __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAV, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BDAT, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_DTA, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_XPORT, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_POR, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BCAT }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension; /* "pyreadstat/_readstat_parser.pxd":30 * FILE_EXT_SAS7BCAT * * ctypedef enum py_file_format: # <<<<<<<<<<<<<< * FILE_FORMAT_SAS * FILE_FORMAT_SPSS */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_format { __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS, __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS, __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_t_10pyreadstat_16_readstat_parser_py_file_format; /* "pyreadstat/_readstat_parser.pxd":35 * FILE_FORMAT_STATA * * ctypedef enum py_datetime_format: # <<<<<<<<<<<<<< * DATE_FORMAT_NOTADATE * DATE_FORMAT_DATE */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format { __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATE, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATETIME, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_TIME }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format; /* "pyreadstat/_readstat_parser.pxd":41 * DATE_FORMAT_TIME * * ctypedef enum py_variable_format: # <<<<<<<<<<<<<< * VAR_FORMAT_STRING * VAR_FORMAT_LONG */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format { __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_STRING, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_MISSING }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format; /* "pyreadstat/_readstat_parser.pxd":49 * # Definitions of extension types * * cdef class data_container: # <<<<<<<<<<<<<< * """ * This extension type holds all the data we need to get from our file from */ struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container { PyObject_HEAD int n_obs; int n_vars; int max_n_obs; PyObject *col_data; PyObject *col_data_len; PyObject *col_names; PyObject *col_labels; PyObject *col_dtypes; PyObject *col_numpy_dtypes; PyObject *col_dtypes_isobject; PyObject *col_dytpes_isfloat; PyObject *col_formats; PyObject *col_formats_original; PyObject *origin; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format file_format; int is_unkown_number_rows; PyObject *file_label; PyObject *file_encoding; int metaonly; int dates_as_pandas; PyObject *label_to_var_name; PyObject *labels_raw; PyObject *notes; PyObject *user_encoding; PyObject *table_name; int filter_cols; PyObject *use_cols; int usernan; PyObject *missing_ranges; PyObject *missing_user_values; PyObject *variable_storage_width; PyObject *variable_display_width; PyObject *variable_alignment; PyObject *variable_measure; int no_datetime_conversion; int ctime; int mtime; }; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, Py_ssize_t); void (*DECREF)(void*, PyObject*, Py_ssize_t); void (*GOTREF)(void*, PyObject*, Py_ssize_t); void (*GIVEREF)(void*, PyObject*, Py_ssize_t); void* (*SetupContext)(const char*, Py_ssize_t, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__)) #define __Pyx_RefNannyFinishContextNogil() __Pyx_RefNannyFinishContext() #endif #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContextNogil() #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_Py_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; Py_XDECREF(tmp);\ } while (0) #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #if PY_VERSION_HEX >= 0x030C00A6 #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL) #else #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type) #endif #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL) #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* PyObjectGetAttrStrNoError.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* ExtTypeTest.proto */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* TupleAndListFromArray.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n); static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n); #endif /* IncludeStringH.proto */ #include /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* fastcall.proto */ #if CYTHON_AVOID_BORROWED_REFS #define __Pyx_Arg_VARARGS(args, i) PySequence_GetItem(args, i) #elif CYTHON_ASSUME_SAFE_MACROS #define __Pyx_Arg_VARARGS(args, i) PyTuple_GET_ITEM(args, i) #else #define __Pyx_Arg_VARARGS(args, i) PyTuple_GetItem(args, i) #endif #if CYTHON_AVOID_BORROWED_REFS #define __Pyx_Arg_NewRef_VARARGS(arg) __Pyx_NewRef(arg) #define __Pyx_Arg_XDECREF_VARARGS(arg) Py_XDECREF(arg) #else #define __Pyx_Arg_NewRef_VARARGS(arg) arg #define __Pyx_Arg_XDECREF_VARARGS(arg) #endif #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds) #define __Pyx_KwValues_VARARGS(args, nargs) NULL #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s) #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw) #if CYTHON_METH_FASTCALL #define __Pyx_Arg_FASTCALL(args, i) args[i] #define __Pyx_NumKwargs_FASTCALL(kwds) PyTuple_GET_SIZE(kwds) #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs)) static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues); #else #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw) #endif #define __Pyx_Arg_NewRef_FASTCALL(arg) arg /* no-op, __Pyx_Arg_FASTCALL is direct and this needs to have the same reference counting */ #define __Pyx_Arg_XDECREF_FASTCALL(arg) #else #define __Pyx_Arg_FASTCALL __Pyx_Arg_VARARGS #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS #define __Pyx_Arg_NewRef_FASTCALL(arg) __Pyx_Arg_NewRef_VARARGS(arg) #define __Pyx_Arg_XDECREF_FASTCALL(arg) __Pyx_Arg_XDECREF_VARARGS(arg) #endif #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS #define __Pyx_ArgsSlice_VARARGS(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_VARARGS(args, start), stop - start) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_FASTCALL(args, start), stop - start) #else #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop) #endif /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* KeywordStringCheck.proto */ static int __Pyx_CheckKeywordStrings(PyObject *kw, const char* function_name, int kw_allowed); /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywords.proto */ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject *const *kwvalues, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /* PyObjectSetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) #endif /* PySequenceContains.proto */ static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { int result = PySequence_Contains(seq, item); return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* ModFloat[double].proto */ static CYTHON_INLINE double __Pyx_mod_double(double, double); /* PyFunctionFastCall.proto */ #if CYTHON_FAST_PYCALL #if !CYTHON_VECTORCALL #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); #endif #define __Pyx_BUILD_ASSERT_EXPR(cond)\ (sizeof(char [1 - 2*!(cond)]) - 1) #ifndef Py_MEMBER_SIZE #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) #endif #if !CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03080000 #include "frameobject.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #define __Pxy_PyFrame_Initialize_Offsets() #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus) #else static size_t __pyx_pyframe_localsplus_offset = 0; #include "frameobject.h" #define __Pxy_PyFrame_Initialize_Offsets()\ ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) #define __Pyx_PyFrame_GetLocalsplus(frame)\ (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) #endif #endif #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectFastCall.proto */ #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL) static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs); /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __pyx_dict_cached_value;\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) do {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* RaiseUnboundLocalError.proto */ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); /* UnicodeConcatInPlace.proto */ # if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_REFNANNY #define __Pyx_PyUnicode_ConcatInPlace(left, right) __Pyx_PyUnicode_ConcatInPlaceImpl(&left, right, __pyx_refnanny) #else #define __Pyx_PyUnicode_ConcatInPlace(left, right) __Pyx_PyUnicode_ConcatInPlaceImpl(&left, right) #endif static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_left, PyObject *right #if CYTHON_REFNANNY , void* __pyx_refnanny #endif ); #else #define __Pyx_PyUnicode_ConcatInPlace __Pyx_PyUnicode_Concat #endif #define __Pyx_PyUnicode_ConcatInPlaceSafe(left, right) ((unlikely((left) == Py_None) || unlikely((right) == Py_None)) ?\ PyNumber_InPlaceAdd(left, right) : __Pyx_PyUnicode_ConcatInPlace(left, right)) /* StrConcatInPlace.proto */ #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyStr_Concat __Pyx_PyUnicode_Concat #define __Pyx_PyStr_ConcatInPlace __Pyx_PyUnicode_ConcatInPlace #else #define __Pyx_PyStr_Concat PyNumber_Add #define __Pyx_PyStr_ConcatInPlace PyNumber_InPlaceAdd #endif #define __Pyx_PyStr_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyStr_Concat(a, b)) #define __Pyx_PyStr_ConcatInPlaceSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_InPlaceAdd(a, b) : __Pyx_PyStr_ConcatInPlace(a, b)) /* PyObject_Str.proto */ #define __Pyx_PyObject_Str(obj)\ (likely(PyString_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj)) /* RaiseUnexpectedTypeError.proto */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { Py_INCREF(x); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 L->ob_item[len] = x; #else PyList_SET_ITEM(list, len, x); #endif __Pyx_SET_SIZE(list, len + 1); return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); #define __Pyx_PyObject_Dict_GetItem(obj, name)\ (likely(PyDict_CheckExact(obj)) ?\ __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) #endif /* SetItemInt.proto */ #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, int wraparound, int boundscheck); /* SliceObject.proto */ #define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)\ __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) static CYTHON_INLINE int __Pyx_PyObject_SetSlice( PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** py_start, PyObject** py_stop, PyObject** py_slice, int has_cstart, int has_cstop, int wraparound); /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* dict_getitem_default.proto */ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value); /* UnpackUnboundCMethod.proto */ typedef struct { PyObject *type; PyObject **method_name; PyCFunction func; PyObject *method; int flag; } __Pyx_CachedCFunction; /* CallUnboundCMethod1.proto */ static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg); #else #define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg) #endif /* CallUnboundCMethod2.proto */ static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1 static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); #else #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2) #endif /* PyObjectCall2Args.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /* PyObjectGetMethod.proto */ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); /* PyObjectCallMethod1.proto */ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); /* append.proto */ static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x); /* StrEquals.proto */ #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals #else #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals #endif /* SliceObject.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** py_start, PyObject** py_stop, PyObject** py_slice, int has_cstart, int has_cstop, int wraparound); /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); /* RaiseNeedMoreValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* IterFinish.proto */ static CYTHON_INLINE int __Pyx_IterFinish(void); /* UnpackItemEndCheck.proto */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /* ObjectGetItem.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key); #else #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) #endif /* py_dict_items.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /* CallUnboundCMethod0.proto */ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CallUnboundCMethod0(cfunc, self)\ (likely((cfunc)->func) ?\ (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\ (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\ (PY_VERSION_HEX >= 0x030700A0 ?\ (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\ (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\ (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\ (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\ (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\ ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\ __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\ __Pyx__CallUnboundCMethod0(cfunc, self)) #else #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) #endif /* GetAttr.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); /* HasAttr.proto */ #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 #define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n) #else static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); #endif /* GetTopmostException.proto */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); #endif /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); #else #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif /* pyfrozenset_new.proto */ static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it); /* PySetContains.proto */ static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq); /* ListExtend.proto */ static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 PyObject* none = _PyList_Extend((PyListObject*)L, v); if (unlikely(!none)) return -1; Py_DECREF(none); return 0; #else return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v); #endif } /* PyObjectCallNoArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); /* IncludeStructmemberH.proto */ #include /* FixUpExtensionType.proto */ #if CYTHON_USE_TYPE_SPECS static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type); #endif /* PyObjectCallMethod0.proto */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /* ValidateBasesTuple.proto */ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases); #endif /* PyType_Ready.proto */ CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t); /* PyObject_GenericGetAttrNoDict.proto */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr #endif /* PyObject_GenericGetAttr.proto */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr #endif /* SetupReduce.proto */ #if !CYTHON_COMPILING_IN_LIMITED_API static int __Pyx_setup_reduce(PyObject* type_obj); #endif /* TypeImport.proto */ #ifndef __PYX_HAVE_RT_ImportType_proto_3_0_9 #define __PYX_HAVE_RT_ImportType_proto_3_0_9 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #include #endif #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L #define __PYX_GET_STRUCT_ALIGNMENT_3_0_9(s) alignof(s) #else #define __PYX_GET_STRUCT_ALIGNMENT_3_0_9(s) sizeof(void*) #endif enum __Pyx_ImportType_CheckSize_3_0_9 { __Pyx_ImportType_CheckSize_Error_3_0_9 = 0, __Pyx_ImportType_CheckSize_Warn_3_0_9 = 1, __Pyx_ImportType_CheckSize_Ignore_3_0_9 = 2 }; static PyTypeObject *__Pyx_ImportType_3_0_9(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_9 check_size); #endif /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* ImportDottedModule.proto */ static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple); #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple); #endif /* ImportDottedModuleRelFirst.proto */ static PyObject *__Pyx_ImportDottedModuleRelFirst(PyObject *name, PyObject *parts_tuple); /* FetchSharedCythonModule.proto */ static PyObject *__Pyx_FetchSharedCythonABIModule(void); /* FetchCommonType.proto */ #if !CYTHON_USE_TYPE_SPECS static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); #else static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec *spec, PyObject *bases); #endif /* PyMethodNew.proto */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { PyObject *typesModule=NULL, *methodType=NULL, *result=NULL; CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); typesModule = PyImport_ImportModule("types"); if (!typesModule) return NULL; methodType = PyObject_GetAttrString(typesModule, "MethodType"); Py_DECREF(typesModule); if (!methodType) return NULL; result = PyObject_CallFunctionObjArgs(methodType, func, self, NULL); Py_DECREF(methodType); return result; } #elif PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); return PyMethod_New(func, self); } #else #define __Pyx_PyMethod_New PyMethod_New #endif /* PyVectorcallFastCallDict.proto */ #if CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw); #endif /* CythonFunctionShared.proto */ #define __Pyx_CyFunction_USED #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CYFUNCTION_COROUTINE 0x08 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #else #define __Pyx_CyFunction_GetClassObj(f)\ ((PyObject*) ((PyCMethodObject *) (f))->mm_class) #endif #define __Pyx_CyFunction_SetClassObj(f, classobj)\ __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj)) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { #if CYTHON_COMPILING_IN_LIMITED_API PyObject_HEAD PyObject *func; #elif PY_VERSION_HEX < 0x030900B1 PyCFunctionObject func; #else PyCMethodObject func; #endif #if CYTHON_BACKPORT_VECTORCALL __pyx_vectorcallfunc func_vectorcall; #endif #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_weakreflist; #endif PyObject *func_dict; PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_classobj; #endif void *defaults; int defaults_pyobjects; size_t defaults_size; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; PyObject *func_is_coroutine; } __pyx_CyFunctionObject; #undef __Pyx_CyOrPyCFunction_Check #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_CyFunctionType) #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_CyFunctionType, &PyCFunction_Type) #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_CyFunctionType) static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc); #undef __Pyx_IsSameCFunction #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc) static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj); static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, size_t size, int pyobjects); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(PyObject *module); #if CYTHON_METH_FASTCALL static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); #if CYTHON_BACKPORT_VECTORCALL #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall) #else #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall) #endif #endif /* CythonFunction.proto */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); /* SetNameInClass.proto */ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000 #define __Pyx_SetNameInClass(ns, name, value)\ (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value)) #elif CYTHON_COMPILING_IN_CPYTHON #define __Pyx_SetNameInClass(ns, name, value)\ (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value)) #else #define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value) #endif /* CalculateMetaclass.proto */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); /* PyObjectLookupSpecial.proto */ #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS #define __Pyx_PyObject_LookupSpecialNoError(obj, attr_name) __Pyx__PyObject_LookupSpecial(obj, attr_name, 0) #define __Pyx_PyObject_LookupSpecial(obj, attr_name) __Pyx__PyObject_LookupSpecial(obj, attr_name, 1) static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error); #else #define __Pyx_PyObject_LookupSpecialNoError(o,n) __Pyx_PyObject_GetAttrStrNoError(o,n) #define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n) #endif /* Py3ClassCreate.proto */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc); static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /* Py3UpdateBases.proto */ static PyObject* __Pyx_PEP560_update_bases(PyObject *bases); /* CLineInTraceback.proto */ #ifdef CYTHON_CLINE_IN_TRACEBACK #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #else static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #endif /* CodeObjectCache.proto */ #if !CYTHON_COMPILING_IN_LIMITED_API typedef struct { PyCodeObject* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); #endif /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_readstat_type_t(readstat_type_t value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); /* CIntFromPy.proto */ static CYTHON_INLINE readstat_type_t __Pyx_PyInt_As_readstat_type_t(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format value); /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%U" static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp); #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) #else typedef const char *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%.200s" #define __Pyx_PyType_GetName(tp) ((tp)->tp_name) #define __Pyx_DECREF_TypeName(obj) #endif /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2)) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) /* CheckBinaryVersion.proto */ static unsigned long __Pyx_get_runtime_version(void); static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); /* VoidPtrExport.proto */ static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig); /* FunctionExport.proto */ static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* #### Code section: module_declarations ### */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4date_4year_year(PyDateTime_Date *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4date_5month_month(PyDateTime_Date *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4date_3day_day(PyDateTime_Date *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_4hour_hour(PyDateTime_Time *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_6minute_minute(PyDateTime_Time *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_6second_second(PyDateTime_Time *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_11microsecond_microsecond(PyDateTime_Time *__pyx_v_self); /* proto*/ static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_4time_6tzinfo_tzinfo(PyDateTime_Time *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_4fold_fold(PyDateTime_Time *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_4year_year(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_5month_month(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_3day_day(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_4hour_hour(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_6minute_minute(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_6second_second(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_11microsecond_microsecond(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_8datetime_6tzinfo_tzinfo(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_4fold_fold(PyDateTime_DateTime *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_9timedelta_3day_day(PyDateTime_Delta *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_9timedelta_6second_second(PyDateTime_Delta *__pyx_v_self); /* proto*/ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_9timedelta_11microsecond_microsecond(PyDateTime_Delta *__pyx_v_self); /* proto*/ /* Module declarations from "libc.stddef" */ /* Module declarations from "pyreadstat.readstat_api" */ /* Module declarations from "libc.string" */ /* Module declarations from "libc.stdio" */ /* Module declarations from "__builtin__" */ /* Module declarations from "cpython.type" */ /* Module declarations from "cpython" */ /* Module declarations from "cpython.object" */ /* Module declarations from "cpython.version" */ /* Module declarations from "datetime" */ /* Module declarations from "cpython.datetime" */ static CYTHON_INLINE void __pyx_f_7cpython_8datetime_import_datetime(void); /*proto*/ static CYTHON_INLINE PyDateTime_DateTime *__pyx_f_7cpython_8datetime_datetime_new(int, int, int, int, int, int, int, PyObject *, struct __pyx_opt_args_7cpython_8datetime_datetime_new *__pyx_optional_args); /*proto*/ static CYTHON_INLINE PyDateTime_Delta *__pyx_f_7cpython_8datetime_timedelta_new(int, int, int); /*proto*/ /* Module declarations from "cpython.exc" */ /* Module declarations from "libc.math" */ /* Module declarations from "pyreadstat._readstat_parser" */ static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_sas_all_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_sas_origin = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_spss_all_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_spss_origin = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_stata_all_formats = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_parser_stata_origin = 0; static __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_f_10pyreadstat_16_readstat_parser_transform_variable_format(PyObject *, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format); /*proto*/ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_transform_datetime(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, double, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format, PyObject *, int); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_metadata(readstat_metadata_t *, void *); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_variable(int, readstat_variable_t *, char *, void *); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_value(int, readstat_variable_t *, readstat_value_t, void *); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_value_label(char *, readstat_value_t, char *, void *); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_note(int, char *, void *); /*proto*/ static void __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_error_t); /*proto*/ static void __pyx_f_10pyreadstat_16_readstat_parser_run_readstat_parser(char *, struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *, __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension, long, long); /*proto*/ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_data_container_to_dict(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *); /*proto*/ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_dict_to_pandas_dataframe(PyObject *, struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *); /*proto*/ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_data_container_extract_metadata(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *); /*proto*/ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_convert_readstat_to_python_value(readstat_value_t, int, struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_open(char const *, void *); /*proto*/ /* #### Code section: typeinfo ### */ /* #### Code section: before_global_var ### */ #define __Pyx_MODULE_NAME "pyreadstat._readstat_parser" extern int __pyx_module_is_main_pyreadstat___readstat_parser; int __pyx_module_is_main_pyreadstat___readstat_parser = 0; /* Implementation of "pyreadstat._readstat_parser" */ /* #### Code section: global_var ### */ static PyObject *__pyx_builtin_object; static PyObject *__pyx_builtin_TypeError; static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_chr; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_zip; static PyObject *__pyx_builtin_UnicodeError; static PyObject *__pyx_builtin_RuntimeError; /* #### Code section: string_decls ### */ static const char __pyx_k_d[] = "%d"; static const char __pyx_k__2[] = ""; static const char __pyx_k__8[] = "."; static const char __pyx_k__9[] = "*"; static const char __pyx_k_gc[] = "gc"; static const char __pyx_k_hi[] = "hi"; static const char __pyx_k_lo[] = "lo"; static const char __pyx_k_np[] = "np"; static const char __pyx_k_nt[] = "nt"; static const char __pyx_k_os[] = "os"; static const char __pyx_k_pd[] = "pd"; static const char __pyx_k_tC[] = "%tC"; static const char __pyx_k_tc[] = "%tc"; static const char __pyx_k_td[] = "%td"; static const char __pyx_k_TOD[] = "TOD"; static const char __pyx_k__15[] = "?"; static const char __pyx_k_chr[] = "chr"; static const char __pyx_k_doc[] = "__doc__"; static const char __pyx_k_get[] = "get"; static const char __pyx_k_nan[] = "nan"; static const char __pyx_k_sys[] = "sys"; static const char __pyx_k_zip[] = "zip"; static const char __pyx_k_DATE[] = "DATE"; static const char __pyx_k_HHMM[] = "HHMM"; static const char __pyx_k_NULL[] = "NULL"; static const char __pyx_k_TIME[] = "TIME"; static const char __pyx_k_copy[] = "copy"; static const char __pyx_k_date[] = "date"; static const char __pyx_k_dict[] = "dict"; static const char __pyx_k_fill[] = "fill"; static const char __pyx_k_init[] = "__init__"; static const char __pyx_k_int8[] = "int8"; static const char __pyx_k_left[] = "left"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_name[] = "name"; static const char __pyx_k_path[] = "path"; static const char __pyx_k_self[] = "self"; static const char __pyx_k_spec[] = "__spec__"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_time[] = "time"; static const char __pyx_k_warn[] = "warn"; static const char __pyx_k_ADATE[] = "ADATE"; static const char __pyx_k_DATE8[] = "DATE8"; static const char __pyx_k_DATE9[] = "DATE9"; static const char __pyx_k_DTIME[] = "DTIME"; static const char __pyx_k_EDATE[] = "EDATE"; static const char __pyx_k_JDATE[] = "JDATE"; static const char __pyx_k_M8_ns[] = "__pyx_d); Py_CLEAR(clear_module_state->__pyx_b); Py_CLEAR(clear_module_state->__pyx_cython_runtime); Py_CLEAR(clear_module_state->__pyx_empty_tuple); Py_CLEAR(clear_module_state->__pyx_empty_bytes); Py_CLEAR(clear_module_state->__pyx_empty_unicode); #ifdef __Pyx_CyFunction_USED Py_CLEAR(clear_module_state->__pyx_CyFunctionType); #endif #ifdef __Pyx_FusedFunction_USED Py_CLEAR(clear_module_state->__pyx_FusedFunctionType); #endif Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_4type_type); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_8datetime_date); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_8datetime_time); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_8datetime_datetime); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_8datetime_timedelta); Py_CLEAR(clear_module_state->__pyx_ptype_7cpython_8datetime_tzinfo); Py_CLEAR(clear_module_state->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container); Py_CLEAR(clear_module_state->__pyx_type_10pyreadstat_16_readstat_parser_data_container); Py_CLEAR(clear_module_state->__pyx_n_s_ADATE); Py_CLEAR(clear_module_state->__pyx_n_s_ADATE10); Py_CLEAR(clear_module_state->__pyx_n_s_ADATE8); Py_CLEAR(clear_module_state->__pyx_n_s_B8601DA); Py_CLEAR(clear_module_state->__pyx_n_s_B8601DN); Py_CLEAR(clear_module_state->__pyx_n_s_B8601DT); Py_CLEAR(clear_module_state->__pyx_n_s_B8601TM); Py_CLEAR(clear_module_state->__pyx_n_s_DATE); Py_CLEAR(clear_module_state->__pyx_n_s_DATE11); Py_CLEAR(clear_module_state->__pyx_n_s_DATE12); Py_CLEAR(clear_module_state->__pyx_n_s_DATE8); Py_CLEAR(clear_module_state->__pyx_n_s_DATE9); Py_CLEAR(clear_module_state->__pyx_n_s_DATEAMPM); Py_CLEAR(clear_module_state->__pyx_n_s_DATETIME); Py_CLEAR(clear_module_state->__pyx_n_s_DATETIME17); Py_CLEAR(clear_module_state->__pyx_n_s_DATETIME18); Py_CLEAR(clear_module_state->__pyx_n_s_DATETIME19); Py_CLEAR(clear_module_state->__pyx_n_s_DATETIME20); Py_CLEAR(clear_module_state->__pyx_n_s_DATETIME21); Py_CLEAR(clear_module_state->__pyx_n_s_DATETIME22); Py_CLEAR(clear_module_state->__pyx_kp_s_DATETIME23_2); Py_CLEAR(clear_module_state->__pyx_n_s_DATETIME8); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYY); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYB); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYB10); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYC); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYC10); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYD); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYD10); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYN6); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYN8); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYP); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYP10); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYS); Py_CLEAR(clear_module_state->__pyx_n_s_DDMMYYS10); Py_CLEAR(clear_module_state->__pyx_n_s_DTDATE); Py_CLEAR(clear_module_state->__pyx_n_s_DTIME); Py_CLEAR(clear_module_state->__pyx_n_s_DataFrame); Py_CLEAR(clear_module_state->__pyx_n_s_E8601DA); Py_CLEAR(clear_module_state->__pyx_n_s_E8601DT); Py_CLEAR(clear_module_state->__pyx_n_s_E8601TM); Py_CLEAR(clear_module_state->__pyx_n_s_EDATE); Py_CLEAR(clear_module_state->__pyx_n_s_EDATE10); Py_CLEAR(clear_module_state->__pyx_n_s_EDATE8); Py_CLEAR(clear_module_state->__pyx_kp_s_Failed_convert_C_to_python_value); Py_CLEAR(clear_module_state->__pyx_kp_s_Failed_to_read_number_of_variabl); Py_CLEAR(clear_module_state->__pyx_kp_s_File_0_does_not_exist); Py_CLEAR(clear_module_state->__pyx_n_s_HHMM); Py_CLEAR(clear_module_state->__pyx_n_s_IS8601DA); Py_CLEAR(clear_module_state->__pyx_n_s_IS8601DT); Py_CLEAR(clear_module_state->__pyx_n_s_IS8601TM); Py_CLEAR(clear_module_state->__pyx_n_s_JDATE); Py_CLEAR(clear_module_state->__pyx_n_s_JDATE5); Py_CLEAR(clear_module_state->__pyx_n_s_JDATE7); Py_CLEAR(clear_module_state->__pyx_kp_s_Just_defining_a_custom_exceptio); Py_CLEAR(clear_module_state->__pyx_kp_s_Just_defining_a_custom_exceptio_2); Py_CLEAR(clear_module_state->__pyx_kp_s_M8_ns); Py_CLEAR(clear_module_state->__pyx_n_s_MDYAMPM); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYY); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYB); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYB10); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYC); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYC10); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYD); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYD10); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYN6); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYN8); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYP); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYP10); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYS); Py_CLEAR(clear_module_state->__pyx_n_s_MMDDYYS10); Py_CLEAR(clear_module_state->__pyx_n_s_NULL); Py_CLEAR(clear_module_state->__pyx_n_s_OrderedDict); Py_CLEAR(clear_module_state->__pyx_n_s_PyreadstatError); Py_CLEAR(clear_module_state->__pyx_n_s_ReadstatError); Py_CLEAR(clear_module_state->__pyx_n_s_RuntimeError); Py_CLEAR(clear_module_state->__pyx_n_s_SDATE); Py_CLEAR(clear_module_state->__pyx_n_s_SDATE10); Py_CLEAR(clear_module_state->__pyx_n_s_SDATE8); Py_CLEAR(clear_module_state->__pyx_kp_s_STRING_type_with_value_s_with_da); Py_CLEAR(clear_module_state->__pyx_n_s_TIME); Py_CLEAR(clear_module_state->__pyx_kp_s_TIME11_2); Py_CLEAR(clear_module_state->__pyx_n_s_TIME20); Py_CLEAR(clear_module_state->__pyx_kp_s_TIME20_3); Py_CLEAR(clear_module_state->__pyx_n_s_TIME5); Py_CLEAR(clear_module_state->__pyx_n_s_TIME8); Py_CLEAR(clear_module_state->__pyx_n_s_TIMEAMPM); Py_CLEAR(clear_module_state->__pyx_n_s_TOD); Py_CLEAR(clear_module_state->__pyx_kp_s_This_class_holds_metadata_we_wa); Py_CLEAR(clear_module_state->__pyx_kp_s_Time_zones_are_not_available_fro); Py_CLEAR(clear_module_state->__pyx_n_s_TypeError); Py_CLEAR(clear_module_state->__pyx_n_s_UnicodeError); Py_CLEAR(clear_module_state->__pyx_kp_s_Unknown_file_format); Py_CLEAR(clear_module_state->__pyx_kp_s_Unkown_data_type); Py_CLEAR(clear_module_state->__pyx_n_s_WEEKDATE); Py_CLEAR(clear_module_state->__pyx_n_s_WEEKDATX); Py_CLEAR(clear_module_state->__pyx_n_s_YMDHMS16); Py_CLEAR(clear_module_state->__pyx_n_s_YMDHMS19); Py_CLEAR(clear_module_state->__pyx_kp_s_YMDHMS19_2); Py_CLEAR(clear_module_state->__pyx_n_s_YMDHMS20); Py_CLEAR(clear_module_state->__pyx_n_s_YYMMDD); Py_CLEAR(clear_module_state->__pyx_n_s_YYMMDD10); Py_CLEAR(clear_module_state->__pyx_n_s_YYMMDDB); Py_CLEAR(clear_module_state->__pyx_n_s_YYMMDDD); Py_CLEAR(clear_module_state->__pyx_n_s_YYMMDDN); Py_CLEAR(clear_module_state->__pyx_n_s_YYMMDDP); Py_CLEAR(clear_module_state->__pyx_n_s_YYMMDDS); Py_CLEAR(clear_module_state->__pyx_n_s__15); Py_CLEAR(clear_module_state->__pyx_kp_s__2); Py_CLEAR(clear_module_state->__pyx_kp_u__8); Py_CLEAR(clear_module_state->__pyx_n_s__9); Py_CLEAR(clear_module_state->__pyx_n_s_allowed_formats); Py_CLEAR(clear_module_state->__pyx_n_s_append); Py_CLEAR(clear_module_state->__pyx_n_s_astype); Py_CLEAR(clear_module_state->__pyx_n_s_asyncio_coroutines); Py_CLEAR(clear_module_state->__pyx_n_s_center); Py_CLEAR(clear_module_state->__pyx_n_s_chr); Py_CLEAR(clear_module_state->__pyx_n_s_class_getitem); Py_CLEAR(clear_module_state->__pyx_n_s_cline_in_traceback); Py_CLEAR(clear_module_state->__pyx_n_s_collections); Py_CLEAR(clear_module_state->__pyx_kp_s_column_0_is_duplicated_renamed_t); Py_CLEAR(clear_module_state->__pyx_n_s_column_labels); Py_CLEAR(clear_module_state->__pyx_n_s_column_names); Py_CLEAR(clear_module_state->__pyx_n_s_column_names_to_labels); Py_CLEAR(clear_module_state->__pyx_n_s_columns); Py_CLEAR(clear_module_state->__pyx_n_s_copy); Py_CLEAR(clear_module_state->__pyx_n_s_creation_time); Py_CLEAR(clear_module_state->__pyx_kp_s_d); Py_CLEAR(clear_module_state->__pyx_n_s_data_container); Py_CLEAR(clear_module_state->__pyx_n_s_data_container___reduce_cython); Py_CLEAR(clear_module_state->__pyx_n_s_data_container___setstate_cython); Py_CLEAR(clear_module_state->__pyx_n_s_date); Py_CLEAR(clear_module_state->__pyx_n_s_datetime); Py_CLEAR(clear_module_state->__pyx_n_s_dict); Py_CLEAR(clear_module_state->__pyx_n_s_dict_2); Py_CLEAR(clear_module_state->__pyx_kp_u_disable); Py_CLEAR(clear_module_state->__pyx_n_s_doc); Py_CLEAR(clear_module_state->__pyx_n_s_double); Py_CLEAR(clear_module_state->__pyx_n_s_dtype); Py_CLEAR(clear_module_state->__pyx_n_s_dtypes); Py_CLEAR(clear_module_state->__pyx_n_s_duplicated); Py_CLEAR(clear_module_state->__pyx_n_s_empty); Py_CLEAR(clear_module_state->__pyx_kp_u_enable); Py_CLEAR(clear_module_state->__pyx_n_s_encode); Py_CLEAR(clear_module_state->__pyx_n_s_enumerate); Py_CLEAR(clear_module_state->__pyx_n_s_expanduser); Py_CLEAR(clear_module_state->__pyx_n_s_file_encoding); Py_CLEAR(clear_module_state->__pyx_n_s_file_label); Py_CLEAR(clear_module_state->__pyx_kp_s_file_path_could_not_be_encoded_w); Py_CLEAR(clear_module_state->__pyx_n_s_fill); Py_CLEAR(clear_module_state->__pyx_n_s_float); Py_CLEAR(clear_module_state->__pyx_n_s_float64); Py_CLEAR(clear_module_state->__pyx_n_s_format); Py_CLEAR(clear_module_state->__pyx_n_s_from_dict); Py_CLEAR(clear_module_state->__pyx_n_s_fromtimestamp); Py_CLEAR(clear_module_state->__pyx_n_s_fsdecode); Py_CLEAR(clear_module_state->__pyx_n_s_fsencode); Py_CLEAR(clear_module_state->__pyx_kp_u_gc); Py_CLEAR(clear_module_state->__pyx_n_s_get); Py_CLEAR(clear_module_state->__pyx_n_s_getfilesystemencoding); Py_CLEAR(clear_module_state->__pyx_n_s_getstate); Py_CLEAR(clear_module_state->__pyx_n_s_hi); Py_CLEAR(clear_module_state->__pyx_n_s_import); Py_CLEAR(clear_module_state->__pyx_n_s_init); Py_CLEAR(clear_module_state->__pyx_n_s_init_subclass); Py_CLEAR(clear_module_state->__pyx_n_s_initializing); Py_CLEAR(clear_module_state->__pyx_n_s_int16); Py_CLEAR(clear_module_state->__pyx_n_s_int32); Py_CLEAR(clear_module_state->__pyx_n_s_int64); Py_CLEAR(clear_module_state->__pyx_n_s_int8); Py_CLEAR(clear_module_state->__pyx_n_s_is_coroutine); Py_CLEAR(clear_module_state->__pyx_kp_u_isenabled); Py_CLEAR(clear_module_state->__pyx_n_s_isfile); Py_CLEAR(clear_module_state->__pyx_n_s_items); Py_CLEAR(clear_module_state->__pyx_n_s_left); Py_CLEAR(clear_module_state->__pyx_n_s_lo); Py_CLEAR(clear_module_state->__pyx_n_s_main); Py_CLEAR(clear_module_state->__pyx_n_s_metaclass); Py_CLEAR(clear_module_state->__pyx_n_s_metadata_container); Py_CLEAR(clear_module_state->__pyx_n_s_metadata_container___init); Py_CLEAR(clear_module_state->__pyx_n_s_missing_ranges); Py_CLEAR(clear_module_state->__pyx_n_s_missing_user_values); Py_CLEAR(clear_module_state->__pyx_n_s_modification_time); Py_CLEAR(clear_module_state->__pyx_n_s_module); Py_CLEAR(clear_module_state->__pyx_n_s_mro_entries); Py_CLEAR(clear_module_state->__pyx_n_s_name); Py_CLEAR(clear_module_state->__pyx_n_s_name_2); Py_CLEAR(clear_module_state->__pyx_n_s_nan); Py_CLEAR(clear_module_state->__pyx_kp_s_no_default___reduce___due_to_non); Py_CLEAR(clear_module_state->__pyx_n_s_nominal); Py_CLEAR(clear_module_state->__pyx_n_s_notes); Py_CLEAR(clear_module_state->__pyx_n_s_np); Py_CLEAR(clear_module_state->__pyx_n_s_nt); Py_CLEAR(clear_module_state->__pyx_n_s_number_columns); Py_CLEAR(clear_module_state->__pyx_n_s_number_rows); Py_CLEAR(clear_module_state->__pyx_n_s_numpy); Py_CLEAR(clear_module_state->__pyx_n_s_object); Py_CLEAR(clear_module_state->__pyx_n_s_ordinal); Py_CLEAR(clear_module_state->__pyx_n_s_original_variable_types); Py_CLEAR(clear_module_state->__pyx_n_s_os); Py_CLEAR(clear_module_state->__pyx_n_s_output_format); Py_CLEAR(clear_module_state->__pyx_kp_s_output_format_must_be_one_of_all); Py_CLEAR(clear_module_state->__pyx_n_s_pandas); Py_CLEAR(clear_module_state->__pyx_n_s_path); Py_CLEAR(clear_module_state->__pyx_kp_s_path_must_be_either_str_or_bytes); Py_CLEAR(clear_module_state->__pyx_kp_s_path_must_be_str_bytes_or_unicod); Py_CLEAR(clear_module_state->__pyx_n_s_pd); Py_CLEAR(clear_module_state->__pyx_n_s_prepare); Py_CLEAR(clear_module_state->__pyx_n_s_pyreadstat__readstat_parser); Py_CLEAR(clear_module_state->__pyx_kp_s_pyreadstat__readstat_parser_pyx); Py_CLEAR(clear_module_state->__pyx_n_s_pyx_capi); Py_CLEAR(clear_module_state->__pyx_n_s_pyx_state); Py_CLEAR(clear_module_state->__pyx_n_s_qualname); Py_CLEAR(clear_module_state->__pyx_n_s_range); Py_CLEAR(clear_module_state->__pyx_n_s_readstat_to_numpy_types); Py_CLEAR(clear_module_state->__pyx_n_s_readstat_variable_types); Py_CLEAR(clear_module_state->__pyx_n_s_reduce); Py_CLEAR(clear_module_state->__pyx_n_s_reduce_cython); Py_CLEAR(clear_module_state->__pyx_n_s_reduce_ex); Py_CLEAR(clear_module_state->__pyx_n_s_right); Py_CLEAR(clear_module_state->__pyx_n_s_sas_all_formats); Py_CLEAR(clear_module_state->__pyx_n_s_sas_date_formats); Py_CLEAR(clear_module_state->__pyx_n_s_sas_datetime_formats); Py_CLEAR(clear_module_state->__pyx_n_s_sas_origin); Py_CLEAR(clear_module_state->__pyx_n_s_sas_time_formats); Py_CLEAR(clear_module_state->__pyx_n_s_scale); Py_CLEAR(clear_module_state->__pyx_n_s_self); Py_CLEAR(clear_module_state->__pyx_n_s_set_name); Py_CLEAR(clear_module_state->__pyx_n_s_setstate); Py_CLEAR(clear_module_state->__pyx_n_s_setstate_cython); Py_CLEAR(clear_module_state->__pyx_n_s_spec); Py_CLEAR(clear_module_state->__pyx_n_s_spss_all_formats); Py_CLEAR(clear_module_state->__pyx_n_s_spss_date_formats); Py_CLEAR(clear_module_state->__pyx_n_s_spss_datetime_formats); Py_CLEAR(clear_module_state->__pyx_n_s_spss_origin); Py_CLEAR(clear_module_state->__pyx_n_s_spss_time_formats); Py_CLEAR(clear_module_state->__pyx_n_s_stata_all_formats); Py_CLEAR(clear_module_state->__pyx_n_s_stata_date_formats); Py_CLEAR(clear_module_state->__pyx_n_s_stata_datetime_formats); Py_CLEAR(clear_module_state->__pyx_n_s_stata_origin); Py_CLEAR(clear_module_state->__pyx_n_s_stata_time_formats); Py_CLEAR(clear_module_state->__pyx_n_s_string); Py_CLEAR(clear_module_state->__pyx_kp_s_stringsource); Py_CLEAR(clear_module_state->__pyx_n_s_super); Py_CLEAR(clear_module_state->__pyx_n_s_surrogateescape); Py_CLEAR(clear_module_state->__pyx_n_s_sys); Py_CLEAR(clear_module_state->__pyx_kp_s_tC); Py_CLEAR(clear_module_state->__pyx_n_s_table_name); Py_CLEAR(clear_module_state->__pyx_kp_s_tc); Py_CLEAR(clear_module_state->__pyx_kp_s_tcHH_MM); Py_CLEAR(clear_module_state->__pyx_kp_s_tcHH_MM_SS); Py_CLEAR(clear_module_state->__pyx_kp_s_td); Py_CLEAR(clear_module_state->__pyx_kp_s_tdCCYY_NN_DD); Py_CLEAR(clear_module_state->__pyx_kp_s_tdD_m_Y); Py_CLEAR(clear_module_state->__pyx_n_s_test); Py_CLEAR(clear_module_state->__pyx_n_s_time); Py_CLEAR(clear_module_state->__pyx_n_s_to_datetime); Py_CLEAR(clear_module_state->__pyx_n_s_tolist); Py_CLEAR(clear_module_state->__pyx_n_s_undetermined); Py_CLEAR(clear_module_state->__pyx_n_s_unknown); Py_CLEAR(clear_module_state->__pyx_kp_s_utf_8); Py_CLEAR(clear_module_state->__pyx_n_s_value_labels); Py_CLEAR(clear_module_state->__pyx_n_s_variable_alignment); Py_CLEAR(clear_module_state->__pyx_n_s_variable_display_width); Py_CLEAR(clear_module_state->__pyx_n_s_variable_measure); Py_CLEAR(clear_module_state->__pyx_n_s_variable_storage_width); Py_CLEAR(clear_module_state->__pyx_n_s_variable_to_label); Py_CLEAR(clear_module_state->__pyx_n_s_variable_value_labels); Py_CLEAR(clear_module_state->__pyx_n_s_warn); Py_CLEAR(clear_module_state->__pyx_n_s_warnings); Py_CLEAR(clear_module_state->__pyx_n_s_zip); Py_CLEAR(clear_module_state->__pyx_int_0); Py_CLEAR(clear_module_state->__pyx_int_1); Py_CLEAR(clear_module_state->__pyx_int_100000); Py_CLEAR(clear_module_state->__pyx_tuple_); Py_CLEAR(clear_module_state->__pyx_tuple__3); Py_CLEAR(clear_module_state->__pyx_tuple__4); Py_CLEAR(clear_module_state->__pyx_tuple__5); Py_CLEAR(clear_module_state->__pyx_tuple__6); Py_CLEAR(clear_module_state->__pyx_tuple__7); Py_CLEAR(clear_module_state->__pyx_tuple__10); Py_CLEAR(clear_module_state->__pyx_tuple__12); Py_CLEAR(clear_module_state->__pyx_codeobj__11); Py_CLEAR(clear_module_state->__pyx_codeobj__13); Py_CLEAR(clear_module_state->__pyx_codeobj__14); return 0; } #endif /* #### Code section: module_state_traverse ### */ #if CYTHON_USE_MODULE_STATE static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { __pyx_mstate *traverse_module_state = __pyx_mstate(m); if (!traverse_module_state) return 0; Py_VISIT(traverse_module_state->__pyx_d); Py_VISIT(traverse_module_state->__pyx_b); Py_VISIT(traverse_module_state->__pyx_cython_runtime); Py_VISIT(traverse_module_state->__pyx_empty_tuple); Py_VISIT(traverse_module_state->__pyx_empty_bytes); Py_VISIT(traverse_module_state->__pyx_empty_unicode); #ifdef __Pyx_CyFunction_USED Py_VISIT(traverse_module_state->__pyx_CyFunctionType); #endif #ifdef __Pyx_FusedFunction_USED Py_VISIT(traverse_module_state->__pyx_FusedFunctionType); #endif Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_4type_type); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_8datetime_date); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_8datetime_time); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_8datetime_datetime); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_8datetime_timedelta); Py_VISIT(traverse_module_state->__pyx_ptype_7cpython_8datetime_tzinfo); Py_VISIT(traverse_module_state->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container); Py_VISIT(traverse_module_state->__pyx_type_10pyreadstat_16_readstat_parser_data_container); Py_VISIT(traverse_module_state->__pyx_n_s_ADATE); Py_VISIT(traverse_module_state->__pyx_n_s_ADATE10); Py_VISIT(traverse_module_state->__pyx_n_s_ADATE8); Py_VISIT(traverse_module_state->__pyx_n_s_B8601DA); Py_VISIT(traverse_module_state->__pyx_n_s_B8601DN); Py_VISIT(traverse_module_state->__pyx_n_s_B8601DT); Py_VISIT(traverse_module_state->__pyx_n_s_B8601TM); Py_VISIT(traverse_module_state->__pyx_n_s_DATE); Py_VISIT(traverse_module_state->__pyx_n_s_DATE11); Py_VISIT(traverse_module_state->__pyx_n_s_DATE12); Py_VISIT(traverse_module_state->__pyx_n_s_DATE8); Py_VISIT(traverse_module_state->__pyx_n_s_DATE9); Py_VISIT(traverse_module_state->__pyx_n_s_DATEAMPM); Py_VISIT(traverse_module_state->__pyx_n_s_DATETIME); Py_VISIT(traverse_module_state->__pyx_n_s_DATETIME17); Py_VISIT(traverse_module_state->__pyx_n_s_DATETIME18); Py_VISIT(traverse_module_state->__pyx_n_s_DATETIME19); Py_VISIT(traverse_module_state->__pyx_n_s_DATETIME20); Py_VISIT(traverse_module_state->__pyx_n_s_DATETIME21); Py_VISIT(traverse_module_state->__pyx_n_s_DATETIME22); Py_VISIT(traverse_module_state->__pyx_kp_s_DATETIME23_2); Py_VISIT(traverse_module_state->__pyx_n_s_DATETIME8); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYY); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYB); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYB10); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYC); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYC10); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYD); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYD10); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYN6); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYN8); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYP); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYP10); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYS); Py_VISIT(traverse_module_state->__pyx_n_s_DDMMYYS10); Py_VISIT(traverse_module_state->__pyx_n_s_DTDATE); Py_VISIT(traverse_module_state->__pyx_n_s_DTIME); Py_VISIT(traverse_module_state->__pyx_n_s_DataFrame); Py_VISIT(traverse_module_state->__pyx_n_s_E8601DA); Py_VISIT(traverse_module_state->__pyx_n_s_E8601DT); Py_VISIT(traverse_module_state->__pyx_n_s_E8601TM); Py_VISIT(traverse_module_state->__pyx_n_s_EDATE); Py_VISIT(traverse_module_state->__pyx_n_s_EDATE10); Py_VISIT(traverse_module_state->__pyx_n_s_EDATE8); Py_VISIT(traverse_module_state->__pyx_kp_s_Failed_convert_C_to_python_value); Py_VISIT(traverse_module_state->__pyx_kp_s_Failed_to_read_number_of_variabl); Py_VISIT(traverse_module_state->__pyx_kp_s_File_0_does_not_exist); Py_VISIT(traverse_module_state->__pyx_n_s_HHMM); Py_VISIT(traverse_module_state->__pyx_n_s_IS8601DA); Py_VISIT(traverse_module_state->__pyx_n_s_IS8601DT); Py_VISIT(traverse_module_state->__pyx_n_s_IS8601TM); Py_VISIT(traverse_module_state->__pyx_n_s_JDATE); Py_VISIT(traverse_module_state->__pyx_n_s_JDATE5); Py_VISIT(traverse_module_state->__pyx_n_s_JDATE7); Py_VISIT(traverse_module_state->__pyx_kp_s_Just_defining_a_custom_exceptio); Py_VISIT(traverse_module_state->__pyx_kp_s_Just_defining_a_custom_exceptio_2); Py_VISIT(traverse_module_state->__pyx_kp_s_M8_ns); Py_VISIT(traverse_module_state->__pyx_n_s_MDYAMPM); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYY); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYB); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYB10); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYC); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYC10); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYD); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYD10); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYN6); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYN8); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYP); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYP10); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYS); Py_VISIT(traverse_module_state->__pyx_n_s_MMDDYYS10); Py_VISIT(traverse_module_state->__pyx_n_s_NULL); Py_VISIT(traverse_module_state->__pyx_n_s_OrderedDict); Py_VISIT(traverse_module_state->__pyx_n_s_PyreadstatError); Py_VISIT(traverse_module_state->__pyx_n_s_ReadstatError); Py_VISIT(traverse_module_state->__pyx_n_s_RuntimeError); Py_VISIT(traverse_module_state->__pyx_n_s_SDATE); Py_VISIT(traverse_module_state->__pyx_n_s_SDATE10); Py_VISIT(traverse_module_state->__pyx_n_s_SDATE8); Py_VISIT(traverse_module_state->__pyx_kp_s_STRING_type_with_value_s_with_da); Py_VISIT(traverse_module_state->__pyx_n_s_TIME); Py_VISIT(traverse_module_state->__pyx_kp_s_TIME11_2); Py_VISIT(traverse_module_state->__pyx_n_s_TIME20); Py_VISIT(traverse_module_state->__pyx_kp_s_TIME20_3); Py_VISIT(traverse_module_state->__pyx_n_s_TIME5); Py_VISIT(traverse_module_state->__pyx_n_s_TIME8); Py_VISIT(traverse_module_state->__pyx_n_s_TIMEAMPM); Py_VISIT(traverse_module_state->__pyx_n_s_TOD); Py_VISIT(traverse_module_state->__pyx_kp_s_This_class_holds_metadata_we_wa); Py_VISIT(traverse_module_state->__pyx_kp_s_Time_zones_are_not_available_fro); Py_VISIT(traverse_module_state->__pyx_n_s_TypeError); Py_VISIT(traverse_module_state->__pyx_n_s_UnicodeError); Py_VISIT(traverse_module_state->__pyx_kp_s_Unknown_file_format); Py_VISIT(traverse_module_state->__pyx_kp_s_Unkown_data_type); Py_VISIT(traverse_module_state->__pyx_n_s_WEEKDATE); Py_VISIT(traverse_module_state->__pyx_n_s_WEEKDATX); Py_VISIT(traverse_module_state->__pyx_n_s_YMDHMS16); Py_VISIT(traverse_module_state->__pyx_n_s_YMDHMS19); Py_VISIT(traverse_module_state->__pyx_kp_s_YMDHMS19_2); Py_VISIT(traverse_module_state->__pyx_n_s_YMDHMS20); Py_VISIT(traverse_module_state->__pyx_n_s_YYMMDD); Py_VISIT(traverse_module_state->__pyx_n_s_YYMMDD10); Py_VISIT(traverse_module_state->__pyx_n_s_YYMMDDB); Py_VISIT(traverse_module_state->__pyx_n_s_YYMMDDD); Py_VISIT(traverse_module_state->__pyx_n_s_YYMMDDN); Py_VISIT(traverse_module_state->__pyx_n_s_YYMMDDP); Py_VISIT(traverse_module_state->__pyx_n_s_YYMMDDS); Py_VISIT(traverse_module_state->__pyx_n_s__15); Py_VISIT(traverse_module_state->__pyx_kp_s__2); Py_VISIT(traverse_module_state->__pyx_kp_u__8); Py_VISIT(traverse_module_state->__pyx_n_s__9); Py_VISIT(traverse_module_state->__pyx_n_s_allowed_formats); Py_VISIT(traverse_module_state->__pyx_n_s_append); Py_VISIT(traverse_module_state->__pyx_n_s_astype); Py_VISIT(traverse_module_state->__pyx_n_s_asyncio_coroutines); Py_VISIT(traverse_module_state->__pyx_n_s_center); Py_VISIT(traverse_module_state->__pyx_n_s_chr); Py_VISIT(traverse_module_state->__pyx_n_s_class_getitem); Py_VISIT(traverse_module_state->__pyx_n_s_cline_in_traceback); Py_VISIT(traverse_module_state->__pyx_n_s_collections); Py_VISIT(traverse_module_state->__pyx_kp_s_column_0_is_duplicated_renamed_t); Py_VISIT(traverse_module_state->__pyx_n_s_column_labels); Py_VISIT(traverse_module_state->__pyx_n_s_column_names); Py_VISIT(traverse_module_state->__pyx_n_s_column_names_to_labels); Py_VISIT(traverse_module_state->__pyx_n_s_columns); Py_VISIT(traverse_module_state->__pyx_n_s_copy); Py_VISIT(traverse_module_state->__pyx_n_s_creation_time); Py_VISIT(traverse_module_state->__pyx_kp_s_d); Py_VISIT(traverse_module_state->__pyx_n_s_data_container); Py_VISIT(traverse_module_state->__pyx_n_s_data_container___reduce_cython); Py_VISIT(traverse_module_state->__pyx_n_s_data_container___setstate_cython); Py_VISIT(traverse_module_state->__pyx_n_s_date); Py_VISIT(traverse_module_state->__pyx_n_s_datetime); Py_VISIT(traverse_module_state->__pyx_n_s_dict); Py_VISIT(traverse_module_state->__pyx_n_s_dict_2); Py_VISIT(traverse_module_state->__pyx_kp_u_disable); Py_VISIT(traverse_module_state->__pyx_n_s_doc); Py_VISIT(traverse_module_state->__pyx_n_s_double); Py_VISIT(traverse_module_state->__pyx_n_s_dtype); Py_VISIT(traverse_module_state->__pyx_n_s_dtypes); Py_VISIT(traverse_module_state->__pyx_n_s_duplicated); Py_VISIT(traverse_module_state->__pyx_n_s_empty); Py_VISIT(traverse_module_state->__pyx_kp_u_enable); Py_VISIT(traverse_module_state->__pyx_n_s_encode); Py_VISIT(traverse_module_state->__pyx_n_s_enumerate); Py_VISIT(traverse_module_state->__pyx_n_s_expanduser); Py_VISIT(traverse_module_state->__pyx_n_s_file_encoding); Py_VISIT(traverse_module_state->__pyx_n_s_file_label); Py_VISIT(traverse_module_state->__pyx_kp_s_file_path_could_not_be_encoded_w); Py_VISIT(traverse_module_state->__pyx_n_s_fill); Py_VISIT(traverse_module_state->__pyx_n_s_float); Py_VISIT(traverse_module_state->__pyx_n_s_float64); Py_VISIT(traverse_module_state->__pyx_n_s_format); Py_VISIT(traverse_module_state->__pyx_n_s_from_dict); Py_VISIT(traverse_module_state->__pyx_n_s_fromtimestamp); Py_VISIT(traverse_module_state->__pyx_n_s_fsdecode); Py_VISIT(traverse_module_state->__pyx_n_s_fsencode); Py_VISIT(traverse_module_state->__pyx_kp_u_gc); Py_VISIT(traverse_module_state->__pyx_n_s_get); Py_VISIT(traverse_module_state->__pyx_n_s_getfilesystemencoding); Py_VISIT(traverse_module_state->__pyx_n_s_getstate); Py_VISIT(traverse_module_state->__pyx_n_s_hi); Py_VISIT(traverse_module_state->__pyx_n_s_import); Py_VISIT(traverse_module_state->__pyx_n_s_init); Py_VISIT(traverse_module_state->__pyx_n_s_init_subclass); Py_VISIT(traverse_module_state->__pyx_n_s_initializing); Py_VISIT(traverse_module_state->__pyx_n_s_int16); Py_VISIT(traverse_module_state->__pyx_n_s_int32); Py_VISIT(traverse_module_state->__pyx_n_s_int64); Py_VISIT(traverse_module_state->__pyx_n_s_int8); Py_VISIT(traverse_module_state->__pyx_n_s_is_coroutine); Py_VISIT(traverse_module_state->__pyx_kp_u_isenabled); Py_VISIT(traverse_module_state->__pyx_n_s_isfile); Py_VISIT(traverse_module_state->__pyx_n_s_items); Py_VISIT(traverse_module_state->__pyx_n_s_left); Py_VISIT(traverse_module_state->__pyx_n_s_lo); Py_VISIT(traverse_module_state->__pyx_n_s_main); Py_VISIT(traverse_module_state->__pyx_n_s_metaclass); Py_VISIT(traverse_module_state->__pyx_n_s_metadata_container); Py_VISIT(traverse_module_state->__pyx_n_s_metadata_container___init); Py_VISIT(traverse_module_state->__pyx_n_s_missing_ranges); Py_VISIT(traverse_module_state->__pyx_n_s_missing_user_values); Py_VISIT(traverse_module_state->__pyx_n_s_modification_time); Py_VISIT(traverse_module_state->__pyx_n_s_module); Py_VISIT(traverse_module_state->__pyx_n_s_mro_entries); Py_VISIT(traverse_module_state->__pyx_n_s_name); Py_VISIT(traverse_module_state->__pyx_n_s_name_2); Py_VISIT(traverse_module_state->__pyx_n_s_nan); Py_VISIT(traverse_module_state->__pyx_kp_s_no_default___reduce___due_to_non); Py_VISIT(traverse_module_state->__pyx_n_s_nominal); Py_VISIT(traverse_module_state->__pyx_n_s_notes); Py_VISIT(traverse_module_state->__pyx_n_s_np); Py_VISIT(traverse_module_state->__pyx_n_s_nt); Py_VISIT(traverse_module_state->__pyx_n_s_number_columns); Py_VISIT(traverse_module_state->__pyx_n_s_number_rows); Py_VISIT(traverse_module_state->__pyx_n_s_numpy); Py_VISIT(traverse_module_state->__pyx_n_s_object); Py_VISIT(traverse_module_state->__pyx_n_s_ordinal); Py_VISIT(traverse_module_state->__pyx_n_s_original_variable_types); Py_VISIT(traverse_module_state->__pyx_n_s_os); Py_VISIT(traverse_module_state->__pyx_n_s_output_format); Py_VISIT(traverse_module_state->__pyx_kp_s_output_format_must_be_one_of_all); Py_VISIT(traverse_module_state->__pyx_n_s_pandas); Py_VISIT(traverse_module_state->__pyx_n_s_path); Py_VISIT(traverse_module_state->__pyx_kp_s_path_must_be_either_str_or_bytes); Py_VISIT(traverse_module_state->__pyx_kp_s_path_must_be_str_bytes_or_unicod); Py_VISIT(traverse_module_state->__pyx_n_s_pd); Py_VISIT(traverse_module_state->__pyx_n_s_prepare); Py_VISIT(traverse_module_state->__pyx_n_s_pyreadstat__readstat_parser); Py_VISIT(traverse_module_state->__pyx_kp_s_pyreadstat__readstat_parser_pyx); Py_VISIT(traverse_module_state->__pyx_n_s_pyx_capi); Py_VISIT(traverse_module_state->__pyx_n_s_pyx_state); Py_VISIT(traverse_module_state->__pyx_n_s_qualname); Py_VISIT(traverse_module_state->__pyx_n_s_range); Py_VISIT(traverse_module_state->__pyx_n_s_readstat_to_numpy_types); Py_VISIT(traverse_module_state->__pyx_n_s_readstat_variable_types); Py_VISIT(traverse_module_state->__pyx_n_s_reduce); Py_VISIT(traverse_module_state->__pyx_n_s_reduce_cython); Py_VISIT(traverse_module_state->__pyx_n_s_reduce_ex); Py_VISIT(traverse_module_state->__pyx_n_s_right); Py_VISIT(traverse_module_state->__pyx_n_s_sas_all_formats); Py_VISIT(traverse_module_state->__pyx_n_s_sas_date_formats); Py_VISIT(traverse_module_state->__pyx_n_s_sas_datetime_formats); Py_VISIT(traverse_module_state->__pyx_n_s_sas_origin); Py_VISIT(traverse_module_state->__pyx_n_s_sas_time_formats); Py_VISIT(traverse_module_state->__pyx_n_s_scale); Py_VISIT(traverse_module_state->__pyx_n_s_self); Py_VISIT(traverse_module_state->__pyx_n_s_set_name); Py_VISIT(traverse_module_state->__pyx_n_s_setstate); Py_VISIT(traverse_module_state->__pyx_n_s_setstate_cython); Py_VISIT(traverse_module_state->__pyx_n_s_spec); Py_VISIT(traverse_module_state->__pyx_n_s_spss_all_formats); Py_VISIT(traverse_module_state->__pyx_n_s_spss_date_formats); Py_VISIT(traverse_module_state->__pyx_n_s_spss_datetime_formats); Py_VISIT(traverse_module_state->__pyx_n_s_spss_origin); Py_VISIT(traverse_module_state->__pyx_n_s_spss_time_formats); Py_VISIT(traverse_module_state->__pyx_n_s_stata_all_formats); Py_VISIT(traverse_module_state->__pyx_n_s_stata_date_formats); Py_VISIT(traverse_module_state->__pyx_n_s_stata_datetime_formats); Py_VISIT(traverse_module_state->__pyx_n_s_stata_origin); Py_VISIT(traverse_module_state->__pyx_n_s_stata_time_formats); Py_VISIT(traverse_module_state->__pyx_n_s_string); Py_VISIT(traverse_module_state->__pyx_kp_s_stringsource); Py_VISIT(traverse_module_state->__pyx_n_s_super); Py_VISIT(traverse_module_state->__pyx_n_s_surrogateescape); Py_VISIT(traverse_module_state->__pyx_n_s_sys); Py_VISIT(traverse_module_state->__pyx_kp_s_tC); Py_VISIT(traverse_module_state->__pyx_n_s_table_name); Py_VISIT(traverse_module_state->__pyx_kp_s_tc); Py_VISIT(traverse_module_state->__pyx_kp_s_tcHH_MM); Py_VISIT(traverse_module_state->__pyx_kp_s_tcHH_MM_SS); Py_VISIT(traverse_module_state->__pyx_kp_s_td); Py_VISIT(traverse_module_state->__pyx_kp_s_tdCCYY_NN_DD); Py_VISIT(traverse_module_state->__pyx_kp_s_tdD_m_Y); Py_VISIT(traverse_module_state->__pyx_n_s_test); Py_VISIT(traverse_module_state->__pyx_n_s_time); Py_VISIT(traverse_module_state->__pyx_n_s_to_datetime); Py_VISIT(traverse_module_state->__pyx_n_s_tolist); Py_VISIT(traverse_module_state->__pyx_n_s_undetermined); Py_VISIT(traverse_module_state->__pyx_n_s_unknown); Py_VISIT(traverse_module_state->__pyx_kp_s_utf_8); Py_VISIT(traverse_module_state->__pyx_n_s_value_labels); Py_VISIT(traverse_module_state->__pyx_n_s_variable_alignment); Py_VISIT(traverse_module_state->__pyx_n_s_variable_display_width); Py_VISIT(traverse_module_state->__pyx_n_s_variable_measure); Py_VISIT(traverse_module_state->__pyx_n_s_variable_storage_width); Py_VISIT(traverse_module_state->__pyx_n_s_variable_to_label); Py_VISIT(traverse_module_state->__pyx_n_s_variable_value_labels); Py_VISIT(traverse_module_state->__pyx_n_s_warn); Py_VISIT(traverse_module_state->__pyx_n_s_warnings); Py_VISIT(traverse_module_state->__pyx_n_s_zip); Py_VISIT(traverse_module_state->__pyx_int_0); Py_VISIT(traverse_module_state->__pyx_int_1); Py_VISIT(traverse_module_state->__pyx_int_100000); Py_VISIT(traverse_module_state->__pyx_tuple_); Py_VISIT(traverse_module_state->__pyx_tuple__3); Py_VISIT(traverse_module_state->__pyx_tuple__4); Py_VISIT(traverse_module_state->__pyx_tuple__5); Py_VISIT(traverse_module_state->__pyx_tuple__6); Py_VISIT(traverse_module_state->__pyx_tuple__7); Py_VISIT(traverse_module_state->__pyx_tuple__10); Py_VISIT(traverse_module_state->__pyx_tuple__12); Py_VISIT(traverse_module_state->__pyx_codeobj__11); Py_VISIT(traverse_module_state->__pyx_codeobj__13); Py_VISIT(traverse_module_state->__pyx_codeobj__14); return 0; } #endif /* #### Code section: module_state_defines ### */ #define __pyx_d __pyx_mstate_global->__pyx_d #define __pyx_b __pyx_mstate_global->__pyx_b #define __pyx_cython_runtime __pyx_mstate_global->__pyx_cython_runtime #define __pyx_empty_tuple __pyx_mstate_global->__pyx_empty_tuple #define __pyx_empty_bytes __pyx_mstate_global->__pyx_empty_bytes #define __pyx_empty_unicode __pyx_mstate_global->__pyx_empty_unicode #ifdef __Pyx_CyFunction_USED #define __pyx_CyFunctionType __pyx_mstate_global->__pyx_CyFunctionType #endif #ifdef __Pyx_FusedFunction_USED #define __pyx_FusedFunctionType __pyx_mstate_global->__pyx_FusedFunctionType #endif #ifdef __Pyx_Generator_USED #define __pyx_GeneratorType __pyx_mstate_global->__pyx_GeneratorType #endif #ifdef __Pyx_IterableCoroutine_USED #define __pyx_IterableCoroutineType __pyx_mstate_global->__pyx_IterableCoroutineType #endif #ifdef __Pyx_Coroutine_USED #define __pyx_CoroutineAwaitType __pyx_mstate_global->__pyx_CoroutineAwaitType #endif #ifdef __Pyx_Coroutine_USED #define __pyx_CoroutineType __pyx_mstate_global->__pyx_CoroutineType #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #define __pyx_ptype_7cpython_4type_type __pyx_mstate_global->__pyx_ptype_7cpython_4type_type #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #define __pyx_ptype_7cpython_8datetime_date __pyx_mstate_global->__pyx_ptype_7cpython_8datetime_date #define __pyx_ptype_7cpython_8datetime_time __pyx_mstate_global->__pyx_ptype_7cpython_8datetime_time #define __pyx_ptype_7cpython_8datetime_datetime __pyx_mstate_global->__pyx_ptype_7cpython_8datetime_datetime #define __pyx_ptype_7cpython_8datetime_timedelta __pyx_mstate_global->__pyx_ptype_7cpython_8datetime_timedelta #define __pyx_ptype_7cpython_8datetime_tzinfo __pyx_mstate_global->__pyx_ptype_7cpython_8datetime_tzinfo #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #define __pyx_type_10pyreadstat_16_readstat_parser_data_container __pyx_mstate_global->__pyx_type_10pyreadstat_16_readstat_parser_data_container #endif #define __pyx_ptype_10pyreadstat_16_readstat_parser_data_container __pyx_mstate_global->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container #define __pyx_n_s_ADATE __pyx_mstate_global->__pyx_n_s_ADATE #define __pyx_n_s_ADATE10 __pyx_mstate_global->__pyx_n_s_ADATE10 #define __pyx_n_s_ADATE8 __pyx_mstate_global->__pyx_n_s_ADATE8 #define __pyx_n_s_B8601DA __pyx_mstate_global->__pyx_n_s_B8601DA #define __pyx_n_s_B8601DN __pyx_mstate_global->__pyx_n_s_B8601DN #define __pyx_n_s_B8601DT __pyx_mstate_global->__pyx_n_s_B8601DT #define __pyx_n_s_B8601TM __pyx_mstate_global->__pyx_n_s_B8601TM #define __pyx_n_s_DATE __pyx_mstate_global->__pyx_n_s_DATE #define __pyx_n_s_DATE11 __pyx_mstate_global->__pyx_n_s_DATE11 #define __pyx_n_s_DATE12 __pyx_mstate_global->__pyx_n_s_DATE12 #define __pyx_n_s_DATE8 __pyx_mstate_global->__pyx_n_s_DATE8 #define __pyx_n_s_DATE9 __pyx_mstate_global->__pyx_n_s_DATE9 #define __pyx_n_s_DATEAMPM __pyx_mstate_global->__pyx_n_s_DATEAMPM #define __pyx_n_s_DATETIME __pyx_mstate_global->__pyx_n_s_DATETIME #define __pyx_n_s_DATETIME17 __pyx_mstate_global->__pyx_n_s_DATETIME17 #define __pyx_n_s_DATETIME18 __pyx_mstate_global->__pyx_n_s_DATETIME18 #define __pyx_n_s_DATETIME19 __pyx_mstate_global->__pyx_n_s_DATETIME19 #define __pyx_n_s_DATETIME20 __pyx_mstate_global->__pyx_n_s_DATETIME20 #define __pyx_n_s_DATETIME21 __pyx_mstate_global->__pyx_n_s_DATETIME21 #define __pyx_n_s_DATETIME22 __pyx_mstate_global->__pyx_n_s_DATETIME22 #define __pyx_kp_s_DATETIME23_2 __pyx_mstate_global->__pyx_kp_s_DATETIME23_2 #define __pyx_n_s_DATETIME8 __pyx_mstate_global->__pyx_n_s_DATETIME8 #define __pyx_n_s_DDMMYY __pyx_mstate_global->__pyx_n_s_DDMMYY #define __pyx_n_s_DDMMYYB __pyx_mstate_global->__pyx_n_s_DDMMYYB #define __pyx_n_s_DDMMYYB10 __pyx_mstate_global->__pyx_n_s_DDMMYYB10 #define __pyx_n_s_DDMMYYC __pyx_mstate_global->__pyx_n_s_DDMMYYC #define __pyx_n_s_DDMMYYC10 __pyx_mstate_global->__pyx_n_s_DDMMYYC10 #define __pyx_n_s_DDMMYYD __pyx_mstate_global->__pyx_n_s_DDMMYYD #define __pyx_n_s_DDMMYYD10 __pyx_mstate_global->__pyx_n_s_DDMMYYD10 #define __pyx_n_s_DDMMYYN6 __pyx_mstate_global->__pyx_n_s_DDMMYYN6 #define __pyx_n_s_DDMMYYN8 __pyx_mstate_global->__pyx_n_s_DDMMYYN8 #define __pyx_n_s_DDMMYYP __pyx_mstate_global->__pyx_n_s_DDMMYYP #define __pyx_n_s_DDMMYYP10 __pyx_mstate_global->__pyx_n_s_DDMMYYP10 #define __pyx_n_s_DDMMYYS __pyx_mstate_global->__pyx_n_s_DDMMYYS #define __pyx_n_s_DDMMYYS10 __pyx_mstate_global->__pyx_n_s_DDMMYYS10 #define __pyx_n_s_DTDATE __pyx_mstate_global->__pyx_n_s_DTDATE #define __pyx_n_s_DTIME __pyx_mstate_global->__pyx_n_s_DTIME #define __pyx_n_s_DataFrame __pyx_mstate_global->__pyx_n_s_DataFrame #define __pyx_n_s_E8601DA __pyx_mstate_global->__pyx_n_s_E8601DA #define __pyx_n_s_E8601DT __pyx_mstate_global->__pyx_n_s_E8601DT #define __pyx_n_s_E8601TM __pyx_mstate_global->__pyx_n_s_E8601TM #define __pyx_n_s_EDATE __pyx_mstate_global->__pyx_n_s_EDATE #define __pyx_n_s_EDATE10 __pyx_mstate_global->__pyx_n_s_EDATE10 #define __pyx_n_s_EDATE8 __pyx_mstate_global->__pyx_n_s_EDATE8 #define __pyx_kp_s_Failed_convert_C_to_python_value __pyx_mstate_global->__pyx_kp_s_Failed_convert_C_to_python_value #define __pyx_kp_s_Failed_to_read_number_of_variabl __pyx_mstate_global->__pyx_kp_s_Failed_to_read_number_of_variabl #define __pyx_kp_s_File_0_does_not_exist __pyx_mstate_global->__pyx_kp_s_File_0_does_not_exist #define __pyx_n_s_HHMM __pyx_mstate_global->__pyx_n_s_HHMM #define __pyx_n_s_IS8601DA __pyx_mstate_global->__pyx_n_s_IS8601DA #define __pyx_n_s_IS8601DT __pyx_mstate_global->__pyx_n_s_IS8601DT #define __pyx_n_s_IS8601TM __pyx_mstate_global->__pyx_n_s_IS8601TM #define __pyx_n_s_JDATE __pyx_mstate_global->__pyx_n_s_JDATE #define __pyx_n_s_JDATE5 __pyx_mstate_global->__pyx_n_s_JDATE5 #define __pyx_n_s_JDATE7 __pyx_mstate_global->__pyx_n_s_JDATE7 #define __pyx_kp_s_Just_defining_a_custom_exceptio __pyx_mstate_global->__pyx_kp_s_Just_defining_a_custom_exceptio #define __pyx_kp_s_Just_defining_a_custom_exceptio_2 __pyx_mstate_global->__pyx_kp_s_Just_defining_a_custom_exceptio_2 #define __pyx_kp_s_M8_ns __pyx_mstate_global->__pyx_kp_s_M8_ns #define __pyx_n_s_MDYAMPM __pyx_mstate_global->__pyx_n_s_MDYAMPM #define __pyx_n_s_MMDDYY __pyx_mstate_global->__pyx_n_s_MMDDYY #define __pyx_n_s_MMDDYYB __pyx_mstate_global->__pyx_n_s_MMDDYYB #define __pyx_n_s_MMDDYYB10 __pyx_mstate_global->__pyx_n_s_MMDDYYB10 #define __pyx_n_s_MMDDYYC __pyx_mstate_global->__pyx_n_s_MMDDYYC #define __pyx_n_s_MMDDYYC10 __pyx_mstate_global->__pyx_n_s_MMDDYYC10 #define __pyx_n_s_MMDDYYD __pyx_mstate_global->__pyx_n_s_MMDDYYD #define __pyx_n_s_MMDDYYD10 __pyx_mstate_global->__pyx_n_s_MMDDYYD10 #define __pyx_n_s_MMDDYYN6 __pyx_mstate_global->__pyx_n_s_MMDDYYN6 #define __pyx_n_s_MMDDYYN8 __pyx_mstate_global->__pyx_n_s_MMDDYYN8 #define __pyx_n_s_MMDDYYP __pyx_mstate_global->__pyx_n_s_MMDDYYP #define __pyx_n_s_MMDDYYP10 __pyx_mstate_global->__pyx_n_s_MMDDYYP10 #define __pyx_n_s_MMDDYYS __pyx_mstate_global->__pyx_n_s_MMDDYYS #define __pyx_n_s_MMDDYYS10 __pyx_mstate_global->__pyx_n_s_MMDDYYS10 #define __pyx_n_s_NULL __pyx_mstate_global->__pyx_n_s_NULL #define __pyx_n_s_OrderedDict __pyx_mstate_global->__pyx_n_s_OrderedDict #define __pyx_n_s_PyreadstatError __pyx_mstate_global->__pyx_n_s_PyreadstatError #define __pyx_n_s_ReadstatError __pyx_mstate_global->__pyx_n_s_ReadstatError #define __pyx_n_s_RuntimeError __pyx_mstate_global->__pyx_n_s_RuntimeError #define __pyx_n_s_SDATE __pyx_mstate_global->__pyx_n_s_SDATE #define __pyx_n_s_SDATE10 __pyx_mstate_global->__pyx_n_s_SDATE10 #define __pyx_n_s_SDATE8 __pyx_mstate_global->__pyx_n_s_SDATE8 #define __pyx_kp_s_STRING_type_with_value_s_with_da __pyx_mstate_global->__pyx_kp_s_STRING_type_with_value_s_with_da #define __pyx_n_s_TIME __pyx_mstate_global->__pyx_n_s_TIME #define __pyx_kp_s_TIME11_2 __pyx_mstate_global->__pyx_kp_s_TIME11_2 #define __pyx_n_s_TIME20 __pyx_mstate_global->__pyx_n_s_TIME20 #define __pyx_kp_s_TIME20_3 __pyx_mstate_global->__pyx_kp_s_TIME20_3 #define __pyx_n_s_TIME5 __pyx_mstate_global->__pyx_n_s_TIME5 #define __pyx_n_s_TIME8 __pyx_mstate_global->__pyx_n_s_TIME8 #define __pyx_n_s_TIMEAMPM __pyx_mstate_global->__pyx_n_s_TIMEAMPM #define __pyx_n_s_TOD __pyx_mstate_global->__pyx_n_s_TOD #define __pyx_kp_s_This_class_holds_metadata_we_wa __pyx_mstate_global->__pyx_kp_s_This_class_holds_metadata_we_wa #define __pyx_kp_s_Time_zones_are_not_available_fro __pyx_mstate_global->__pyx_kp_s_Time_zones_are_not_available_fro #define __pyx_n_s_TypeError __pyx_mstate_global->__pyx_n_s_TypeError #define __pyx_n_s_UnicodeError __pyx_mstate_global->__pyx_n_s_UnicodeError #define __pyx_kp_s_Unknown_file_format __pyx_mstate_global->__pyx_kp_s_Unknown_file_format #define __pyx_kp_s_Unkown_data_type __pyx_mstate_global->__pyx_kp_s_Unkown_data_type #define __pyx_n_s_WEEKDATE __pyx_mstate_global->__pyx_n_s_WEEKDATE #define __pyx_n_s_WEEKDATX __pyx_mstate_global->__pyx_n_s_WEEKDATX #define __pyx_n_s_YMDHMS16 __pyx_mstate_global->__pyx_n_s_YMDHMS16 #define __pyx_n_s_YMDHMS19 __pyx_mstate_global->__pyx_n_s_YMDHMS19 #define __pyx_kp_s_YMDHMS19_2 __pyx_mstate_global->__pyx_kp_s_YMDHMS19_2 #define __pyx_n_s_YMDHMS20 __pyx_mstate_global->__pyx_n_s_YMDHMS20 #define __pyx_n_s_YYMMDD __pyx_mstate_global->__pyx_n_s_YYMMDD #define __pyx_n_s_YYMMDD10 __pyx_mstate_global->__pyx_n_s_YYMMDD10 #define __pyx_n_s_YYMMDDB __pyx_mstate_global->__pyx_n_s_YYMMDDB #define __pyx_n_s_YYMMDDD __pyx_mstate_global->__pyx_n_s_YYMMDDD #define __pyx_n_s_YYMMDDN __pyx_mstate_global->__pyx_n_s_YYMMDDN #define __pyx_n_s_YYMMDDP __pyx_mstate_global->__pyx_n_s_YYMMDDP #define __pyx_n_s_YYMMDDS __pyx_mstate_global->__pyx_n_s_YYMMDDS #define __pyx_n_s__15 __pyx_mstate_global->__pyx_n_s__15 #define __pyx_kp_s__2 __pyx_mstate_global->__pyx_kp_s__2 #define __pyx_kp_u__8 __pyx_mstate_global->__pyx_kp_u__8 #define __pyx_n_s__9 __pyx_mstate_global->__pyx_n_s__9 #define __pyx_n_s_allowed_formats __pyx_mstate_global->__pyx_n_s_allowed_formats #define __pyx_n_s_append __pyx_mstate_global->__pyx_n_s_append #define __pyx_n_s_astype __pyx_mstate_global->__pyx_n_s_astype #define __pyx_n_s_asyncio_coroutines __pyx_mstate_global->__pyx_n_s_asyncio_coroutines #define __pyx_n_s_center __pyx_mstate_global->__pyx_n_s_center #define __pyx_n_s_chr __pyx_mstate_global->__pyx_n_s_chr #define __pyx_n_s_class_getitem __pyx_mstate_global->__pyx_n_s_class_getitem #define __pyx_n_s_cline_in_traceback __pyx_mstate_global->__pyx_n_s_cline_in_traceback #define __pyx_n_s_collections __pyx_mstate_global->__pyx_n_s_collections #define __pyx_kp_s_column_0_is_duplicated_renamed_t __pyx_mstate_global->__pyx_kp_s_column_0_is_duplicated_renamed_t #define __pyx_n_s_column_labels __pyx_mstate_global->__pyx_n_s_column_labels #define __pyx_n_s_column_names __pyx_mstate_global->__pyx_n_s_column_names #define __pyx_n_s_column_names_to_labels __pyx_mstate_global->__pyx_n_s_column_names_to_labels #define __pyx_n_s_columns __pyx_mstate_global->__pyx_n_s_columns #define __pyx_n_s_copy __pyx_mstate_global->__pyx_n_s_copy #define __pyx_n_s_creation_time __pyx_mstate_global->__pyx_n_s_creation_time #define __pyx_kp_s_d __pyx_mstate_global->__pyx_kp_s_d #define __pyx_n_s_data_container __pyx_mstate_global->__pyx_n_s_data_container #define __pyx_n_s_data_container___reduce_cython __pyx_mstate_global->__pyx_n_s_data_container___reduce_cython #define __pyx_n_s_data_container___setstate_cython __pyx_mstate_global->__pyx_n_s_data_container___setstate_cython #define __pyx_n_s_date __pyx_mstate_global->__pyx_n_s_date #define __pyx_n_s_datetime __pyx_mstate_global->__pyx_n_s_datetime #define __pyx_n_s_dict __pyx_mstate_global->__pyx_n_s_dict #define __pyx_n_s_dict_2 __pyx_mstate_global->__pyx_n_s_dict_2 #define __pyx_kp_u_disable __pyx_mstate_global->__pyx_kp_u_disable #define __pyx_n_s_doc __pyx_mstate_global->__pyx_n_s_doc #define __pyx_n_s_double __pyx_mstate_global->__pyx_n_s_double #define __pyx_n_s_dtype __pyx_mstate_global->__pyx_n_s_dtype #define __pyx_n_s_dtypes __pyx_mstate_global->__pyx_n_s_dtypes #define __pyx_n_s_duplicated __pyx_mstate_global->__pyx_n_s_duplicated #define __pyx_n_s_empty __pyx_mstate_global->__pyx_n_s_empty #define __pyx_kp_u_enable __pyx_mstate_global->__pyx_kp_u_enable #define __pyx_n_s_encode __pyx_mstate_global->__pyx_n_s_encode #define __pyx_n_s_enumerate __pyx_mstate_global->__pyx_n_s_enumerate #define __pyx_n_s_expanduser __pyx_mstate_global->__pyx_n_s_expanduser #define __pyx_n_s_file_encoding __pyx_mstate_global->__pyx_n_s_file_encoding #define __pyx_n_s_file_label __pyx_mstate_global->__pyx_n_s_file_label #define __pyx_kp_s_file_path_could_not_be_encoded_w __pyx_mstate_global->__pyx_kp_s_file_path_could_not_be_encoded_w #define __pyx_n_s_fill __pyx_mstate_global->__pyx_n_s_fill #define __pyx_n_s_float __pyx_mstate_global->__pyx_n_s_float #define __pyx_n_s_float64 __pyx_mstate_global->__pyx_n_s_float64 #define __pyx_n_s_format __pyx_mstate_global->__pyx_n_s_format #define __pyx_n_s_from_dict __pyx_mstate_global->__pyx_n_s_from_dict #define __pyx_n_s_fromtimestamp __pyx_mstate_global->__pyx_n_s_fromtimestamp #define __pyx_n_s_fsdecode __pyx_mstate_global->__pyx_n_s_fsdecode #define __pyx_n_s_fsencode __pyx_mstate_global->__pyx_n_s_fsencode #define __pyx_kp_u_gc __pyx_mstate_global->__pyx_kp_u_gc #define __pyx_n_s_get __pyx_mstate_global->__pyx_n_s_get #define __pyx_n_s_getfilesystemencoding __pyx_mstate_global->__pyx_n_s_getfilesystemencoding #define __pyx_n_s_getstate __pyx_mstate_global->__pyx_n_s_getstate #define __pyx_n_s_hi __pyx_mstate_global->__pyx_n_s_hi #define __pyx_n_s_import __pyx_mstate_global->__pyx_n_s_import #define __pyx_n_s_init __pyx_mstate_global->__pyx_n_s_init #define __pyx_n_s_init_subclass __pyx_mstate_global->__pyx_n_s_init_subclass #define __pyx_n_s_initializing __pyx_mstate_global->__pyx_n_s_initializing #define __pyx_n_s_int16 __pyx_mstate_global->__pyx_n_s_int16 #define __pyx_n_s_int32 __pyx_mstate_global->__pyx_n_s_int32 #define __pyx_n_s_int64 __pyx_mstate_global->__pyx_n_s_int64 #define __pyx_n_s_int8 __pyx_mstate_global->__pyx_n_s_int8 #define __pyx_n_s_is_coroutine __pyx_mstate_global->__pyx_n_s_is_coroutine #define __pyx_kp_u_isenabled __pyx_mstate_global->__pyx_kp_u_isenabled #define __pyx_n_s_isfile __pyx_mstate_global->__pyx_n_s_isfile #define __pyx_n_s_items __pyx_mstate_global->__pyx_n_s_items #define __pyx_n_s_left __pyx_mstate_global->__pyx_n_s_left #define __pyx_n_s_lo __pyx_mstate_global->__pyx_n_s_lo #define __pyx_n_s_main __pyx_mstate_global->__pyx_n_s_main #define __pyx_n_s_metaclass __pyx_mstate_global->__pyx_n_s_metaclass #define __pyx_n_s_metadata_container __pyx_mstate_global->__pyx_n_s_metadata_container #define __pyx_n_s_metadata_container___init __pyx_mstate_global->__pyx_n_s_metadata_container___init #define __pyx_n_s_missing_ranges __pyx_mstate_global->__pyx_n_s_missing_ranges #define __pyx_n_s_missing_user_values __pyx_mstate_global->__pyx_n_s_missing_user_values #define __pyx_n_s_modification_time __pyx_mstate_global->__pyx_n_s_modification_time #define __pyx_n_s_module __pyx_mstate_global->__pyx_n_s_module #define __pyx_n_s_mro_entries __pyx_mstate_global->__pyx_n_s_mro_entries #define __pyx_n_s_name __pyx_mstate_global->__pyx_n_s_name #define __pyx_n_s_name_2 __pyx_mstate_global->__pyx_n_s_name_2 #define __pyx_n_s_nan __pyx_mstate_global->__pyx_n_s_nan #define __pyx_kp_s_no_default___reduce___due_to_non __pyx_mstate_global->__pyx_kp_s_no_default___reduce___due_to_non #define __pyx_n_s_nominal __pyx_mstate_global->__pyx_n_s_nominal #define __pyx_n_s_notes __pyx_mstate_global->__pyx_n_s_notes #define __pyx_n_s_np __pyx_mstate_global->__pyx_n_s_np #define __pyx_n_s_nt __pyx_mstate_global->__pyx_n_s_nt #define __pyx_n_s_number_columns __pyx_mstate_global->__pyx_n_s_number_columns #define __pyx_n_s_number_rows __pyx_mstate_global->__pyx_n_s_number_rows #define __pyx_n_s_numpy __pyx_mstate_global->__pyx_n_s_numpy #define __pyx_n_s_object __pyx_mstate_global->__pyx_n_s_object #define __pyx_n_s_ordinal __pyx_mstate_global->__pyx_n_s_ordinal #define __pyx_n_s_original_variable_types __pyx_mstate_global->__pyx_n_s_original_variable_types #define __pyx_n_s_os __pyx_mstate_global->__pyx_n_s_os #define __pyx_n_s_output_format __pyx_mstate_global->__pyx_n_s_output_format #define __pyx_kp_s_output_format_must_be_one_of_all __pyx_mstate_global->__pyx_kp_s_output_format_must_be_one_of_all #define __pyx_n_s_pandas __pyx_mstate_global->__pyx_n_s_pandas #define __pyx_n_s_path __pyx_mstate_global->__pyx_n_s_path #define __pyx_kp_s_path_must_be_either_str_or_bytes __pyx_mstate_global->__pyx_kp_s_path_must_be_either_str_or_bytes #define __pyx_kp_s_path_must_be_str_bytes_or_unicod __pyx_mstate_global->__pyx_kp_s_path_must_be_str_bytes_or_unicod #define __pyx_n_s_pd __pyx_mstate_global->__pyx_n_s_pd #define __pyx_n_s_prepare __pyx_mstate_global->__pyx_n_s_prepare #define __pyx_n_s_pyreadstat__readstat_parser __pyx_mstate_global->__pyx_n_s_pyreadstat__readstat_parser #define __pyx_kp_s_pyreadstat__readstat_parser_pyx __pyx_mstate_global->__pyx_kp_s_pyreadstat__readstat_parser_pyx #define __pyx_n_s_pyx_capi __pyx_mstate_global->__pyx_n_s_pyx_capi #define __pyx_n_s_pyx_state __pyx_mstate_global->__pyx_n_s_pyx_state #define __pyx_n_s_qualname __pyx_mstate_global->__pyx_n_s_qualname #define __pyx_n_s_range __pyx_mstate_global->__pyx_n_s_range #define __pyx_n_s_readstat_to_numpy_types __pyx_mstate_global->__pyx_n_s_readstat_to_numpy_types #define __pyx_n_s_readstat_variable_types __pyx_mstate_global->__pyx_n_s_readstat_variable_types #define __pyx_n_s_reduce __pyx_mstate_global->__pyx_n_s_reduce #define __pyx_n_s_reduce_cython __pyx_mstate_global->__pyx_n_s_reduce_cython #define __pyx_n_s_reduce_ex __pyx_mstate_global->__pyx_n_s_reduce_ex #define __pyx_n_s_right __pyx_mstate_global->__pyx_n_s_right #define __pyx_n_s_sas_all_formats __pyx_mstate_global->__pyx_n_s_sas_all_formats #define __pyx_n_s_sas_date_formats __pyx_mstate_global->__pyx_n_s_sas_date_formats #define __pyx_n_s_sas_datetime_formats __pyx_mstate_global->__pyx_n_s_sas_datetime_formats #define __pyx_n_s_sas_origin __pyx_mstate_global->__pyx_n_s_sas_origin #define __pyx_n_s_sas_time_formats __pyx_mstate_global->__pyx_n_s_sas_time_formats #define __pyx_n_s_scale __pyx_mstate_global->__pyx_n_s_scale #define __pyx_n_s_self __pyx_mstate_global->__pyx_n_s_self #define __pyx_n_s_set_name __pyx_mstate_global->__pyx_n_s_set_name #define __pyx_n_s_setstate __pyx_mstate_global->__pyx_n_s_setstate #define __pyx_n_s_setstate_cython __pyx_mstate_global->__pyx_n_s_setstate_cython #define __pyx_n_s_spec __pyx_mstate_global->__pyx_n_s_spec #define __pyx_n_s_spss_all_formats __pyx_mstate_global->__pyx_n_s_spss_all_formats #define __pyx_n_s_spss_date_formats __pyx_mstate_global->__pyx_n_s_spss_date_formats #define __pyx_n_s_spss_datetime_formats __pyx_mstate_global->__pyx_n_s_spss_datetime_formats #define __pyx_n_s_spss_origin __pyx_mstate_global->__pyx_n_s_spss_origin #define __pyx_n_s_spss_time_formats __pyx_mstate_global->__pyx_n_s_spss_time_formats #define __pyx_n_s_stata_all_formats __pyx_mstate_global->__pyx_n_s_stata_all_formats #define __pyx_n_s_stata_date_formats __pyx_mstate_global->__pyx_n_s_stata_date_formats #define __pyx_n_s_stata_datetime_formats __pyx_mstate_global->__pyx_n_s_stata_datetime_formats #define __pyx_n_s_stata_origin __pyx_mstate_global->__pyx_n_s_stata_origin #define __pyx_n_s_stata_time_formats __pyx_mstate_global->__pyx_n_s_stata_time_formats #define __pyx_n_s_string __pyx_mstate_global->__pyx_n_s_string #define __pyx_kp_s_stringsource __pyx_mstate_global->__pyx_kp_s_stringsource #define __pyx_n_s_super __pyx_mstate_global->__pyx_n_s_super #define __pyx_n_s_surrogateescape __pyx_mstate_global->__pyx_n_s_surrogateescape #define __pyx_n_s_sys __pyx_mstate_global->__pyx_n_s_sys #define __pyx_kp_s_tC __pyx_mstate_global->__pyx_kp_s_tC #define __pyx_n_s_table_name __pyx_mstate_global->__pyx_n_s_table_name #define __pyx_kp_s_tc __pyx_mstate_global->__pyx_kp_s_tc #define __pyx_kp_s_tcHH_MM __pyx_mstate_global->__pyx_kp_s_tcHH_MM #define __pyx_kp_s_tcHH_MM_SS __pyx_mstate_global->__pyx_kp_s_tcHH_MM_SS #define __pyx_kp_s_td __pyx_mstate_global->__pyx_kp_s_td #define __pyx_kp_s_tdCCYY_NN_DD __pyx_mstate_global->__pyx_kp_s_tdCCYY_NN_DD #define __pyx_kp_s_tdD_m_Y __pyx_mstate_global->__pyx_kp_s_tdD_m_Y #define __pyx_n_s_test __pyx_mstate_global->__pyx_n_s_test #define __pyx_n_s_time __pyx_mstate_global->__pyx_n_s_time #define __pyx_n_s_to_datetime __pyx_mstate_global->__pyx_n_s_to_datetime #define __pyx_n_s_tolist __pyx_mstate_global->__pyx_n_s_tolist #define __pyx_n_s_undetermined __pyx_mstate_global->__pyx_n_s_undetermined #define __pyx_n_s_unknown __pyx_mstate_global->__pyx_n_s_unknown #define __pyx_kp_s_utf_8 __pyx_mstate_global->__pyx_kp_s_utf_8 #define __pyx_n_s_value_labels __pyx_mstate_global->__pyx_n_s_value_labels #define __pyx_n_s_variable_alignment __pyx_mstate_global->__pyx_n_s_variable_alignment #define __pyx_n_s_variable_display_width __pyx_mstate_global->__pyx_n_s_variable_display_width #define __pyx_n_s_variable_measure __pyx_mstate_global->__pyx_n_s_variable_measure #define __pyx_n_s_variable_storage_width __pyx_mstate_global->__pyx_n_s_variable_storage_width #define __pyx_n_s_variable_to_label __pyx_mstate_global->__pyx_n_s_variable_to_label #define __pyx_n_s_variable_value_labels __pyx_mstate_global->__pyx_n_s_variable_value_labels #define __pyx_n_s_warn __pyx_mstate_global->__pyx_n_s_warn #define __pyx_n_s_warnings __pyx_mstate_global->__pyx_n_s_warnings #define __pyx_n_s_zip __pyx_mstate_global->__pyx_n_s_zip #define __pyx_int_0 __pyx_mstate_global->__pyx_int_0 #define __pyx_int_1 __pyx_mstate_global->__pyx_int_1 #define __pyx_int_100000 __pyx_mstate_global->__pyx_int_100000 #define __pyx_tuple_ __pyx_mstate_global->__pyx_tuple_ #define __pyx_tuple__3 __pyx_mstate_global->__pyx_tuple__3 #define __pyx_tuple__4 __pyx_mstate_global->__pyx_tuple__4 #define __pyx_tuple__5 __pyx_mstate_global->__pyx_tuple__5 #define __pyx_tuple__6 __pyx_mstate_global->__pyx_tuple__6 #define __pyx_tuple__7 __pyx_mstate_global->__pyx_tuple__7 #define __pyx_tuple__10 __pyx_mstate_global->__pyx_tuple__10 #define __pyx_tuple__12 __pyx_mstate_global->__pyx_tuple__12 #define __pyx_codeobj__11 __pyx_mstate_global->__pyx_codeobj__11 #define __pyx_codeobj__13 __pyx_mstate_global->__pyx_codeobj__13 #define __pyx_codeobj__14 __pyx_mstate_global->__pyx_codeobj__14 /* #### Code section: module_code ### */ /* "cpython/datetime.pxd":72 * ctypedef extern class datetime.date[object PyDateTime_Date]: * @property * cdef inline int year(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_YEAR(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4date_4year_year(PyDateTime_Date *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":73 * @property * cdef inline int year(self): * return PyDateTime_GET_YEAR(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_GET_YEAR(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":72 * ctypedef extern class datetime.date[object PyDateTime_Date]: * @property * cdef inline int year(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_YEAR(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":76 * * @property * cdef inline int month(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_MONTH(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4date_5month_month(PyDateTime_Date *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":77 * @property * cdef inline int month(self): * return PyDateTime_GET_MONTH(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_GET_MONTH(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":76 * * @property * cdef inline int month(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_MONTH(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":80 * * @property * cdef inline int day(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_DAY(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4date_3day_day(PyDateTime_Date *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":81 * @property * cdef inline int day(self): * return PyDateTime_GET_DAY(self) # <<<<<<<<<<<<<< * * ctypedef extern class datetime.time[object PyDateTime_Time]: */ __pyx_r = PyDateTime_GET_DAY(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":80 * * @property * cdef inline int day(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_DAY(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":85 * ctypedef extern class datetime.time[object PyDateTime_Time]: * @property * cdef inline int hour(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_HOUR(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_4hour_hour(PyDateTime_Time *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":86 * @property * cdef inline int hour(self): * return PyDateTime_TIME_GET_HOUR(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_TIME_GET_HOUR(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":85 * ctypedef extern class datetime.time[object PyDateTime_Time]: * @property * cdef inline int hour(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_HOUR(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":89 * * @property * cdef inline int minute(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_MINUTE(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_6minute_minute(PyDateTime_Time *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":90 * @property * cdef inline int minute(self): * return PyDateTime_TIME_GET_MINUTE(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_TIME_GET_MINUTE(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":89 * * @property * cdef inline int minute(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_MINUTE(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":93 * * @property * cdef inline int second(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_SECOND(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_6second_second(PyDateTime_Time *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":94 * @property * cdef inline int second(self): * return PyDateTime_TIME_GET_SECOND(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_TIME_GET_SECOND(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":93 * * @property * cdef inline int second(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_SECOND(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":97 * * @property * cdef inline int microsecond(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_MICROSECOND(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_11microsecond_microsecond(PyDateTime_Time *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":98 * @property * cdef inline int microsecond(self): * return PyDateTime_TIME_GET_MICROSECOND(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_TIME_GET_MICROSECOND(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":97 * * @property * cdef inline int microsecond(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_MICROSECOND(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":101 * * @property * cdef inline object tzinfo(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_TZINFO(self) * */ static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_4time_6tzinfo_tzinfo(PyDateTime_Time *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1; __Pyx_RefNannySetupContext("tzinfo", 1); /* "cpython/datetime.pxd":102 * @property * cdef inline object tzinfo(self): * return PyDateTime_TIME_GET_TZINFO(self) # <<<<<<<<<<<<<< * * @property */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyDateTime_TIME_GET_TZINFO(((PyObject *)__pyx_v_self)); __Pyx_INCREF(((PyObject *)__pyx_t_1)); __pyx_r = ((PyObject *)__pyx_t_1); goto __pyx_L0; /* "cpython/datetime.pxd":101 * * @property * cdef inline object tzinfo(self): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_TZINFO(self) * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":105 * * @property * cdef inline int fold(self): # <<<<<<<<<<<<<< * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_TIME_GET_FOLD(self) */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_4time_4fold_fold(PyDateTime_Time *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":107 * cdef inline int fold(self): * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_TIME_GET_FOLD(self) # <<<<<<<<<<<<<< * * ctypedef extern class datetime.datetime[object PyDateTime_DateTime]: */ __pyx_r = PyDateTime_TIME_GET_FOLD(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":105 * * @property * cdef inline int fold(self): # <<<<<<<<<<<<<< * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_TIME_GET_FOLD(self) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":111 * ctypedef extern class datetime.datetime[object PyDateTime_DateTime]: * @property * cdef inline int year(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_YEAR(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_4year_year(PyDateTime_DateTime *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":112 * @property * cdef inline int year(self): * return PyDateTime_GET_YEAR(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_GET_YEAR(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":111 * ctypedef extern class datetime.datetime[object PyDateTime_DateTime]: * @property * cdef inline int year(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_YEAR(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":115 * * @property * cdef inline int month(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_MONTH(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_5month_month(PyDateTime_DateTime *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":116 * @property * cdef inline int month(self): * return PyDateTime_GET_MONTH(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_GET_MONTH(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":115 * * @property * cdef inline int month(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_MONTH(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":119 * * @property * cdef inline int day(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_DAY(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_3day_day(PyDateTime_DateTime *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":120 * @property * cdef inline int day(self): * return PyDateTime_GET_DAY(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_GET_DAY(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":119 * * @property * cdef inline int day(self): # <<<<<<<<<<<<<< * return PyDateTime_GET_DAY(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":123 * * @property * cdef inline int hour(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_HOUR(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_4hour_hour(PyDateTime_DateTime *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":124 * @property * cdef inline int hour(self): * return PyDateTime_DATE_GET_HOUR(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_DATE_GET_HOUR(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":123 * * @property * cdef inline int hour(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_HOUR(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":127 * * @property * cdef inline int minute(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_MINUTE(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_6minute_minute(PyDateTime_DateTime *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":128 * @property * cdef inline int minute(self): * return PyDateTime_DATE_GET_MINUTE(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_DATE_GET_MINUTE(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":127 * * @property * cdef inline int minute(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_MINUTE(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":131 * * @property * cdef inline int second(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_SECOND(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_6second_second(PyDateTime_DateTime *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":132 * @property * cdef inline int second(self): * return PyDateTime_DATE_GET_SECOND(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_DATE_GET_SECOND(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":131 * * @property * cdef inline int second(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_SECOND(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":135 * * @property * cdef inline int microsecond(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_MICROSECOND(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_11microsecond_microsecond(PyDateTime_DateTime *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":136 * @property * cdef inline int microsecond(self): * return PyDateTime_DATE_GET_MICROSECOND(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_DATE_GET_MICROSECOND(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":135 * * @property * cdef inline int microsecond(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_MICROSECOND(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":139 * * @property * cdef inline object tzinfo(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_TZINFO(self) * */ static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_8datetime_6tzinfo_tzinfo(PyDateTime_DateTime *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1; __Pyx_RefNannySetupContext("tzinfo", 1); /* "cpython/datetime.pxd":140 * @property * cdef inline object tzinfo(self): * return PyDateTime_DATE_GET_TZINFO(self) # <<<<<<<<<<<<<< * * @property */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyDateTime_DATE_GET_TZINFO(((PyObject *)__pyx_v_self)); __Pyx_INCREF(((PyObject *)__pyx_t_1)); __pyx_r = ((PyObject *)__pyx_t_1); goto __pyx_L0; /* "cpython/datetime.pxd":139 * * @property * cdef inline object tzinfo(self): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_TZINFO(self) * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":143 * * @property * cdef inline int fold(self): # <<<<<<<<<<<<<< * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_DATE_GET_FOLD(self) */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_8datetime_4fold_fold(PyDateTime_DateTime *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":145 * cdef inline int fold(self): * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_DATE_GET_FOLD(self) # <<<<<<<<<<<<<< * * ctypedef extern class datetime.timedelta[object PyDateTime_Delta]: */ __pyx_r = PyDateTime_DATE_GET_FOLD(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":143 * * @property * cdef inline int fold(self): # <<<<<<<<<<<<<< * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_DATE_GET_FOLD(self) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":149 * ctypedef extern class datetime.timedelta[object PyDateTime_Delta]: * @property * cdef inline int day(self): # <<<<<<<<<<<<<< * return PyDateTime_DELTA_GET_DAYS(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_9timedelta_3day_day(PyDateTime_Delta *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":150 * @property * cdef inline int day(self): * return PyDateTime_DELTA_GET_DAYS(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_DELTA_GET_DAYS(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":149 * ctypedef extern class datetime.timedelta[object PyDateTime_Delta]: * @property * cdef inline int day(self): # <<<<<<<<<<<<<< * return PyDateTime_DELTA_GET_DAYS(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":153 * * @property * cdef inline int second(self): # <<<<<<<<<<<<<< * return PyDateTime_DELTA_GET_SECONDS(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_9timedelta_6second_second(PyDateTime_Delta *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":154 * @property * cdef inline int second(self): * return PyDateTime_DELTA_GET_SECONDS(self) # <<<<<<<<<<<<<< * * @property */ __pyx_r = PyDateTime_DELTA_GET_SECONDS(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":153 * * @property * cdef inline int second(self): # <<<<<<<<<<<<<< * return PyDateTime_DELTA_GET_SECONDS(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":157 * * @property * cdef inline int microsecond(self): # <<<<<<<<<<<<<< * return PyDateTime_DELTA_GET_MICROSECONDS(self) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_9timedelta_11microsecond_microsecond(PyDateTime_Delta *__pyx_v_self) { int __pyx_r; /* "cpython/datetime.pxd":158 * @property * cdef inline int microsecond(self): * return PyDateTime_DELTA_GET_MICROSECONDS(self) # <<<<<<<<<<<<<< * * ctypedef extern class datetime.tzinfo[object PyDateTime_TZInfo]: */ __pyx_r = PyDateTime_DELTA_GET_MICROSECONDS(((PyObject *)__pyx_v_self)); goto __pyx_L0; /* "cpython/datetime.pxd":157 * * @property * cdef inline int microsecond(self): # <<<<<<<<<<<<<< * return PyDateTime_DELTA_GET_MICROSECONDS(self) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":282 * # Datetime C API initialization function. * # You have to call it before any usage of DateTime CAPI functions. * cdef inline void import_datetime(): # <<<<<<<<<<<<<< * PyDateTime_IMPORT * */ static CYTHON_INLINE void __pyx_f_7cpython_8datetime_import_datetime(void) { /* "cpython/datetime.pxd":283 * # You have to call it before any usage of DateTime CAPI functions. * cdef inline void import_datetime(): * PyDateTime_IMPORT # <<<<<<<<<<<<<< * * # Create date object using DateTime CAPI factory function. */ (void)(PyDateTime_IMPORT); /* "cpython/datetime.pxd":282 * # Datetime C API initialization function. * # You have to call it before any usage of DateTime CAPI functions. * cdef inline void import_datetime(): # <<<<<<<<<<<<<< * PyDateTime_IMPORT * */ /* function exit code */ } /* "cpython/datetime.pxd":287 * # Create date object using DateTime CAPI factory function. * # Note, there are no range checks for any of the arguments. * cdef inline date date_new(int year, int month, int day): # <<<<<<<<<<<<<< * return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType) * */ static CYTHON_INLINE PyDateTime_Date *__pyx_f_7cpython_8datetime_date_new(int __pyx_v_year, int __pyx_v_month, int __pyx_v_day) { PyDateTime_Date *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("date_new", 1); /* "cpython/datetime.pxd":288 * # Note, there are no range checks for any of the arguments. * cdef inline date date_new(int year, int month, int day): * return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType) # <<<<<<<<<<<<<< * * # Create time object using DateTime CAPI factory function */ __Pyx_XDECREF((PyObject *)__pyx_r); __pyx_t_1 = ((PyObject *)PyDateTimeAPI->Date_FromDate(__pyx_v_year, __pyx_v_month, __pyx_v_day, PyDateTimeAPI->DateType)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((PyDateTime_Date *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; /* "cpython/datetime.pxd":287 * # Create date object using DateTime CAPI factory function. * # Note, there are no range checks for any of the arguments. * cdef inline date date_new(int year, int month, int day): # <<<<<<<<<<<<<< * return PyDateTimeAPI.Date_FromDate(year, month, day, PyDateTimeAPI.DateType) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("cpython.datetime.date_new", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":292 * # Create time object using DateTime CAPI factory function * # Note, there are no range checks for any of the arguments. * cdef inline time time_new(int hour, int minute, int second, int microsecond, object tz, int fold=0): # <<<<<<<<<<<<<< * return __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) * */ static CYTHON_INLINE PyDateTime_Time *__pyx_f_7cpython_8datetime_time_new(int __pyx_v_hour, int __pyx_v_minute, int __pyx_v_second, int __pyx_v_microsecond, PyObject *__pyx_v_tz, struct __pyx_opt_args_7cpython_8datetime_time_new *__pyx_optional_args) { int __pyx_v_fold = ((int)0); PyDateTime_Time *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("time_new", 1); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_fold = __pyx_optional_args->fold; } } /* "cpython/datetime.pxd":293 * # Note, there are no range checks for any of the arguments. * cdef inline time time_new(int hour, int minute, int second, int microsecond, object tz, int fold=0): * return __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) # <<<<<<<<<<<<<< * * # Create datetime object using DateTime CAPI factory function. */ __Pyx_XDECREF((PyObject *)__pyx_r); __pyx_t_1 = ((PyObject *)__Pyx_DateTime_TimeWithFold(__pyx_v_hour, __pyx_v_minute, __pyx_v_second, __pyx_v_microsecond, __pyx_v_tz, __pyx_v_fold)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7cpython_8datetime_time))))) __PYX_ERR(2, 293, __pyx_L1_error) __pyx_r = ((PyDateTime_Time *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; /* "cpython/datetime.pxd":292 * # Create time object using DateTime CAPI factory function * # Note, there are no range checks for any of the arguments. * cdef inline time time_new(int hour, int minute, int second, int microsecond, object tz, int fold=0): # <<<<<<<<<<<<<< * return __Pyx_DateTime_TimeWithFold(hour, minute, second, microsecond, tz, fold) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("cpython.datetime.time_new", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":297 * # Create datetime object using DateTime CAPI factory function. * # Note, there are no range checks for any of the arguments. * cdef inline datetime datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz, int fold=0): # <<<<<<<<<<<<<< * return __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) * */ static CYTHON_INLINE PyDateTime_DateTime *__pyx_f_7cpython_8datetime_datetime_new(int __pyx_v_year, int __pyx_v_month, int __pyx_v_day, int __pyx_v_hour, int __pyx_v_minute, int __pyx_v_second, int __pyx_v_microsecond, PyObject *__pyx_v_tz, struct __pyx_opt_args_7cpython_8datetime_datetime_new *__pyx_optional_args) { int __pyx_v_fold = ((int)0); PyDateTime_DateTime *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("datetime_new", 1); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_fold = __pyx_optional_args->fold; } } /* "cpython/datetime.pxd":298 * # Note, there are no range checks for any of the arguments. * cdef inline datetime datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz, int fold=0): * return __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) # <<<<<<<<<<<<<< * * # Create timedelta object using DateTime CAPI factory function. */ __Pyx_XDECREF((PyObject *)__pyx_r); __pyx_t_1 = ((PyObject *)__Pyx_DateTime_DateTimeWithFold(__pyx_v_year, __pyx_v_month, __pyx_v_day, __pyx_v_hour, __pyx_v_minute, __pyx_v_second, __pyx_v_microsecond, __pyx_v_tz, __pyx_v_fold)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((PyDateTime_DateTime *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; /* "cpython/datetime.pxd":297 * # Create datetime object using DateTime CAPI factory function. * # Note, there are no range checks for any of the arguments. * cdef inline datetime datetime_new(int year, int month, int day, int hour, int minute, int second, int microsecond, object tz, int fold=0): # <<<<<<<<<<<<<< * return __Pyx_DateTime_DateTimeWithFold(year, month, day, hour, minute, second, microsecond, tz, fold) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("cpython.datetime.datetime_new", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":302 * # Create timedelta object using DateTime CAPI factory function. * # Note, there are no range checks for any of the arguments. * cdef inline timedelta timedelta_new(int days, int seconds, int useconds): # <<<<<<<<<<<<<< * return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType) * */ static CYTHON_INLINE PyDateTime_Delta *__pyx_f_7cpython_8datetime_timedelta_new(int __pyx_v_days, int __pyx_v_seconds, int __pyx_v_useconds) { PyDateTime_Delta *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("timedelta_new", 1); /* "cpython/datetime.pxd":303 * # Note, there are no range checks for any of the arguments. * cdef inline timedelta timedelta_new(int days, int seconds, int useconds): * return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType) # <<<<<<<<<<<<<< * * # Create timedelta object using DateTime CAPI factory function. */ __Pyx_XDECREF((PyObject *)__pyx_r); __pyx_t_1 = ((PyObject *)PyDateTimeAPI->Delta_FromDelta(__pyx_v_days, __pyx_v_seconds, __pyx_v_useconds, 1, PyDateTimeAPI->DeltaType)); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((PyDateTime_Delta *)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; /* "cpython/datetime.pxd":302 * # Create timedelta object using DateTime CAPI factory function. * # Note, there are no range checks for any of the arguments. * cdef inline timedelta timedelta_new(int days, int seconds, int useconds): # <<<<<<<<<<<<<< * return PyDateTimeAPI.Delta_FromDelta(days, seconds, useconds, 1, PyDateTimeAPI.DeltaType) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("cpython.datetime.timedelta_new", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":306 * * # Create timedelta object using DateTime CAPI factory function. * cdef inline object timezone_new(object offset, object name=None): # <<<<<<<<<<<<<< * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') */ static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_timezone_new(PyObject *__pyx_v_offset, struct __pyx_opt_args_7cpython_8datetime_timezone_new *__pyx_optional_args) { PyObject *__pyx_v_name = ((PyObject *)Py_None); PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("timezone_new", 1); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_name = __pyx_optional_args->name; } } /* "cpython/datetime.pxd":307 * # Create timedelta object using DateTime CAPI factory function. * cdef inline object timezone_new(object offset, object name=None): * if PY_VERSION_HEX < 0x030700b1: # <<<<<<<<<<<<<< * raise RuntimeError('Time zones are not available from the C-API.') * return __Pyx_TimeZone_FromOffsetAndName(offset, name if name is not None else NULL) */ __pyx_t_1 = (PY_VERSION_HEX < 0x030700b1); if (unlikely(__pyx_t_1)) { /* "cpython/datetime.pxd":308 * cdef inline object timezone_new(object offset, object name=None): * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') # <<<<<<<<<<<<<< * return __Pyx_TimeZone_FromOffsetAndName(offset, name if name is not None else NULL) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(2, 308, __pyx_L1_error) /* "cpython/datetime.pxd":307 * # Create timedelta object using DateTime CAPI factory function. * cdef inline object timezone_new(object offset, object name=None): * if PY_VERSION_HEX < 0x030700b1: # <<<<<<<<<<<<<< * raise RuntimeError('Time zones are not available from the C-API.') * return __Pyx_TimeZone_FromOffsetAndName(offset, name if name is not None else NULL) */ } /* "cpython/datetime.pxd":309 * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') * return __Pyx_TimeZone_FromOffsetAndName(offset, name if name is not None else NULL) # <<<<<<<<<<<<<< * * # Create datetime object using DB API constructor. */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = (__pyx_v_name != Py_None); if (__pyx_t_1) { __pyx_t_3 = ((PyObject *)__pyx_v_name); } else { __pyx_t_3 = NULL; } __pyx_t_2 = __Pyx_TimeZone_FromOffsetAndName(__pyx_v_offset, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 309, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "cpython/datetime.pxd":306 * * # Create timedelta object using DateTime CAPI factory function. * cdef inline object timezone_new(object offset, object name=None): # <<<<<<<<<<<<<< * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("cpython.datetime.timezone_new", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":312 * * # Create datetime object using DB API constructor. * cdef inline datetime datetime_from_timestamp(timestamp, tz=None): # <<<<<<<<<<<<<< * return PyDateTimeAPI.DateTime_FromTimestamp( * PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL) */ static CYTHON_INLINE PyDateTime_DateTime *__pyx_f_7cpython_8datetime_datetime_from_timestamp(PyObject *__pyx_v_timestamp, struct __pyx_opt_args_7cpython_8datetime_datetime_from_timestamp *__pyx_optional_args) { PyObject *__pyx_v_tz = ((PyObject *)Py_None); PyDateTime_DateTime *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("datetime_from_timestamp", 1); if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_tz = __pyx_optional_args->tz; } } /* "cpython/datetime.pxd":313 * # Create datetime object using DB API constructor. * cdef inline datetime datetime_from_timestamp(timestamp, tz=None): * return PyDateTimeAPI.DateTime_FromTimestamp( # <<<<<<<<<<<<<< * PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL) * */ __Pyx_XDECREF((PyObject *)__pyx_r); /* "cpython/datetime.pxd":314 * cdef inline datetime datetime_from_timestamp(timestamp, tz=None): * return PyDateTimeAPI.DateTime_FromTimestamp( * PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL) # <<<<<<<<<<<<<< * * # Create date object using DB API constructor. */ __pyx_t_2 = (__pyx_v_tz != Py_None); if (__pyx_t_2) { __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 314, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_timestamp); __Pyx_GIVEREF(__pyx_v_timestamp); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_timestamp)) __PYX_ERR(2, 314, __pyx_L1_error); __Pyx_INCREF(__pyx_v_tz); __Pyx_GIVEREF(__pyx_v_tz); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_tz)) __PYX_ERR(2, 314, __pyx_L1_error); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 314, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_timestamp); __Pyx_GIVEREF(__pyx_v_timestamp); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_timestamp)) __PYX_ERR(2, 314, __pyx_L1_error); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } /* "cpython/datetime.pxd":313 * # Create datetime object using DB API constructor. * cdef inline datetime datetime_from_timestamp(timestamp, tz=None): * return PyDateTimeAPI.DateTime_FromTimestamp( # <<<<<<<<<<<<<< * PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL) * */ __pyx_t_3 = ((PyObject *)PyDateTimeAPI->DateTime_FromTimestamp(((PyObject *)PyDateTimeAPI->DateTimeType), __pyx_t_1, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(2, 313, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = ((PyDateTime_DateTime *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; /* "cpython/datetime.pxd":312 * * # Create datetime object using DB API constructor. * cdef inline datetime datetime_from_timestamp(timestamp, tz=None): # <<<<<<<<<<<<<< * return PyDateTimeAPI.DateTime_FromTimestamp( * PyDateTimeAPI.DateTimeType, (timestamp, tz) if tz is not None else (timestamp,), NULL) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("cpython.datetime.datetime_from_timestamp", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":317 * * # Create date object using DB API constructor. * cdef inline date date_from_timestamp(timestamp): # <<<<<<<<<<<<<< * return PyDateTimeAPI.Date_FromTimestamp(PyDateTimeAPI.DateType, (timestamp,)) * */ static CYTHON_INLINE PyDateTime_Date *__pyx_f_7cpython_8datetime_date_from_timestamp(PyObject *__pyx_v_timestamp) { PyDateTime_Date *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("date_from_timestamp", 1); /* "cpython/datetime.pxd":318 * # Create date object using DB API constructor. * cdef inline date date_from_timestamp(timestamp): * return PyDateTimeAPI.Date_FromTimestamp(PyDateTimeAPI.DateType, (timestamp,)) # <<<<<<<<<<<<<< * * # More recognizable getters for date/time/datetime/timedelta. */ __Pyx_XDECREF((PyObject *)__pyx_r); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_timestamp); __Pyx_GIVEREF(__pyx_v_timestamp); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_timestamp)) __PYX_ERR(2, 318, __pyx_L1_error); __pyx_t_2 = ((PyObject *)PyDateTimeAPI->Date_FromTimestamp(((PyObject *)PyDateTimeAPI->DateType), __pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = ((PyDateTime_Date *)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; /* "cpython/datetime.pxd":317 * * # Create date object using DB API constructor. * cdef inline date date_from_timestamp(timestamp): # <<<<<<<<<<<<<< * return PyDateTimeAPI.Date_FromTimestamp(PyDateTimeAPI.DateType, (timestamp,)) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("cpython.datetime.date_from_timestamp", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":326 * * # Get UTC singleton * cdef inline object get_utc(): # <<<<<<<<<<<<<< * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') */ static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_get_utc(void) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_utc", 1); /* "cpython/datetime.pxd":327 * # Get UTC singleton * cdef inline object get_utc(): * if PY_VERSION_HEX < 0x030700b1: # <<<<<<<<<<<<<< * raise RuntimeError('Time zones are not available from the C-API.') * return __Pyx_TimeZone_UTC */ __pyx_t_1 = (PY_VERSION_HEX < 0x030700b1); if (unlikely(__pyx_t_1)) { /* "cpython/datetime.pxd":328 * cdef inline object get_utc(): * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') # <<<<<<<<<<<<<< * return __Pyx_TimeZone_UTC * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(2, 328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(2, 328, __pyx_L1_error) /* "cpython/datetime.pxd":327 * # Get UTC singleton * cdef inline object get_utc(): * if PY_VERSION_HEX < 0x030700b1: # <<<<<<<<<<<<<< * raise RuntimeError('Time zones are not available from the C-API.') * return __Pyx_TimeZone_UTC */ } /* "cpython/datetime.pxd":329 * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') * return __Pyx_TimeZone_UTC # <<<<<<<<<<<<<< * * # Get tzinfo of time */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(((PyObject *)__Pyx_TimeZone_UTC)); __pyx_r = ((PyObject *)__Pyx_TimeZone_UTC); goto __pyx_L0; /* "cpython/datetime.pxd":326 * * # Get UTC singleton * cdef inline object get_utc(): # <<<<<<<<<<<<<< * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("cpython.datetime.get_utc", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":332 * * # Get tzinfo of time * cdef inline object time_tzinfo(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_TZINFO(o) * */ static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_time_tzinfo(PyObject *__pyx_v_o) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1; __Pyx_RefNannySetupContext("time_tzinfo", 1); /* "cpython/datetime.pxd":333 * # Get tzinfo of time * cdef inline object time_tzinfo(object o): * return PyDateTime_TIME_GET_TZINFO(o) # <<<<<<<<<<<<<< * * # Get tzinfo of datetime */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyDateTime_TIME_GET_TZINFO(__pyx_v_o); __Pyx_INCREF(((PyObject *)__pyx_t_1)); __pyx_r = ((PyObject *)__pyx_t_1); goto __pyx_L0; /* "cpython/datetime.pxd":332 * * # Get tzinfo of time * cdef inline object time_tzinfo(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_TZINFO(o) * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":336 * * # Get tzinfo of datetime * cdef inline object datetime_tzinfo(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_TZINFO(o) * */ static CYTHON_INLINE PyObject *__pyx_f_7cpython_8datetime_datetime_tzinfo(PyObject *__pyx_v_o) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1; __Pyx_RefNannySetupContext("datetime_tzinfo", 1); /* "cpython/datetime.pxd":337 * # Get tzinfo of datetime * cdef inline object datetime_tzinfo(object o): * return PyDateTime_DATE_GET_TZINFO(o) # <<<<<<<<<<<<<< * * # Get year of date */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyDateTime_DATE_GET_TZINFO(__pyx_v_o); __Pyx_INCREF(((PyObject *)__pyx_t_1)); __pyx_r = ((PyObject *)__pyx_t_1); goto __pyx_L0; /* "cpython/datetime.pxd":336 * * # Get tzinfo of datetime * cdef inline object datetime_tzinfo(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_TZINFO(o) * */ /* function exit code */ __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "cpython/datetime.pxd":340 * * # Get year of date * cdef inline int date_year(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_YEAR(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_date_year(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":341 * # Get year of date * cdef inline int date_year(object o): * return PyDateTime_GET_YEAR(o) # <<<<<<<<<<<<<< * * # Get month of date */ __pyx_r = PyDateTime_GET_YEAR(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":340 * * # Get year of date * cdef inline int date_year(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_YEAR(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":344 * * # Get month of date * cdef inline int date_month(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_MONTH(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_date_month(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":345 * # Get month of date * cdef inline int date_month(object o): * return PyDateTime_GET_MONTH(o) # <<<<<<<<<<<<<< * * # Get day of date */ __pyx_r = PyDateTime_GET_MONTH(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":344 * * # Get month of date * cdef inline int date_month(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_MONTH(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":348 * * # Get day of date * cdef inline int date_day(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_DAY(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_date_day(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":349 * # Get day of date * cdef inline int date_day(object o): * return PyDateTime_GET_DAY(o) # <<<<<<<<<<<<<< * * # Get year of datetime */ __pyx_r = PyDateTime_GET_DAY(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":348 * * # Get day of date * cdef inline int date_day(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_DAY(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":352 * * # Get year of datetime * cdef inline int datetime_year(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_YEAR(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_year(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":353 * # Get year of datetime * cdef inline int datetime_year(object o): * return PyDateTime_GET_YEAR(o) # <<<<<<<<<<<<<< * * # Get month of datetime */ __pyx_r = PyDateTime_GET_YEAR(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":352 * * # Get year of datetime * cdef inline int datetime_year(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_YEAR(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":356 * * # Get month of datetime * cdef inline int datetime_month(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_MONTH(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_month(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":357 * # Get month of datetime * cdef inline int datetime_month(object o): * return PyDateTime_GET_MONTH(o) # <<<<<<<<<<<<<< * * # Get day of datetime */ __pyx_r = PyDateTime_GET_MONTH(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":356 * * # Get month of datetime * cdef inline int datetime_month(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_MONTH(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":360 * * # Get day of datetime * cdef inline int datetime_day(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_DAY(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_day(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":361 * # Get day of datetime * cdef inline int datetime_day(object o): * return PyDateTime_GET_DAY(o) # <<<<<<<<<<<<<< * * # Get hour of time */ __pyx_r = PyDateTime_GET_DAY(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":360 * * # Get day of datetime * cdef inline int datetime_day(object o): # <<<<<<<<<<<<<< * return PyDateTime_GET_DAY(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":364 * * # Get hour of time * cdef inline int time_hour(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_HOUR(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_hour(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":365 * # Get hour of time * cdef inline int time_hour(object o): * return PyDateTime_TIME_GET_HOUR(o) # <<<<<<<<<<<<<< * * # Get minute of time */ __pyx_r = PyDateTime_TIME_GET_HOUR(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":364 * * # Get hour of time * cdef inline int time_hour(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_HOUR(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":368 * * # Get minute of time * cdef inline int time_minute(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_MINUTE(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_minute(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":369 * # Get minute of time * cdef inline int time_minute(object o): * return PyDateTime_TIME_GET_MINUTE(o) # <<<<<<<<<<<<<< * * # Get second of time */ __pyx_r = PyDateTime_TIME_GET_MINUTE(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":368 * * # Get minute of time * cdef inline int time_minute(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_MINUTE(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":372 * * # Get second of time * cdef inline int time_second(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_SECOND(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_second(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":373 * # Get second of time * cdef inline int time_second(object o): * return PyDateTime_TIME_GET_SECOND(o) # <<<<<<<<<<<<<< * * # Get microsecond of time */ __pyx_r = PyDateTime_TIME_GET_SECOND(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":372 * * # Get second of time * cdef inline int time_second(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_SECOND(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":376 * * # Get microsecond of time * cdef inline int time_microsecond(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_MICROSECOND(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_microsecond(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":377 * # Get microsecond of time * cdef inline int time_microsecond(object o): * return PyDateTime_TIME_GET_MICROSECOND(o) # <<<<<<<<<<<<<< * * # Get fold of time */ __pyx_r = PyDateTime_TIME_GET_MICROSECOND(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":376 * * # Get microsecond of time * cdef inline int time_microsecond(object o): # <<<<<<<<<<<<<< * return PyDateTime_TIME_GET_MICROSECOND(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":380 * * # Get fold of time * cdef inline int time_fold(object o): # <<<<<<<<<<<<<< * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_TIME_GET_FOLD(o) */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_time_fold(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":382 * cdef inline int time_fold(object o): * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_TIME_GET_FOLD(o) # <<<<<<<<<<<<<< * * # Get hour of datetime */ __pyx_r = PyDateTime_TIME_GET_FOLD(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":380 * * # Get fold of time * cdef inline int time_fold(object o): # <<<<<<<<<<<<<< * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_TIME_GET_FOLD(o) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":385 * * # Get hour of datetime * cdef inline int datetime_hour(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_HOUR(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_hour(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":386 * # Get hour of datetime * cdef inline int datetime_hour(object o): * return PyDateTime_DATE_GET_HOUR(o) # <<<<<<<<<<<<<< * * # Get minute of datetime */ __pyx_r = PyDateTime_DATE_GET_HOUR(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":385 * * # Get hour of datetime * cdef inline int datetime_hour(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_HOUR(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":389 * * # Get minute of datetime * cdef inline int datetime_minute(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_MINUTE(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_minute(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":390 * # Get minute of datetime * cdef inline int datetime_minute(object o): * return PyDateTime_DATE_GET_MINUTE(o) # <<<<<<<<<<<<<< * * # Get second of datetime */ __pyx_r = PyDateTime_DATE_GET_MINUTE(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":389 * * # Get minute of datetime * cdef inline int datetime_minute(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_MINUTE(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":393 * * # Get second of datetime * cdef inline int datetime_second(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_SECOND(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_second(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":394 * # Get second of datetime * cdef inline int datetime_second(object o): * return PyDateTime_DATE_GET_SECOND(o) # <<<<<<<<<<<<<< * * # Get microsecond of datetime */ __pyx_r = PyDateTime_DATE_GET_SECOND(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":393 * * # Get second of datetime * cdef inline int datetime_second(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_SECOND(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":397 * * # Get microsecond of datetime * cdef inline int datetime_microsecond(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_MICROSECOND(o) * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_microsecond(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":398 * # Get microsecond of datetime * cdef inline int datetime_microsecond(object o): * return PyDateTime_DATE_GET_MICROSECOND(o) # <<<<<<<<<<<<<< * * # Get fold of datetime */ __pyx_r = PyDateTime_DATE_GET_MICROSECOND(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":397 * * # Get microsecond of datetime * cdef inline int datetime_microsecond(object o): # <<<<<<<<<<<<<< * return PyDateTime_DATE_GET_MICROSECOND(o) * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":401 * * # Get fold of datetime * cdef inline int datetime_fold(object o): # <<<<<<<<<<<<<< * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_DATE_GET_FOLD(o) */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_datetime_fold(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":403 * cdef inline int datetime_fold(object o): * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_DATE_GET_FOLD(o) # <<<<<<<<<<<<<< * * # Get days of timedelta */ __pyx_r = PyDateTime_DATE_GET_FOLD(__pyx_v_o); goto __pyx_L0; /* "cpython/datetime.pxd":401 * * # Get fold of datetime * cdef inline int datetime_fold(object o): # <<<<<<<<<<<<<< * # For Python < 3.6 this returns 0 no matter what * return PyDateTime_DATE_GET_FOLD(o) */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":406 * * # Get days of timedelta * cdef inline int timedelta_days(object o): # <<<<<<<<<<<<<< * return (o).days * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_timedelta_days(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":407 * # Get days of timedelta * cdef inline int timedelta_days(object o): * return (o).days # <<<<<<<<<<<<<< * * # Get seconds of timedelta */ __pyx_r = ((PyDateTime_Delta *)__pyx_v_o)->days; goto __pyx_L0; /* "cpython/datetime.pxd":406 * * # Get days of timedelta * cdef inline int timedelta_days(object o): # <<<<<<<<<<<<<< * return (o).days * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":410 * * # Get seconds of timedelta * cdef inline int timedelta_seconds(object o): # <<<<<<<<<<<<<< * return (o).seconds * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_timedelta_seconds(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":411 * # Get seconds of timedelta * cdef inline int timedelta_seconds(object o): * return (o).seconds # <<<<<<<<<<<<<< * * # Get microseconds of timedelta */ __pyx_r = ((PyDateTime_Delta *)__pyx_v_o)->seconds; goto __pyx_L0; /* "cpython/datetime.pxd":410 * * # Get seconds of timedelta * cdef inline int timedelta_seconds(object o): # <<<<<<<<<<<<<< * return (o).seconds * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":414 * * # Get microseconds of timedelta * cdef inline int timedelta_microseconds(object o): # <<<<<<<<<<<<<< * return (o).microseconds * */ static CYTHON_INLINE int __pyx_f_7cpython_8datetime_timedelta_microseconds(PyObject *__pyx_v_o) { int __pyx_r; /* "cpython/datetime.pxd":415 * # Get microseconds of timedelta * cdef inline int timedelta_microseconds(object o): * return (o).microseconds # <<<<<<<<<<<<<< * * cdef inline double total_seconds(timedelta obj): */ __pyx_r = ((PyDateTime_Delta *)__pyx_v_o)->microseconds; goto __pyx_L0; /* "cpython/datetime.pxd":414 * * # Get microseconds of timedelta * cdef inline int timedelta_microseconds(object o): # <<<<<<<<<<<<<< * return (o).microseconds * */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "cpython/datetime.pxd":417 * return (o).microseconds * * cdef inline double total_seconds(timedelta obj): # <<<<<<<<<<<<<< * # Mirrors the "timedelta.total_seconds()" method. * # Note that this implementation is not guaranteed to give *exactly* the same */ static CYTHON_INLINE double __pyx_f_7cpython_8datetime_total_seconds(PyDateTime_Delta *__pyx_v_obj) { double __pyx_v_days; double __pyx_v_seconds; double __pyx_v_micros; double __pyx_r; /* "cpython/datetime.pxd":423 * cdef: * double days, seconds, micros * days = PyDateTime_DELTA_GET_DAYS(obj) # <<<<<<<<<<<<<< * seconds = PyDateTime_DELTA_GET_SECONDS(obj) * micros = PyDateTime_DELTA_GET_MICROSECONDS(obj) */ __pyx_v_days = ((double)PyDateTime_DELTA_GET_DAYS(((PyObject *)__pyx_v_obj))); /* "cpython/datetime.pxd":424 * double days, seconds, micros * days = PyDateTime_DELTA_GET_DAYS(obj) * seconds = PyDateTime_DELTA_GET_SECONDS(obj) # <<<<<<<<<<<<<< * micros = PyDateTime_DELTA_GET_MICROSECONDS(obj) * return days * 24 * 3600 + seconds + micros / 1_000_000 */ __pyx_v_seconds = ((double)PyDateTime_DELTA_GET_SECONDS(((PyObject *)__pyx_v_obj))); /* "cpython/datetime.pxd":425 * days = PyDateTime_DELTA_GET_DAYS(obj) * seconds = PyDateTime_DELTA_GET_SECONDS(obj) * micros = PyDateTime_DELTA_GET_MICROSECONDS(obj) # <<<<<<<<<<<<<< * return days * 24 * 3600 + seconds + micros / 1_000_000 */ __pyx_v_micros = ((double)PyDateTime_DELTA_GET_MICROSECONDS(((PyObject *)__pyx_v_obj))); /* "cpython/datetime.pxd":426 * seconds = PyDateTime_DELTA_GET_SECONDS(obj) * micros = PyDateTime_DELTA_GET_MICROSECONDS(obj) * return days * 24 * 3600 + seconds + micros / 1_000_000 # <<<<<<<<<<<<<< */ __pyx_r = ((((__pyx_v_days * 24.0) * 3600.0) + __pyx_v_seconds) + (__pyx_v_micros / 1000000.0)); goto __pyx_L0; /* "cpython/datetime.pxd":417 * return (o).microseconds * * cdef inline double total_seconds(timedelta obj): # <<<<<<<<<<<<<< * # Mirrors the "timedelta.total_seconds()" method. * # Note that this implementation is not guaranteed to give *exactly* the same */ /* function exit code */ __pyx_L0:; return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":81 * """ * * def __cinit__(self): # <<<<<<<<<<<<<< * self.n_obs = 0 * self.n_vars = 0 */ /* Python wrapper */ static int __pyx_pw_10pyreadstat_16_readstat_parser_14data_container_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_10pyreadstat_16_readstat_parser_14data_container_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, __pyx_nargs); return -1;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_VARARGS(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; __pyx_r = __pyx_pf_10pyreadstat_16_readstat_parser_14data_container___cinit__(((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_10pyreadstat_16_readstat_parser_14data_container___cinit__(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 1); /* "pyreadstat/_readstat_parser.pyx":82 * * def __cinit__(self): * self.n_obs = 0 # <<<<<<<<<<<<<< * self.n_vars = 0 * self.max_n_obs = 0 */ __pyx_v_self->n_obs = 0; /* "pyreadstat/_readstat_parser.pyx":83 * def __cinit__(self): * self.n_obs = 0 * self.n_vars = 0 # <<<<<<<<<<<<<< * self.max_n_obs = 0 * self.col_data = list() */ __pyx_v_self->n_vars = 0; /* "pyreadstat/_readstat_parser.pyx":84 * self.n_obs = 0 * self.n_vars = 0 * self.max_n_obs = 0 # <<<<<<<<<<<<<< * self.col_data = list() * self.col_data_len = list() */ __pyx_v_self->max_n_obs = 0; /* "pyreadstat/_readstat_parser.pyx":85 * self.n_vars = 0 * self.max_n_obs = 0 * self.col_data = list() # <<<<<<<<<<<<<< * self.col_data_len = list() * self.col_names = list() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_data); __Pyx_DECREF(__pyx_v_self->col_data); __pyx_v_self->col_data = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":86 * self.max_n_obs = 0 * self.col_data = list() * self.col_data_len = list() # <<<<<<<<<<<<<< * self.col_names = list() * self.col_labels = list() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_data_len); __Pyx_DECREF(__pyx_v_self->col_data_len); __pyx_v_self->col_data_len = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":87 * self.col_data = list() * self.col_data_len = list() * self.col_names = list() # <<<<<<<<<<<<<< * self.col_labels = list() * self.col_dtypes = list() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_names); __Pyx_DECREF(__pyx_v_self->col_names); __pyx_v_self->col_names = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":88 * self.col_data_len = list() * self.col_names = list() * self.col_labels = list() # <<<<<<<<<<<<<< * self.col_dtypes = list() * self.col_numpy_dtypes = list() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_labels); __Pyx_DECREF(__pyx_v_self->col_labels); __pyx_v_self->col_labels = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":89 * self.col_names = list() * self.col_labels = list() * self.col_dtypes = list() # <<<<<<<<<<<<<< * self.col_numpy_dtypes = list() * self.col_dtypes_isobject = list() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_dtypes); __Pyx_DECREF(__pyx_v_self->col_dtypes); __pyx_v_self->col_dtypes = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":90 * self.col_labels = list() * self.col_dtypes = list() * self.col_numpy_dtypes = list() # <<<<<<<<<<<<<< * self.col_dtypes_isobject = list() * self.col_dytpes_isfloat = list() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_numpy_dtypes); __Pyx_DECREF(__pyx_v_self->col_numpy_dtypes); __pyx_v_self->col_numpy_dtypes = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":91 * self.col_dtypes = list() * self.col_numpy_dtypes = list() * self.col_dtypes_isobject = list() # <<<<<<<<<<<<<< * self.col_dytpes_isfloat = list() * self.col_formats = list() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_dtypes_isobject); __Pyx_DECREF(__pyx_v_self->col_dtypes_isobject); __pyx_v_self->col_dtypes_isobject = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":92 * self.col_numpy_dtypes = list() * self.col_dtypes_isobject = list() * self.col_dytpes_isfloat = list() # <<<<<<<<<<<<<< * self.col_formats = list() * self.col_formats_original = list() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_dytpes_isfloat); __Pyx_DECREF(__pyx_v_self->col_dytpes_isfloat); __pyx_v_self->col_dytpes_isfloat = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":93 * self.col_dtypes_isobject = list() * self.col_dytpes_isfloat = list() * self.col_formats = list() # <<<<<<<<<<<<<< * self.col_formats_original = list() * self.origin = None */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_formats); __Pyx_DECREF(__pyx_v_self->col_formats); __pyx_v_self->col_formats = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":94 * self.col_dytpes_isfloat = list() * self.col_formats = list() * self.col_formats_original = list() # <<<<<<<<<<<<<< * self.origin = None * self.is_unkown_number_rows = 0 */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->col_formats_original); __Pyx_DECREF(__pyx_v_self->col_formats_original); __pyx_v_self->col_formats_original = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":95 * self.col_formats = list() * self.col_formats_original = list() * self.origin = None # <<<<<<<<<<<<<< * self.is_unkown_number_rows = 0 * self.file_encoding = None */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->origin); __Pyx_DECREF(__pyx_v_self->origin); __pyx_v_self->origin = Py_None; /* "pyreadstat/_readstat_parser.pyx":96 * self.col_formats_original = list() * self.origin = None * self.is_unkown_number_rows = 0 # <<<<<<<<<<<<<< * self.file_encoding = None * self.file_label = None */ __pyx_v_self->is_unkown_number_rows = 0; /* "pyreadstat/_readstat_parser.pyx":97 * self.origin = None * self.is_unkown_number_rows = 0 * self.file_encoding = None # <<<<<<<<<<<<<< * self.file_label = None * self.metaonly = 0 */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->file_encoding); __Pyx_DECREF(__pyx_v_self->file_encoding); __pyx_v_self->file_encoding = ((PyObject*)Py_None); /* "pyreadstat/_readstat_parser.pyx":98 * self.is_unkown_number_rows = 0 * self.file_encoding = None * self.file_label = None # <<<<<<<<<<<<<< * self.metaonly = 0 * self.dates_as_pandas = 0 */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->file_label); __Pyx_DECREF(__pyx_v_self->file_label); __pyx_v_self->file_label = ((PyObject*)Py_None); /* "pyreadstat/_readstat_parser.pyx":99 * self.file_encoding = None * self.file_label = None * self.metaonly = 0 # <<<<<<<<<<<<<< * self.dates_as_pandas = 0 * self.label_to_var_name = dict() */ __pyx_v_self->metaonly = 0; /* "pyreadstat/_readstat_parser.pyx":100 * self.file_label = None * self.metaonly = 0 * self.dates_as_pandas = 0 # <<<<<<<<<<<<<< * self.label_to_var_name = dict() * self.labels_raw = dict() */ __pyx_v_self->dates_as_pandas = 0; /* "pyreadstat/_readstat_parser.pyx":101 * self.metaonly = 0 * self.dates_as_pandas = 0 * self.label_to_var_name = dict() # <<<<<<<<<<<<<< * self.labels_raw = dict() * self.notes = list() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->label_to_var_name); __Pyx_DECREF(__pyx_v_self->label_to_var_name); __pyx_v_self->label_to_var_name = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":102 * self.dates_as_pandas = 0 * self.label_to_var_name = dict() * self.labels_raw = dict() # <<<<<<<<<<<<<< * self.notes = list() * self.user_encoding = None */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->labels_raw); __Pyx_DECREF(__pyx_v_self->labels_raw); __pyx_v_self->labels_raw = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":103 * self.label_to_var_name = dict() * self.labels_raw = dict() * self.notes = list() # <<<<<<<<<<<<<< * self.user_encoding = None * self.table_name = None */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->notes); __Pyx_DECREF(__pyx_v_self->notes); __pyx_v_self->notes = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":104 * self.labels_raw = dict() * self.notes = list() * self.user_encoding = None # <<<<<<<<<<<<<< * self.table_name = None * self.filter_cols = 0 */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->user_encoding); __Pyx_DECREF(__pyx_v_self->user_encoding); __pyx_v_self->user_encoding = ((PyObject*)Py_None); /* "pyreadstat/_readstat_parser.pyx":105 * self.notes = list() * self.user_encoding = None * self.table_name = None # <<<<<<<<<<<<<< * self.filter_cols = 0 * self.use_cols = list() */ __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->table_name); __Pyx_DECREF(__pyx_v_self->table_name); __pyx_v_self->table_name = ((PyObject*)Py_None); /* "pyreadstat/_readstat_parser.pyx":106 * self.user_encoding = None * self.table_name = None * self.filter_cols = 0 # <<<<<<<<<<<<<< * self.use_cols = list() * self.usernan = 0 */ __pyx_v_self->filter_cols = 0; /* "pyreadstat/_readstat_parser.pyx":107 * self.table_name = None * self.filter_cols = 0 * self.use_cols = list() # <<<<<<<<<<<<<< * self.usernan = 0 * self.missing_ranges = dict() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->use_cols); __Pyx_DECREF(__pyx_v_self->use_cols); __pyx_v_self->use_cols = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":108 * self.filter_cols = 0 * self.use_cols = list() * self.usernan = 0 # <<<<<<<<<<<<<< * self.missing_ranges = dict() * self.missing_user_values = dict() */ __pyx_v_self->usernan = 0; /* "pyreadstat/_readstat_parser.pyx":109 * self.use_cols = list() * self.usernan = 0 * self.missing_ranges = dict() # <<<<<<<<<<<<<< * self.missing_user_values = dict() * self.variable_storage_width = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->missing_ranges); __Pyx_DECREF(__pyx_v_self->missing_ranges); __pyx_v_self->missing_ranges = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":110 * self.usernan = 0 * self.missing_ranges = dict() * self.missing_user_values = dict() # <<<<<<<<<<<<<< * self.variable_storage_width = dict() * self.variable_display_width = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->missing_user_values); __Pyx_DECREF(__pyx_v_self->missing_user_values); __pyx_v_self->missing_user_values = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":111 * self.missing_ranges = dict() * self.missing_user_values = dict() * self.variable_storage_width = dict() # <<<<<<<<<<<<<< * self.variable_display_width = dict() * self.variable_alignment = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->variable_storage_width); __Pyx_DECREF(__pyx_v_self->variable_storage_width); __pyx_v_self->variable_storage_width = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":112 * self.missing_user_values = dict() * self.variable_storage_width = dict() * self.variable_display_width = dict() # <<<<<<<<<<<<<< * self.variable_alignment = dict() * self.variable_measure = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->variable_display_width); __Pyx_DECREF(__pyx_v_self->variable_display_width); __pyx_v_self->variable_display_width = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":113 * self.variable_storage_width = dict() * self.variable_display_width = dict() * self.variable_alignment = dict() # <<<<<<<<<<<<<< * self.variable_measure = dict() * self.no_datetime_conversion = 0 */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->variable_alignment); __Pyx_DECREF(__pyx_v_self->variable_alignment); __pyx_v_self->variable_alignment = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":114 * self.variable_display_width = dict() * self.variable_alignment = dict() * self.variable_measure = dict() # <<<<<<<<<<<<<< * self.no_datetime_conversion = 0 * self.ctime = 0 */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->variable_measure); __Pyx_DECREF(__pyx_v_self->variable_measure); __pyx_v_self->variable_measure = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":115 * self.variable_alignment = dict() * self.variable_measure = dict() * self.no_datetime_conversion = 0 # <<<<<<<<<<<<<< * self.ctime = 0 * self.mtime = 0 */ __pyx_v_self->no_datetime_conversion = 0; /* "pyreadstat/_readstat_parser.pyx":116 * self.variable_measure = dict() * self.no_datetime_conversion = 0 * self.ctime = 0 # <<<<<<<<<<<<<< * self.mtime = 0 * */ __pyx_v_self->ctime = 0; /* "pyreadstat/_readstat_parser.pyx":117 * self.no_datetime_conversion = 0 * self.ctime = 0 * self.mtime = 0 # <<<<<<<<<<<<<< * * class metadata_container: */ __pyx_v_self->mtime = 0; /* "pyreadstat/_readstat_parser.pyx":81 * """ * * def __cinit__(self): # <<<<<<<<<<<<<< * self.n_obs = 0 * self.n_vars = 0 */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("pyreadstat._readstat_parser.data_container.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_3__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_10pyreadstat_16_readstat_parser_14data_container_3__reduce_cython__ = {"__reduce_cython__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_3__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_3__reduce_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__reduce_cython__", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__reduce_cython__", 0))) return NULL; __pyx_r = __pyx_pf_10pyreadstat_16_readstat_parser_14data_container_2__reduce_cython__(((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_16_readstat_parser_14data_container_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__reduce_cython__", 1); /* "(tree fragment)":2 * def __reduce_cython__(self): * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" # <<<<<<<<<<<<<< * def __setstate_cython__(self, __pyx_state): * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" */ __Pyx_Raise(__pyx_builtin_TypeError, __pyx_kp_s_no_default___reduce___due_to_non, 0, 0); __PYX_ERR(1, 2, __pyx_L1_error) /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("pyreadstat._readstat_parser.data_container.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_5__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_10pyreadstat_16_readstat_parser_14data_container_5__setstate_cython__ = {"__setstate_cython__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_5__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_5__setstate_cython__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { CYTHON_UNUSED PyObject *__pyx_v___pyx_state = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_state,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pyx_state)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 3, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__setstate_cython__") < 0)) __PYX_ERR(1, 3, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v___pyx_state = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__setstate_cython__", 1, 1, 1, __pyx_nargs); __PYX_ERR(1, 3, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat._readstat_parser.data_container.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10pyreadstat_16_readstat_parser_14data_container_4__setstate_cython__(((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_v_self), __pyx_v___pyx_state); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_16_readstat_parser_14data_container_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setstate_cython__", 1); /* "(tree fragment)":4 * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" # <<<<<<<<<<<<<< */ __Pyx_Raise(__pyx_builtin_TypeError, __pyx_kp_s_no_default___reduce___due_to_non, 0, 0); __PYX_ERR(1, 4, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("pyreadstat._readstat_parser.data_container.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":123 * This class holds metadata we want to give back to python * """ * def __init__(self): # <<<<<<<<<<<<<< * self.column_names = list() * self.column_labels = list() */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_16_readstat_parser_18metadata_container_1__init__(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_10pyreadstat_16_readstat_parser_18metadata_container_1__init__ = {"__init__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_16_readstat_parser_18metadata_container_1__init__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_10pyreadstat_16_readstat_parser_18metadata_container_1__init__(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_self = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[1] = {0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_self)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 123, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__init__") < 0)) __PYX_ERR(0, 123, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_self = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 123, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat._readstat_parser.metadata_container.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10pyreadstat_16_readstat_parser_18metadata_container___init__(__pyx_self, __pyx_v_self); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_16_readstat_parser_18metadata_container___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 1); /* "pyreadstat/_readstat_parser.pyx":124 * """ * def __init__(self): * self.column_names = list() # <<<<<<<<<<<<<< * self.column_labels = list() * self.column_names_to_labels = dict() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_column_names, __pyx_t_1) < 0) __PYX_ERR(0, 124, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":125 * def __init__(self): * self.column_names = list() * self.column_labels = list() # <<<<<<<<<<<<<< * self.column_names_to_labels = dict() * self.file_encoding = None */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_column_labels, __pyx_t_1) < 0) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":126 * self.column_names = list() * self.column_labels = list() * self.column_names_to_labels = dict() # <<<<<<<<<<<<<< * self.file_encoding = None * self.number_columns = None */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_column_names_to_labels, __pyx_t_1) < 0) __PYX_ERR(0, 126, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":127 * self.column_labels = list() * self.column_names_to_labels = dict() * self.file_encoding = None # <<<<<<<<<<<<<< * self.number_columns = None * self.number_rows = None */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_file_encoding, Py_None) < 0) __PYX_ERR(0, 127, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":128 * self.column_names_to_labels = dict() * self.file_encoding = None * self.number_columns = None # <<<<<<<<<<<<<< * self.number_rows = None * self.variable_value_labels = dict() */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_number_columns, Py_None) < 0) __PYX_ERR(0, 128, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":129 * self.file_encoding = None * self.number_columns = None * self.number_rows = None # <<<<<<<<<<<<<< * self.variable_value_labels = dict() * self.value_labels = dict() */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_number_rows, Py_None) < 0) __PYX_ERR(0, 129, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":130 * self.number_columns = None * self.number_rows = None * self.variable_value_labels = dict() # <<<<<<<<<<<<<< * self.value_labels = dict() * self.variable_to_label = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_variable_value_labels, __pyx_t_1) < 0) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":131 * self.number_rows = None * self.variable_value_labels = dict() * self.value_labels = dict() # <<<<<<<<<<<<<< * self.variable_to_label = dict() * self.notes = list() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_value_labels, __pyx_t_1) < 0) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":132 * self.variable_value_labels = dict() * self.value_labels = dict() * self.variable_to_label = dict() # <<<<<<<<<<<<<< * self.notes = list() * self.original_variable_types = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_variable_to_label, __pyx_t_1) < 0) __PYX_ERR(0, 132, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":133 * self.value_labels = dict() * self.variable_to_label = dict() * self.notes = list() # <<<<<<<<<<<<<< * self.original_variable_types = dict() * self.readstat_variable_types = dict() */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_notes, __pyx_t_1) < 0) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":134 * self.variable_to_label = dict() * self.notes = list() * self.original_variable_types = dict() # <<<<<<<<<<<<<< * self.readstat_variable_types = dict() * self.table_name = None */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_original_variable_types, __pyx_t_1) < 0) __PYX_ERR(0, 134, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":135 * self.notes = list() * self.original_variable_types = dict() * self.readstat_variable_types = dict() # <<<<<<<<<<<<<< * self.table_name = None * self.missing_ranges = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_readstat_variable_types, __pyx_t_1) < 0) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":136 * self.original_variable_types = dict() * self.readstat_variable_types = dict() * self.table_name = None # <<<<<<<<<<<<<< * self.missing_ranges = dict() * self.missing_user_values = dict() */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_table_name, Py_None) < 0) __PYX_ERR(0, 136, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":137 * self.readstat_variable_types = dict() * self.table_name = None * self.missing_ranges = dict() # <<<<<<<<<<<<<< * self.missing_user_values = dict() * self.variable_storage_width = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_missing_ranges, __pyx_t_1) < 0) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":138 * self.table_name = None * self.missing_ranges = dict() * self.missing_user_values = dict() # <<<<<<<<<<<<<< * self.variable_storage_width = dict() * self.variable_display_width = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_missing_user_values, __pyx_t_1) < 0) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":139 * self.missing_ranges = dict() * self.missing_user_values = dict() * self.variable_storage_width = dict() # <<<<<<<<<<<<<< * self.variable_display_width = dict() * self.variable_alignment = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_variable_storage_width, __pyx_t_1) < 0) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":140 * self.missing_user_values = dict() * self.variable_storage_width = dict() * self.variable_display_width = dict() # <<<<<<<<<<<<<< * self.variable_alignment = dict() * self.variable_measure = dict() */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_variable_display_width, __pyx_t_1) < 0) __PYX_ERR(0, 140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":141 * self.variable_storage_width = dict() * self.variable_display_width = dict() * self.variable_alignment = dict() # <<<<<<<<<<<<<< * self.variable_measure = dict() * self.creation_time = None */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_variable_alignment, __pyx_t_1) < 0) __PYX_ERR(0, 141, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":142 * self.variable_display_width = dict() * self.variable_alignment = dict() * self.variable_measure = dict() # <<<<<<<<<<<<<< * self.creation_time = None * self.modification_time = None */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_variable_measure, __pyx_t_1) < 0) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":143 * self.variable_alignment = dict() * self.variable_measure = dict() * self.creation_time = None # <<<<<<<<<<<<<< * self.modification_time = None * */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_creation_time, Py_None) < 0) __PYX_ERR(0, 143, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":144 * self.variable_measure = dict() * self.creation_time = None * self.modification_time = None # <<<<<<<<<<<<<< * * */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_modification_time, Py_None) < 0) __PYX_ERR(0, 144, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":123 * This class holds metadata we want to give back to python * """ * def __init__(self): # <<<<<<<<<<<<<< * self.column_names = list() * self.column_labels = list() */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("pyreadstat._readstat_parser.metadata_container.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":160 * * * cdef py_datetime_format transform_variable_format(str var_format, py_file_format file_format): # <<<<<<<<<<<<<< * """ * Transforms a readstat var_format to a date, datetime or time format label */ static __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_f_10pyreadstat_16_readstat_parser_transform_variable_format(PyObject *__pyx_v_var_format, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format) { __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_r; int __pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* "pyreadstat/_readstat_parser.pyx":164 * Transforms a readstat var_format to a date, datetime or time format label * """ * if file_format == FILE_FORMAT_SAS: # <<<<<<<<<<<<<< * if var_format in sas_all_formats: * if var_format in sas_date_formats: */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS: /* "pyreadstat/_readstat_parser.pyx":165 * """ * if file_format == FILE_FORMAT_SAS: * if var_format in sas_all_formats: # <<<<<<<<<<<<<< * if var_format in sas_date_formats: * return DATE_FORMAT_DATE */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_sas_all_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 165, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":166 * if file_format == FILE_FORMAT_SAS: * if var_format in sas_all_formats: * if var_format in sas_date_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATE * elif var_format in sas_datetime_formats: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 166, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":167 * if var_format in sas_all_formats: * if var_format in sas_date_formats: * return DATE_FORMAT_DATE # <<<<<<<<<<<<<< * elif var_format in sas_datetime_formats: * return DATE_FORMAT_DATETIME */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATE; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":166 * if file_format == FILE_FORMAT_SAS: * if var_format in sas_all_formats: * if var_format in sas_date_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATE * elif var_format in sas_datetime_formats: */ } /* "pyreadstat/_readstat_parser.pyx":168 * if var_format in sas_date_formats: * return DATE_FORMAT_DATE * elif var_format in sas_datetime_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATETIME * elif var_format in sas_time_formats: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 168, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":169 * return DATE_FORMAT_DATE * elif var_format in sas_datetime_formats: * return DATE_FORMAT_DATETIME # <<<<<<<<<<<<<< * elif var_format in sas_time_formats: * return DATE_FORMAT_TIME */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATETIME; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":168 * if var_format in sas_date_formats: * return DATE_FORMAT_DATE * elif var_format in sas_datetime_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATETIME * elif var_format in sas_time_formats: */ } /* "pyreadstat/_readstat_parser.pyx":170 * elif var_format in sas_datetime_formats: * return DATE_FORMAT_DATETIME * elif var_format in sas_time_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_TIME * else: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 170, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":171 * return DATE_FORMAT_DATETIME * elif var_format in sas_time_formats: * return DATE_FORMAT_TIME # <<<<<<<<<<<<<< * else: * return DATE_FORMAT_NOTADATE */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_TIME; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":170 * elif var_format in sas_datetime_formats: * return DATE_FORMAT_DATETIME * elif var_format in sas_time_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_TIME * else: */ } /* "pyreadstat/_readstat_parser.pyx":165 * """ * if file_format == FILE_FORMAT_SAS: * if var_format in sas_all_formats: # <<<<<<<<<<<<<< * if var_format in sas_date_formats: * return DATE_FORMAT_DATE */ goto __pyx_L3; } /* "pyreadstat/_readstat_parser.pyx":173 * return DATE_FORMAT_TIME * else: * return DATE_FORMAT_NOTADATE # <<<<<<<<<<<<<< * * elif file_format == FILE_FORMAT_SPSS: */ /*else*/ { __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE; goto __pyx_L0; } __pyx_L3:; /* "pyreadstat/_readstat_parser.pyx":164 * Transforms a readstat var_format to a date, datetime or time format label * """ * if file_format == FILE_FORMAT_SAS: # <<<<<<<<<<<<<< * if var_format in sas_all_formats: * if var_format in sas_date_formats: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS: /* "pyreadstat/_readstat_parser.pyx":176 * * elif file_format == FILE_FORMAT_SPSS: * if var_format in spss_all_formats: # <<<<<<<<<<<<<< * if var_format in spss_date_formats: * return DATE_FORMAT_DATE */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_spss_all_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 176, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":177 * elif file_format == FILE_FORMAT_SPSS: * if var_format in spss_all_formats: * if var_format in spss_date_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATE * elif var_format in spss_datetime_formats: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 177, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":178 * if var_format in spss_all_formats: * if var_format in spss_date_formats: * return DATE_FORMAT_DATE # <<<<<<<<<<<<<< * elif var_format in spss_datetime_formats: * return DATE_FORMAT_DATETIME */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATE; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":177 * elif file_format == FILE_FORMAT_SPSS: * if var_format in spss_all_formats: * if var_format in spss_date_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATE * elif var_format in spss_datetime_formats: */ } /* "pyreadstat/_readstat_parser.pyx":179 * if var_format in spss_date_formats: * return DATE_FORMAT_DATE * elif var_format in spss_datetime_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATETIME * elif var_format in spss_time_formats: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 179, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":180 * return DATE_FORMAT_DATE * elif var_format in spss_datetime_formats: * return DATE_FORMAT_DATETIME # <<<<<<<<<<<<<< * elif var_format in spss_time_formats: * return DATE_FORMAT_TIME */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATETIME; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":179 * if var_format in spss_date_formats: * return DATE_FORMAT_DATE * elif var_format in spss_datetime_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATETIME * elif var_format in spss_time_formats: */ } /* "pyreadstat/_readstat_parser.pyx":181 * elif var_format in spss_datetime_formats: * return DATE_FORMAT_DATETIME * elif var_format in spss_time_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_TIME * else: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 181, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":182 * return DATE_FORMAT_DATETIME * elif var_format in spss_time_formats: * return DATE_FORMAT_TIME # <<<<<<<<<<<<<< * else: * return DATE_FORMAT_NOTADATE */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_TIME; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":181 * elif var_format in spss_datetime_formats: * return DATE_FORMAT_DATETIME * elif var_format in spss_time_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_TIME * else: */ } /* "pyreadstat/_readstat_parser.pyx":176 * * elif file_format == FILE_FORMAT_SPSS: * if var_format in spss_all_formats: # <<<<<<<<<<<<<< * if var_format in spss_date_formats: * return DATE_FORMAT_DATE */ goto __pyx_L5; } /* "pyreadstat/_readstat_parser.pyx":184 * return DATE_FORMAT_TIME * else: * return DATE_FORMAT_NOTADATE # <<<<<<<<<<<<<< * * elif file_format == FILE_FORMAT_STATA: */ /*else*/ { __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE; goto __pyx_L0; } __pyx_L5:; /* "pyreadstat/_readstat_parser.pyx":175 * return DATE_FORMAT_NOTADATE * * elif file_format == FILE_FORMAT_SPSS: # <<<<<<<<<<<<<< * if var_format in spss_all_formats: * if var_format in spss_date_formats: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA: /* "pyreadstat/_readstat_parser.pyx":187 * * elif file_format == FILE_FORMAT_STATA: * if var_format in stata_all_formats: # <<<<<<<<<<<<<< * if var_format in stata_date_formats: * return DATE_FORMAT_DATE */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_stata_all_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 187, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":188 * elif file_format == FILE_FORMAT_STATA: * if var_format in stata_all_formats: * if var_format in stata_date_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATE * elif var_format in stata_datetime_formats: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 188, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":189 * if var_format in stata_all_formats: * if var_format in stata_date_formats: * return DATE_FORMAT_DATE # <<<<<<<<<<<<<< * elif var_format in stata_datetime_formats: * return DATE_FORMAT_DATETIME */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATE; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":188 * elif file_format == FILE_FORMAT_STATA: * if var_format in stata_all_formats: * if var_format in stata_date_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATE * elif var_format in stata_datetime_formats: */ } /* "pyreadstat/_readstat_parser.pyx":190 * if var_format in stata_date_formats: * return DATE_FORMAT_DATE * elif var_format in stata_datetime_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATETIME * elif var_format in stata_time_formats: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 190, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":191 * return DATE_FORMAT_DATE * elif var_format in stata_datetime_formats: * return DATE_FORMAT_DATETIME # <<<<<<<<<<<<<< * elif var_format in stata_time_formats: * return DATE_FORMAT_TIME */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATETIME; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":190 * if var_format in stata_date_formats: * return DATE_FORMAT_DATE * elif var_format in stata_datetime_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_DATETIME * elif var_format in stata_time_formats: */ } /* "pyreadstat/_readstat_parser.pyx":192 * elif var_format in stata_datetime_formats: * return DATE_FORMAT_DATETIME * elif var_format in stata_time_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_TIME * else: */ __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_var_format, __pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 192, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":193 * return DATE_FORMAT_DATETIME * elif var_format in stata_time_formats: * return DATE_FORMAT_TIME # <<<<<<<<<<<<<< * else: * return DATE_FORMAT_NOTADATE */ __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_TIME; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":192 * elif var_format in stata_datetime_formats: * return DATE_FORMAT_DATETIME * elif var_format in stata_time_formats: # <<<<<<<<<<<<<< * return DATE_FORMAT_TIME * else: */ } /* "pyreadstat/_readstat_parser.pyx":187 * * elif file_format == FILE_FORMAT_STATA: * if var_format in stata_all_formats: # <<<<<<<<<<<<<< * if var_format in stata_date_formats: * return DATE_FORMAT_DATE */ goto __pyx_L7; } /* "pyreadstat/_readstat_parser.pyx":195 * return DATE_FORMAT_TIME * else: * return DATE_FORMAT_NOTADATE # <<<<<<<<<<<<<< * * cdef object transform_datetime(py_datetime_format var_format, double tstamp, py_file_format file_format, object origin, bint dates_as_pandas): */ /*else*/ { __pyx_r = __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE; goto __pyx_L0; } __pyx_L7:; /* "pyreadstat/_readstat_parser.pyx":186 * return DATE_FORMAT_NOTADATE * * elif file_format == FILE_FORMAT_STATA: # <<<<<<<<<<<<<< * if var_format in stata_all_formats: * if var_format in stata_date_formats: */ break; default: break; } /* "pyreadstat/_readstat_parser.pyx":160 * * * cdef py_datetime_format transform_variable_format(str var_format, py_file_format file_format): # <<<<<<<<<<<<<< * """ * Transforms a readstat var_format to a date, datetime or time format label */ /* function exit code */ __pyx_r = (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("pyreadstat._readstat_parser.transform_variable_format", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) 0; __pyx_L0:; return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":197 * return DATE_FORMAT_NOTADATE * * cdef object transform_datetime(py_datetime_format var_format, double tstamp, py_file_format file_format, object origin, bint dates_as_pandas): # <<<<<<<<<<<<<< * """ * Transforms a tstamp integer value to a date, time or datetime pyton object. */ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_transform_datetime(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_v_var_format, double __pyx_v_tstamp, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format, PyObject *__pyx_v_origin, int __pyx_v_dates_as_pandas) { PyObject *__pyx_v_tdelta = 0; int __pyx_v_days; int __pyx_v_secs; double __pyx_v_msecs; int __pyx_v_usecs; PyObject *__pyx_v_mydat = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("transform_datetime", 1); /* "pyreadstat/_readstat_parser.pyx":210 * cdef object mydat * * if var_format == DATE_FORMAT_DATE: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SPSS: * # tstamp is in seconds */ switch (__pyx_v_var_format) { case __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATE: /* "pyreadstat/_readstat_parser.pyx":211 * * if var_format == DATE_FORMAT_DATE: * if file_format == FILE_FORMAT_SPSS: # <<<<<<<<<<<<<< * # tstamp is in seconds * days = (floor(tstamp / 86400)) */ __pyx_t_1 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS); if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":213 * if file_format == FILE_FORMAT_SPSS: * # tstamp is in seconds * days = (floor(tstamp / 86400)) # <<<<<<<<<<<<<< * secs = (tstamp % 86400) * tdelta = timedelta_new(days, secs, 0) */ __pyx_v_days = ((int)floor((__pyx_v_tstamp / 86400.0))); /* "pyreadstat/_readstat_parser.pyx":214 * # tstamp is in seconds * days = (floor(tstamp / 86400)) * secs = (tstamp % 86400) # <<<<<<<<<<<<<< * tdelta = timedelta_new(days, secs, 0) * #tdelta = timedelta(seconds=tstamp) */ __pyx_v_secs = ((int)__Pyx_mod_double(__pyx_v_tstamp, 86400.0)); /* "pyreadstat/_readstat_parser.pyx":215 * days = (floor(tstamp / 86400)) * secs = (tstamp % 86400) * tdelta = timedelta_new(days, secs, 0) # <<<<<<<<<<<<<< * #tdelta = timedelta(seconds=tstamp) * else: */ __pyx_t_2 = ((PyObject *)__pyx_f_7cpython_8datetime_timedelta_new(__pyx_v_days, __pyx_v_secs, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_tdelta = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":211 * * if var_format == DATE_FORMAT_DATE: * if file_format == FILE_FORMAT_SPSS: # <<<<<<<<<<<<<< * # tstamp is in seconds * days = (floor(tstamp / 86400)) */ goto __pyx_L3; } /* "pyreadstat/_readstat_parser.pyx":219 * else: * # tstamp is in days * days = tstamp # <<<<<<<<<<<<<< * tdelta = timedelta_new(days, 0, 0) * #tdelta = timedelta(days=tstamp) */ /*else*/ { __pyx_v_days = ((int)__pyx_v_tstamp); /* "pyreadstat/_readstat_parser.pyx":220 * # tstamp is in days * days = tstamp * tdelta = timedelta_new(days, 0, 0) # <<<<<<<<<<<<<< * #tdelta = timedelta(days=tstamp) * mydat = origin + tdelta */ __pyx_t_2 = ((PyObject *)__pyx_f_7cpython_8datetime_timedelta_new(__pyx_v_days, 0, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_tdelta = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L3:; /* "pyreadstat/_readstat_parser.pyx":222 * tdelta = timedelta_new(days, 0, 0) * #tdelta = timedelta(days=tstamp) * mydat = origin + tdelta # <<<<<<<<<<<<<< * if dates_as_pandas: * return mydat */ __pyx_t_2 = PyNumber_Add(__pyx_v_origin, __pyx_v_tdelta); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_mydat = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":223 * #tdelta = timedelta(days=tstamp) * mydat = origin + tdelta * if dates_as_pandas: # <<<<<<<<<<<<<< * return mydat * else: */ if (__pyx_v_dates_as_pandas) { /* "pyreadstat/_readstat_parser.pyx":224 * mydat = origin + tdelta * if dates_as_pandas: * return mydat # <<<<<<<<<<<<<< * else: * return mydat.date() */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_mydat); __pyx_r = __pyx_v_mydat; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":223 * #tdelta = timedelta(days=tstamp) * mydat = origin + tdelta * if dates_as_pandas: # <<<<<<<<<<<<<< * return mydat * else: */ } /* "pyreadstat/_readstat_parser.pyx":226 * return mydat * else: * return mydat.date() # <<<<<<<<<<<<<< * elif var_format == DATE_FORMAT_DATETIME: * if file_format == FILE_FORMAT_STATA: */ /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_mydat, __pyx_n_s_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } /* "pyreadstat/_readstat_parser.pyx":210 * cdef object mydat * * if var_format == DATE_FORMAT_DATE: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SPSS: * # tstamp is in seconds */ break; case __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATETIME: /* "pyreadstat/_readstat_parser.pyx":228 * return mydat.date() * elif var_format == DATE_FORMAT_DATETIME: * if file_format == FILE_FORMAT_STATA: # <<<<<<<<<<<<<< * # tstamp is in millisecons * days = (floor(tstamp / 86400000)) */ __pyx_t_1 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA); if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":230 * if file_format == FILE_FORMAT_STATA: * # tstamp is in millisecons * days = (floor(tstamp / 86400000)) # <<<<<<<<<<<<<< * msecs = tstamp % 86400000 * secs = (msecs/1000) */ __pyx_v_days = ((int)floor((__pyx_v_tstamp / 86400000.0))); /* "pyreadstat/_readstat_parser.pyx":231 * # tstamp is in millisecons * days = (floor(tstamp / 86400000)) * msecs = tstamp % 86400000 # <<<<<<<<<<<<<< * secs = (msecs/1000) * usecs = ((msecs % 1000) * 1000 ) */ __pyx_v_msecs = __Pyx_mod_double(__pyx_v_tstamp, 86400000.0); /* "pyreadstat/_readstat_parser.pyx":232 * days = (floor(tstamp / 86400000)) * msecs = tstamp % 86400000 * secs = (msecs/1000) # <<<<<<<<<<<<<< * usecs = ((msecs % 1000) * 1000 ) * tdelta = timedelta_new(days, secs, usecs) */ __pyx_v_secs = ((int)(__pyx_v_msecs / 1000.0)); /* "pyreadstat/_readstat_parser.pyx":233 * msecs = tstamp % 86400000 * secs = (msecs/1000) * usecs = ((msecs % 1000) * 1000 ) # <<<<<<<<<<<<<< * tdelta = timedelta_new(days, secs, usecs) * #tdelta = timedelta(milliseconds=tstamp) */ __pyx_v_usecs = ((int)(__Pyx_mod_double(__pyx_v_msecs, 1000.0) * 1000.0)); /* "pyreadstat/_readstat_parser.pyx":234 * secs = (msecs/1000) * usecs = ((msecs % 1000) * 1000 ) * tdelta = timedelta_new(days, secs, usecs) # <<<<<<<<<<<<<< * #tdelta = timedelta(milliseconds=tstamp) * else: */ __pyx_t_2 = ((PyObject *)__pyx_f_7cpython_8datetime_timedelta_new(__pyx_v_days, __pyx_v_secs, __pyx_v_usecs)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_tdelta = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":228 * return mydat.date() * elif var_format == DATE_FORMAT_DATETIME: * if file_format == FILE_FORMAT_STATA: # <<<<<<<<<<<<<< * # tstamp is in millisecons * days = (floor(tstamp / 86400000)) */ goto __pyx_L5; } /* "pyreadstat/_readstat_parser.pyx":238 * else: * # tstamp in seconds * days = (floor(tstamp / 86400)) # <<<<<<<<<<<<<< * secs = (tstamp % 86400) * tdelta = timedelta_new(days, secs, 0) */ /*else*/ { __pyx_v_days = ((int)floor((__pyx_v_tstamp / 86400.0))); /* "pyreadstat/_readstat_parser.pyx":239 * # tstamp in seconds * days = (floor(tstamp / 86400)) * secs = (tstamp % 86400) # <<<<<<<<<<<<<< * tdelta = timedelta_new(days, secs, 0) * #tdelta = timedelta(seconds=tstamp) */ __pyx_v_secs = ((int)__Pyx_mod_double(__pyx_v_tstamp, 86400.0)); /* "pyreadstat/_readstat_parser.pyx":240 * days = (floor(tstamp / 86400)) * secs = (tstamp % 86400) * tdelta = timedelta_new(days, secs, 0) # <<<<<<<<<<<<<< * #tdelta = timedelta(seconds=tstamp) * mydat = origin + tdelta */ __pyx_t_2 = ((PyObject *)__pyx_f_7cpython_8datetime_timedelta_new(__pyx_v_days, __pyx_v_secs, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_tdelta = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L5:; /* "pyreadstat/_readstat_parser.pyx":242 * tdelta = timedelta_new(days, secs, 0) * #tdelta = timedelta(seconds=tstamp) * mydat = origin + tdelta # <<<<<<<<<<<<<< * return mydat * elif var_format == DATE_FORMAT_TIME: */ __pyx_t_2 = PyNumber_Add(__pyx_v_origin, __pyx_v_tdelta); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_mydat = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":243 * #tdelta = timedelta(seconds=tstamp) * mydat = origin + tdelta * return mydat # <<<<<<<<<<<<<< * elif var_format == DATE_FORMAT_TIME: * if file_format == FILE_FORMAT_STATA: */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_mydat); __pyx_r = __pyx_v_mydat; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":227 * else: * return mydat.date() * elif var_format == DATE_FORMAT_DATETIME: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_STATA: * # tstamp is in millisecons */ break; case __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_TIME: /* "pyreadstat/_readstat_parser.pyx":245 * return mydat * elif var_format == DATE_FORMAT_TIME: * if file_format == FILE_FORMAT_STATA: # <<<<<<<<<<<<<< * # tstamp is in millisecons * days = (floor(tstamp / 86400000)) */ __pyx_t_1 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA); if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":247 * if file_format == FILE_FORMAT_STATA: * # tstamp is in millisecons * days = (floor(tstamp / 86400000)) # <<<<<<<<<<<<<< * msecs = tstamp % 86400000 * secs = (msecs/1000) */ __pyx_v_days = ((int)floor((__pyx_v_tstamp / 86400000.0))); /* "pyreadstat/_readstat_parser.pyx":248 * # tstamp is in millisecons * days = (floor(tstamp / 86400000)) * msecs = tstamp % 86400000 # <<<<<<<<<<<<<< * secs = (msecs/1000) * usecs = ((msecs % 1000) * 1000 ) */ __pyx_v_msecs = __Pyx_mod_double(__pyx_v_tstamp, 86400000.0); /* "pyreadstat/_readstat_parser.pyx":249 * days = (floor(tstamp / 86400000)) * msecs = tstamp % 86400000 * secs = (msecs/1000) # <<<<<<<<<<<<<< * usecs = ((msecs % 1000) * 1000 ) * tdelta = timedelta_new(days, secs, usecs) */ __pyx_v_secs = ((int)(__pyx_v_msecs / 1000.0)); /* "pyreadstat/_readstat_parser.pyx":250 * msecs = tstamp % 86400000 * secs = (msecs/1000) * usecs = ((msecs % 1000) * 1000 ) # <<<<<<<<<<<<<< * tdelta = timedelta_new(days, secs, usecs) * #tdelta = timedelta(milliseconds=tstamp) */ __pyx_v_usecs = ((int)(__Pyx_mod_double(__pyx_v_msecs, 1000.0) * 1000.0)); /* "pyreadstat/_readstat_parser.pyx":251 * secs = (msecs/1000) * usecs = ((msecs % 1000) * 1000 ) * tdelta = timedelta_new(days, secs, usecs) # <<<<<<<<<<<<<< * #tdelta = timedelta(milliseconds=tstamp) * else: */ __pyx_t_2 = ((PyObject *)__pyx_f_7cpython_8datetime_timedelta_new(__pyx_v_days, __pyx_v_secs, __pyx_v_usecs)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_tdelta = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":245 * return mydat * elif var_format == DATE_FORMAT_TIME: * if file_format == FILE_FORMAT_STATA: # <<<<<<<<<<<<<< * # tstamp is in millisecons * days = (floor(tstamp / 86400000)) */ goto __pyx_L6; } /* "pyreadstat/_readstat_parser.pyx":255 * else: * # tstamp in seconds * days = (floor(tstamp / 86400)) # <<<<<<<<<<<<<< * secs = (tstamp % 86400) * tdelta = timedelta_new(days, secs, 0) */ /*else*/ { __pyx_v_days = ((int)floor((__pyx_v_tstamp / 86400.0))); /* "pyreadstat/_readstat_parser.pyx":256 * # tstamp in seconds * days = (floor(tstamp / 86400)) * secs = (tstamp % 86400) # <<<<<<<<<<<<<< * tdelta = timedelta_new(days, secs, 0) * #tdelta = timedelta(seconds=tstamp) */ __pyx_v_secs = ((int)__Pyx_mod_double(__pyx_v_tstamp, 86400.0)); /* "pyreadstat/_readstat_parser.pyx":257 * days = (floor(tstamp / 86400)) * secs = (tstamp % 86400) * tdelta = timedelta_new(days, secs, 0) # <<<<<<<<<<<<<< * #tdelta = timedelta(seconds=tstamp) * mydat = origin + tdelta */ __pyx_t_2 = ((PyObject *)__pyx_f_7cpython_8datetime_timedelta_new(__pyx_v_days, __pyx_v_secs, 0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_tdelta = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L6:; /* "pyreadstat/_readstat_parser.pyx":259 * tdelta = timedelta_new(days, secs, 0) * #tdelta = timedelta(seconds=tstamp) * mydat = origin + tdelta # <<<<<<<<<<<<<< * return mydat.time() * */ __pyx_t_2 = PyNumber_Add(__pyx_v_origin, __pyx_v_tdelta); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_mydat = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":260 * #tdelta = timedelta(seconds=tstamp) * mydat = origin + tdelta * return mydat.time() # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_mydat, __pyx_n_s_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":244 * mydat = origin + tdelta * return mydat * elif var_format == DATE_FORMAT_TIME: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_STATA: * # tstamp is in millisecons */ break; default: break; } /* "pyreadstat/_readstat_parser.pyx":197 * return DATE_FORMAT_NOTADATE * * cdef object transform_datetime(py_datetime_format var_format, double tstamp, py_file_format file_format, object origin, bint dates_as_pandas): # <<<<<<<<<<<<<< * """ * Transforms a tstamp integer value to a date, time or datetime pyton object. */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_parser.transform_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_tdelta); __Pyx_XDECREF(__pyx_v_mydat); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":263 * * * cdef object convert_readstat_to_python_value(readstat_value_t value, int index, data_container dc): # <<<<<<<<<<<<<< * """ * Converts a readstat value to a python value. */ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_convert_readstat_to_python_value(readstat_value_t __pyx_v_value, int __pyx_v_index, struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_dc) { readstat_type_t __pyx_v_var_type; __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_v_var_format; __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format __pyx_v_pyformat; PyObject *__pyx_v_origin = 0; int __pyx_v_dates_as_pandas; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format; PyObject *__pyx_v_result = 0; char *__pyx_v_c_str_value; PyObject *__pyx_v_py_str_value = 0; int8_t __pyx_v_c_int8_value; int16_t __pyx_v_c_int16_value; int32_t __pyx_v_c_int32_value; float __pyx_v_c_float_value; double __pyx_v_c_double_value; long __pyx_v_py_long_value; double __pyx_v_py_float_value; double __pyx_v_tstamp; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; readstat_type_t __pyx_t_2; __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_t_3; int __pyx_t_4; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_t_5; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; int __pyx_t_9; PyObject *__pyx_t_10 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("convert_readstat_to_python_value", 1); /* "pyreadstat/_readstat_parser.pyx":290 * cdef double tstamp * * var_type = dc.col_dtypes[index] # <<<<<<<<<<<<<< * var_format = dc.col_formats[index] * origin = dc.origin */ if (unlikely(__pyx_v_dc->col_dtypes == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 290, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_dtypes, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = ((readstat_type_t)__Pyx_PyInt_As_readstat_type_t(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_var_type = __pyx_t_2; /* "pyreadstat/_readstat_parser.pyx":291 * * var_type = dc.col_dtypes[index] * var_format = dc.col_formats[index] # <<<<<<<<<<<<<< * origin = dc.origin * dates_as_pandas = dc.dates_as_pandas */ if (unlikely(__pyx_v_dc->col_formats == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 291, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_formats, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 291, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = ((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)__Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format(__pyx_t_1)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 291, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_var_format = __pyx_t_3; /* "pyreadstat/_readstat_parser.pyx":292 * var_type = dc.col_dtypes[index] * var_format = dc.col_formats[index] * origin = dc.origin # <<<<<<<<<<<<<< * dates_as_pandas = dc.dates_as_pandas * file_format = dc.file_format */ __pyx_t_1 = __pyx_v_dc->origin; __Pyx_INCREF(__pyx_t_1); __pyx_v_origin = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":293 * var_format = dc.col_formats[index] * origin = dc.origin * dates_as_pandas = dc.dates_as_pandas # <<<<<<<<<<<<<< * file_format = dc.file_format * */ __pyx_t_4 = __pyx_v_dc->dates_as_pandas; __pyx_v_dates_as_pandas = __pyx_t_4; /* "pyreadstat/_readstat_parser.pyx":294 * origin = dc.origin * dates_as_pandas = dc.dates_as_pandas * file_format = dc.file_format # <<<<<<<<<<<<<< * * # transform to values cython can deal with */ __pyx_t_5 = __pyx_v_dc->file_format; __pyx_v_file_format = __pyx_t_5; /* "pyreadstat/_readstat_parser.pyx":297 * * # transform to values cython can deal with * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: # <<<<<<<<<<<<<< * c_str_value = readstat_string_value(value) * if c_str_value != NULL: */ switch (__pyx_v_var_type) { case READSTAT_TYPE_STRING: case READSTAT_TYPE_STRING_REF: /* "pyreadstat/_readstat_parser.pyx":298 * # transform to values cython can deal with * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: * c_str_value = readstat_string_value(value) # <<<<<<<<<<<<<< * if c_str_value != NULL: * py_str_value = c_str_value */ __pyx_v_c_str_value = readstat_string_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":299 * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: * c_str_value = readstat_string_value(value) * if c_str_value != NULL: # <<<<<<<<<<<<<< * py_str_value = c_str_value * else: */ __pyx_t_4 = (__pyx_v_c_str_value != NULL); if (__pyx_t_4) { /* "pyreadstat/_readstat_parser.pyx":300 * c_str_value = readstat_string_value(value) * if c_str_value != NULL: * py_str_value = c_str_value # <<<<<<<<<<<<<< * else: * py_str_value = '' */ __pyx_t_1 = __Pyx_PyStr_FromString(__pyx_v_c_str_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __pyx_t_1; __Pyx_INCREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_py_str_value = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":299 * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: * c_str_value = readstat_string_value(value) * if c_str_value != NULL: # <<<<<<<<<<<<<< * py_str_value = c_str_value * else: */ goto __pyx_L3; } /* "pyreadstat/_readstat_parser.pyx":302 * py_str_value = c_str_value * else: * py_str_value = '' # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_STRING * elif var_type == READSTAT_TYPE_INT8: */ /*else*/ { __Pyx_INCREF(__pyx_kp_s__2); __pyx_v_py_str_value = __pyx_kp_s__2; } __pyx_L3:; /* "pyreadstat/_readstat_parser.pyx":303 * else: * py_str_value = '' * pyformat = VAR_FORMAT_STRING # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_INT8: * c_int8_value = readstat_int8_value(value) */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_STRING; /* "pyreadstat/_readstat_parser.pyx":297 * * # transform to values cython can deal with * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: # <<<<<<<<<<<<<< * c_str_value = readstat_string_value(value) * if c_str_value != NULL: */ break; case READSTAT_TYPE_INT8: /* "pyreadstat/_readstat_parser.pyx":305 * pyformat = VAR_FORMAT_STRING * elif var_type == READSTAT_TYPE_INT8: * c_int8_value = readstat_int8_value(value) # <<<<<<<<<<<<<< * py_long_value = c_int8_value * pyformat = VAR_FORMAT_LONG */ __pyx_v_c_int8_value = readstat_int8_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":306 * elif var_type == READSTAT_TYPE_INT8: * c_int8_value = readstat_int8_value(value) * py_long_value = c_int8_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_INT16: */ __pyx_v_py_long_value = ((long)__pyx_v_c_int8_value); /* "pyreadstat/_readstat_parser.pyx":307 * c_int8_value = readstat_int8_value(value) * py_long_value = c_int8_value * pyformat = VAR_FORMAT_LONG # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_INT16: * c_int16_value = readstat_int16_value(value) */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG; /* "pyreadstat/_readstat_parser.pyx":304 * py_str_value = '' * pyformat = VAR_FORMAT_STRING * elif var_type == READSTAT_TYPE_INT8: # <<<<<<<<<<<<<< * c_int8_value = readstat_int8_value(value) * py_long_value = c_int8_value */ break; case READSTAT_TYPE_INT16: /* "pyreadstat/_readstat_parser.pyx":309 * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_INT16: * c_int16_value = readstat_int16_value(value) # <<<<<<<<<<<<<< * py_long_value = c_int16_value * pyformat = VAR_FORMAT_LONG */ __pyx_v_c_int16_value = readstat_int16_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":310 * elif var_type == READSTAT_TYPE_INT16: * c_int16_value = readstat_int16_value(value) * py_long_value = c_int16_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_INT32: */ __pyx_v_py_long_value = ((long)__pyx_v_c_int16_value); /* "pyreadstat/_readstat_parser.pyx":311 * c_int16_value = readstat_int16_value(value) * py_long_value = c_int16_value * pyformat = VAR_FORMAT_LONG # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_INT32: * c_int32_value = readstat_int32_value(value) */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG; /* "pyreadstat/_readstat_parser.pyx":308 * py_long_value = c_int8_value * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_INT16: # <<<<<<<<<<<<<< * c_int16_value = readstat_int16_value(value) * py_long_value = c_int16_value */ break; case READSTAT_TYPE_INT32: /* "pyreadstat/_readstat_parser.pyx":313 * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_INT32: * c_int32_value = readstat_int32_value(value) # <<<<<<<<<<<<<< * py_long_value = c_int32_value * pyformat = VAR_FORMAT_LONG */ __pyx_v_c_int32_value = readstat_int32_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":314 * elif var_type == READSTAT_TYPE_INT32: * c_int32_value = readstat_int32_value(value) * py_long_value = c_int32_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_FLOAT: */ __pyx_v_py_long_value = ((long)__pyx_v_c_int32_value); /* "pyreadstat/_readstat_parser.pyx":315 * c_int32_value = readstat_int32_value(value) * py_long_value = c_int32_value * pyformat = VAR_FORMAT_LONG # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_FLOAT: * c_float_value = readstat_float_value(value) */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG; /* "pyreadstat/_readstat_parser.pyx":312 * py_long_value = c_int16_value * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_INT32: # <<<<<<<<<<<<<< * c_int32_value = readstat_int32_value(value) * py_long_value = c_int32_value */ break; case READSTAT_TYPE_FLOAT: /* "pyreadstat/_readstat_parser.pyx":317 * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_FLOAT: * c_float_value = readstat_float_value(value) # <<<<<<<<<<<<<< * py_float_value = c_float_value * pyformat = VAR_FORMAT_FLOAT */ __pyx_v_c_float_value = readstat_float_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":318 * elif var_type == READSTAT_TYPE_FLOAT: * c_float_value = readstat_float_value(value) * py_float_value = c_float_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_FLOAT * elif var_type == READSTAT_TYPE_DOUBLE: */ __pyx_v_py_float_value = ((double)__pyx_v_c_float_value); /* "pyreadstat/_readstat_parser.pyx":319 * c_float_value = readstat_float_value(value) * py_float_value = c_float_value * pyformat = VAR_FORMAT_FLOAT # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_DOUBLE: * c_double_value = readstat_double_value(value); */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT; /* "pyreadstat/_readstat_parser.pyx":316 * py_long_value = c_int32_value * pyformat = VAR_FORMAT_LONG * elif var_type == READSTAT_TYPE_FLOAT: # <<<<<<<<<<<<<< * c_float_value = readstat_float_value(value) * py_float_value = c_float_value */ break; case READSTAT_TYPE_DOUBLE: /* "pyreadstat/_readstat_parser.pyx":321 * pyformat = VAR_FORMAT_FLOAT * elif var_type == READSTAT_TYPE_DOUBLE: * c_double_value = readstat_double_value(value); # <<<<<<<<<<<<<< * py_float_value = c_double_value * pyformat = VAR_FORMAT_FLOAT */ __pyx_v_c_double_value = readstat_double_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":322 * elif var_type == READSTAT_TYPE_DOUBLE: * c_double_value = readstat_double_value(value); * py_float_value = c_double_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_FLOAT * else: */ __pyx_v_py_float_value = ((double)__pyx_v_c_double_value); /* "pyreadstat/_readstat_parser.pyx":323 * c_double_value = readstat_double_value(value); * py_float_value = c_double_value * pyformat = VAR_FORMAT_FLOAT # <<<<<<<<<<<<<< * else: * raise PyreadstatError("Unkown data type") */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT; /* "pyreadstat/_readstat_parser.pyx":320 * py_float_value = c_float_value * pyformat = VAR_FORMAT_FLOAT * elif var_type == READSTAT_TYPE_DOUBLE: # <<<<<<<<<<<<<< * c_double_value = readstat_double_value(value); * py_float_value = c_double_value */ break; default: /* "pyreadstat/_readstat_parser.pyx":325 * pyformat = VAR_FORMAT_FLOAT * else: * raise PyreadstatError("Unkown data type") # <<<<<<<<<<<<<< * * # final transformation and storage */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_s_Unkown_data_type}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 325, __pyx_L1_error) break; } /* "pyreadstat/_readstat_parser.pyx":329 * # final transformation and storage * * if pyformat == VAR_FORMAT_STRING: # <<<<<<<<<<<<<< * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: * result = py_str_value */ switch (__pyx_v_pyformat) { case __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_STRING: /* "pyreadstat/_readstat_parser.pyx":330 * * if pyformat == VAR_FORMAT_STRING: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: # <<<<<<<<<<<<<< * result = py_str_value * else: */ __pyx_t_9 = (__pyx_v_var_format == __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE); if (!__pyx_t_9) { } else { __pyx_t_4 = __pyx_t_9; goto __pyx_L5_bool_binop_done; } __pyx_t_4 = __pyx_v_dc->no_datetime_conversion; __pyx_L5_bool_binop_done:; if (likely(__pyx_t_4)) { /* "pyreadstat/_readstat_parser.pyx":331 * if pyformat == VAR_FORMAT_STRING: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: * result = py_str_value # <<<<<<<<<<<<<< * else: * #str_byte_val = py_str_value.encode("UTF-8") */ if (unlikely(!__pyx_v_py_str_value)) { __Pyx_RaiseUnboundLocalError("py_str_value"); __PYX_ERR(0, 331, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_py_str_value); __pyx_v_result = __pyx_v_py_str_value; /* "pyreadstat/_readstat_parser.pyx":330 * * if pyformat == VAR_FORMAT_STRING: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: # <<<<<<<<<<<<<< * result = py_str_value * else: */ goto __pyx_L4; } /* "pyreadstat/_readstat_parser.pyx":334 * else: * #str_byte_val = py_str_value.encode("UTF-8") * raise PyreadstatError("STRING type with value '%s' with date type in column '%s'" % (py_str_value, dc.col_names[index])) # <<<<<<<<<<<<<< * elif pyformat == VAR_FORMAT_LONG: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(!__pyx_v_py_str_value)) { __Pyx_RaiseUnboundLocalError("py_str_value"); __PYX_ERR(0, 334, __pyx_L1_error) } if (unlikely(__pyx_v_dc->col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 334, __pyx_L1_error) } __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_dc->col_names, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_v_py_str_value); __Pyx_GIVEREF(__pyx_v_py_str_value); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_py_str_value)) __PYX_ERR(0, 334, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_7)) __PYX_ERR(0, 334, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_STRING_type_with_value_s_with_da, __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_7}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 334, __pyx_L1_error) } __pyx_L4:; /* "pyreadstat/_readstat_parser.pyx":329 * # final transformation and storage * * if pyformat == VAR_FORMAT_STRING: # <<<<<<<<<<<<<< * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: * result = py_str_value */ break; case __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG: /* "pyreadstat/_readstat_parser.pyx":336 * raise PyreadstatError("STRING type with value '%s' with date type in column '%s'" % (py_str_value, dc.col_names[index])) * elif pyformat == VAR_FORMAT_LONG: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: # <<<<<<<<<<<<<< * result = py_long_value * else: */ __pyx_t_9 = (__pyx_v_var_format == __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE); if (!__pyx_t_9) { } else { __pyx_t_4 = __pyx_t_9; goto __pyx_L8_bool_binop_done; } __pyx_t_4 = __pyx_v_dc->no_datetime_conversion; __pyx_L8_bool_binop_done:; if (__pyx_t_4) { /* "pyreadstat/_readstat_parser.pyx":337 * elif pyformat == VAR_FORMAT_LONG: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: * result = py_long_value # <<<<<<<<<<<<<< * else: * tstamp = py_long_value */ __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_py_long_value); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_result = __pyx_t_6; __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":336 * raise PyreadstatError("STRING type with value '%s' with date type in column '%s'" % (py_str_value, dc.col_names[index])) * elif pyformat == VAR_FORMAT_LONG: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: # <<<<<<<<<<<<<< * result = py_long_value * else: */ goto __pyx_L7; } /* "pyreadstat/_readstat_parser.pyx":339 * result = py_long_value * else: * tstamp = py_long_value # <<<<<<<<<<<<<< * result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) * elif pyformat == VAR_FORMAT_FLOAT: */ /*else*/ { __pyx_v_tstamp = ((double)__pyx_v_py_long_value); /* "pyreadstat/_readstat_parser.pyx":340 * else: * tstamp = py_long_value * result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) # <<<<<<<<<<<<<< * elif pyformat == VAR_FORMAT_FLOAT: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: */ __pyx_t_6 = __pyx_f_10pyreadstat_16_readstat_parser_transform_datetime(__pyx_v_var_format, __pyx_v_tstamp, __pyx_v_file_format, __pyx_v_origin, __pyx_v_dates_as_pandas); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_result = __pyx_t_6; __pyx_t_6 = 0; } __pyx_L7:; /* "pyreadstat/_readstat_parser.pyx":335 * #str_byte_val = py_str_value.encode("UTF-8") * raise PyreadstatError("STRING type with value '%s' with date type in column '%s'" % (py_str_value, dc.col_names[index])) * elif pyformat == VAR_FORMAT_LONG: # <<<<<<<<<<<<<< * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: * result = py_long_value */ break; case __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT: /* "pyreadstat/_readstat_parser.pyx":342 * result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) * elif pyformat == VAR_FORMAT_FLOAT: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: # <<<<<<<<<<<<<< * result = py_float_value * else: */ __pyx_t_9 = (__pyx_v_var_format == __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE); if (!__pyx_t_9) { } else { __pyx_t_4 = __pyx_t_9; goto __pyx_L11_bool_binop_done; } __pyx_t_4 = __pyx_v_dc->no_datetime_conversion; __pyx_L11_bool_binop_done:; if (__pyx_t_4) { /* "pyreadstat/_readstat_parser.pyx":343 * elif pyformat == VAR_FORMAT_FLOAT: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: * result = py_float_value # <<<<<<<<<<<<<< * else: * #tstamp = py_float_value */ __pyx_t_6 = PyFloat_FromDouble(__pyx_v_py_float_value); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_result = __pyx_t_6; __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":342 * result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) * elif pyformat == VAR_FORMAT_FLOAT: * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: # <<<<<<<<<<<<<< * result = py_float_value * else: */ goto __pyx_L10; } /* "pyreadstat/_readstat_parser.pyx":346 * else: * #tstamp = py_float_value * tstamp = py_float_value # <<<<<<<<<<<<<< * result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) * #elif pyformat == VAR_FORMAT_MISSING: */ /*else*/ { __pyx_v_tstamp = __pyx_v_py_float_value; /* "pyreadstat/_readstat_parser.pyx":347 * #tstamp = py_float_value * tstamp = py_float_value * result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) # <<<<<<<<<<<<<< * #elif pyformat == VAR_FORMAT_MISSING: * # pass */ __pyx_t_6 = __pyx_f_10pyreadstat_16_readstat_parser_transform_datetime(__pyx_v_var_format, __pyx_v_tstamp, __pyx_v_file_format, __pyx_v_origin, __pyx_v_dates_as_pandas); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_result = __pyx_t_6; __pyx_t_6 = 0; } __pyx_L10:; /* "pyreadstat/_readstat_parser.pyx":341 * tstamp = py_long_value * result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) * elif pyformat == VAR_FORMAT_FLOAT: # <<<<<<<<<<<<<< * if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: * result = py_float_value */ break; default: /* "pyreadstat/_readstat_parser.pyx":351 * # pass * else: * raise PyreadstatError("Failed convert C to python value") # <<<<<<<<<<<<<< * * return result */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_s_Failed_convert_C_to_python_value}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 351, __pyx_L1_error) break; } /* "pyreadstat/_readstat_parser.pyx":353 * raise PyreadstatError("Failed convert C to python value") * * return result # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":263 * * * cdef object convert_readstat_to_python_value(readstat_value_t value, int index, data_container dc): # <<<<<<<<<<<<<< * """ * Converts a readstat value to a python value. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("pyreadstat._readstat_parser.convert_readstat_to_python_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_origin); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_py_str_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":356 * * * cdef int handle_metadata(readstat_metadata_t *metadata, void *ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * This function sets the number of observations(rows), number of variables */ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_metadata(readstat_metadata_t *__pyx_v_metadata, void *__pyx_v_ctx) { int __pyx_v_var_count; int __pyx_v_obs_count; struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_dc = 0; char *__pyx_v_flabel_orig; char *__pyx_v_fencoding_orig; PyObject *__pyx_v_flabel = 0; PyObject *__pyx_v_fencoding = 0; CYTHON_UNUSED int __pyx_v_metaonly; char *__pyx_v_table; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_metadata", 1); /* "pyreadstat/_readstat_parser.pyx":365 * * cdef int var_count, obs_count * cdef data_container dc = ctx # <<<<<<<<<<<<<< * #cdef object row * cdef char * flabel_orig */ __pyx_t_1 = ((PyObject *)__pyx_v_ctx); __Pyx_INCREF(__pyx_t_1); __pyx_v_dc = ((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":375 * cdef int mtime * * metaonly = dc.metaonly # <<<<<<<<<<<<<< * * var_count = readstat_get_var_count(metadata) */ __pyx_t_2 = __pyx_v_dc->metaonly; __pyx_v_metaonly = __pyx_t_2; /* "pyreadstat/_readstat_parser.pyx":377 * metaonly = dc.metaonly * * var_count = readstat_get_var_count(metadata) # <<<<<<<<<<<<<< * if var_count<0: * raise PyreadstatError("Failed to read number of variables") */ __pyx_v_var_count = readstat_get_var_count(__pyx_v_metadata); /* "pyreadstat/_readstat_parser.pyx":378 * * var_count = readstat_get_var_count(metadata) * if var_count<0: # <<<<<<<<<<<<<< * raise PyreadstatError("Failed to read number of variables") * obs_count = readstat_get_row_count(metadata) */ __pyx_t_2 = (__pyx_v_var_count < 0); if (unlikely(__pyx_t_2)) { /* "pyreadstat/_readstat_parser.pyx":379 * var_count = readstat_get_var_count(metadata) * if var_count<0: * raise PyreadstatError("Failed to read number of variables") # <<<<<<<<<<<<<< * obs_count = readstat_get_row_count(metadata) * if obs_count <0: */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_kp_s_Failed_to_read_number_of_variabl}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 379, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":378 * * var_count = readstat_get_var_count(metadata) * if var_count<0: # <<<<<<<<<<<<<< * raise PyreadstatError("Failed to read number of variables") * obs_count = readstat_get_row_count(metadata) */ } /* "pyreadstat/_readstat_parser.pyx":380 * if var_count<0: * raise PyreadstatError("Failed to read number of variables") * obs_count = readstat_get_row_count(metadata) # <<<<<<<<<<<<<< * if obs_count <0: * # if <0 it means the number of rows is not known, allocate 100 000 */ __pyx_v_obs_count = readstat_get_row_count(__pyx_v_metadata); /* "pyreadstat/_readstat_parser.pyx":381 * raise PyreadstatError("Failed to read number of variables") * obs_count = readstat_get_row_count(metadata) * if obs_count <0: # <<<<<<<<<<<<<< * # if <0 it means the number of rows is not known, allocate 100 000 * obs_count = 100000 */ __pyx_t_2 = (__pyx_v_obs_count < 0); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":383 * if obs_count <0: * # if <0 it means the number of rows is not known, allocate 100 000 * obs_count = 100000 # <<<<<<<<<<<<<< * dc.is_unkown_number_rows = 1 * */ __pyx_v_obs_count = 0x186A0; /* "pyreadstat/_readstat_parser.pyx":384 * # if <0 it means the number of rows is not known, allocate 100 000 * obs_count = 100000 * dc.is_unkown_number_rows = 1 # <<<<<<<<<<<<<< * * dc.n_obs = obs_count */ __pyx_v_dc->is_unkown_number_rows = 1; /* "pyreadstat/_readstat_parser.pyx":381 * raise PyreadstatError("Failed to read number of variables") * obs_count = readstat_get_row_count(metadata) * if obs_count <0: # <<<<<<<<<<<<<< * # if <0 it means the number of rows is not known, allocate 100 000 * obs_count = 100000 */ } /* "pyreadstat/_readstat_parser.pyx":386 * dc.is_unkown_number_rows = 1 * * dc.n_obs = obs_count # <<<<<<<<<<<<<< * dc.n_vars = var_count * */ __pyx_v_dc->n_obs = __pyx_v_obs_count; /* "pyreadstat/_readstat_parser.pyx":387 * * dc.n_obs = obs_count * dc.n_vars = var_count # <<<<<<<<<<<<<< * * dc.col_data_len = [obs_count] * var_count */ __pyx_v_dc->n_vars = __pyx_v_var_count; /* "pyreadstat/_readstat_parser.pyx":389 * dc.n_vars = var_count * * dc.col_data_len = [obs_count] * var_count # <<<<<<<<<<<<<< * dc.col_numpy_dtypes = [None] * var_count * dc.col_dytpes_isfloat = [0] * var_count */ __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_obs_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyList_New(1 * ((__pyx_v_var_count<0) ? 0:__pyx_v_var_count)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_var_count; __pyx_temp++) { __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_t_1)) __PYX_ERR(0, 389, __pyx_L1_error); } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_dc->col_data_len); __Pyx_DECREF(__pyx_v_dc->col_data_len); __pyx_v_dc->col_data_len = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":390 * * dc.col_data_len = [obs_count] * var_count * dc.col_numpy_dtypes = [None] * var_count # <<<<<<<<<<<<<< * dc.col_dytpes_isfloat = [0] * var_count * dc.col_dtypes_isobject = [0] * var_count */ __pyx_t_3 = PyList_New(1 * ((__pyx_v_var_count<0) ? 0:__pyx_v_var_count)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_var_count; __pyx_temp++) { __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, __pyx_temp, Py_None)) __PYX_ERR(0, 390, __pyx_L1_error); } } __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_dc->col_numpy_dtypes); __Pyx_DECREF(__pyx_v_dc->col_numpy_dtypes); __pyx_v_dc->col_numpy_dtypes = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":391 * dc.col_data_len = [obs_count] * var_count * dc.col_numpy_dtypes = [None] * var_count * dc.col_dytpes_isfloat = [0] * var_count # <<<<<<<<<<<<<< * dc.col_dtypes_isobject = [0] * var_count * */ __pyx_t_3 = PyList_New(1 * ((__pyx_v_var_count<0) ? 0:__pyx_v_var_count)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_var_count; __pyx_temp++) { __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_int_0)) __PYX_ERR(0, 391, __pyx_L1_error); } } __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_dc->col_dytpes_isfloat); __Pyx_DECREF(__pyx_v_dc->col_dytpes_isfloat); __pyx_v_dc->col_dytpes_isfloat = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":392 * dc.col_numpy_dtypes = [None] * var_count * dc.col_dytpes_isfloat = [0] * var_count * dc.col_dtypes_isobject = [0] * var_count # <<<<<<<<<<<<<< * * # read other metadata */ __pyx_t_3 = PyList_New(1 * ((__pyx_v_var_count<0) ? 0:__pyx_v_var_count)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 392, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_var_count; __pyx_temp++) { __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_int_0)) __PYX_ERR(0, 392, __pyx_L1_error); } } __Pyx_GIVEREF(__pyx_t_3); __Pyx_GOTREF(__pyx_v_dc->col_dtypes_isobject); __Pyx_DECREF(__pyx_v_dc->col_dtypes_isobject); __pyx_v_dc->col_dtypes_isobject = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":395 * * # read other metadata * flabel_orig = readstat_get_file_label(metadata); # <<<<<<<<<<<<<< * fencoding_orig = readstat_get_file_encoding(metadata) * if flabel_orig != NULL and flabel_orig[0]: */ __pyx_v_flabel_orig = readstat_get_file_label(__pyx_v_metadata); /* "pyreadstat/_readstat_parser.pyx":396 * # read other metadata * flabel_orig = readstat_get_file_label(metadata); * fencoding_orig = readstat_get_file_encoding(metadata) # <<<<<<<<<<<<<< * if flabel_orig != NULL and flabel_orig[0]: * flabel = flabel_orig */ __pyx_v_fencoding_orig = readstat_get_file_encoding(__pyx_v_metadata); /* "pyreadstat/_readstat_parser.pyx":397 * flabel_orig = readstat_get_file_label(metadata); * fencoding_orig = readstat_get_file_encoding(metadata) * if flabel_orig != NULL and flabel_orig[0]: # <<<<<<<<<<<<<< * flabel = flabel_orig * else: */ __pyx_t_6 = (__pyx_v_flabel_orig != NULL); if (__pyx_t_6) { } else { __pyx_t_2 = __pyx_t_6; goto __pyx_L6_bool_binop_done; } __pyx_t_6 = ((__pyx_v_flabel_orig[0]) != 0); __pyx_t_2 = __pyx_t_6; __pyx_L6_bool_binop_done:; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":398 * fencoding_orig = readstat_get_file_encoding(metadata) * if flabel_orig != NULL and flabel_orig[0]: * flabel = flabel_orig # <<<<<<<<<<<<<< * else: * flabel = None */ __pyx_t_3 = __Pyx_PyStr_FromString(__pyx_v_flabel_orig); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_flabel = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":397 * flabel_orig = readstat_get_file_label(metadata); * fencoding_orig = readstat_get_file_encoding(metadata) * if flabel_orig != NULL and flabel_orig[0]: # <<<<<<<<<<<<<< * flabel = flabel_orig * else: */ goto __pyx_L5; } /* "pyreadstat/_readstat_parser.pyx":400 * flabel = flabel_orig * else: * flabel = None # <<<<<<<<<<<<<< * if fencoding_orig != NULL and fencoding_orig[0]: * fencoding = fencoding_orig */ /*else*/ { __Pyx_INCREF(Py_None); __pyx_v_flabel = ((PyObject*)Py_None); } __pyx_L5:; /* "pyreadstat/_readstat_parser.pyx":401 * else: * flabel = None * if fencoding_orig != NULL and fencoding_orig[0]: # <<<<<<<<<<<<<< * fencoding = fencoding_orig * else: */ __pyx_t_6 = (__pyx_v_fencoding_orig != NULL); if (__pyx_t_6) { } else { __pyx_t_2 = __pyx_t_6; goto __pyx_L9_bool_binop_done; } __pyx_t_6 = ((__pyx_v_fencoding_orig[0]) != 0); __pyx_t_2 = __pyx_t_6; __pyx_L9_bool_binop_done:; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":402 * flabel = None * if fencoding_orig != NULL and fencoding_orig[0]: * fencoding = fencoding_orig # <<<<<<<<<<<<<< * else: * fencoding = None */ __pyx_t_1 = __Pyx_PyStr_FromString(__pyx_v_fencoding_orig); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_fencoding = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":401 * else: * flabel = None * if fencoding_orig != NULL and fencoding_orig[0]: # <<<<<<<<<<<<<< * fencoding = fencoding_orig * else: */ goto __pyx_L8; } /* "pyreadstat/_readstat_parser.pyx":404 * fencoding = fencoding_orig * else: * fencoding = None # <<<<<<<<<<<<<< * * dc.file_encoding = fencoding */ /*else*/ { __Pyx_INCREF(Py_None); __pyx_v_fencoding = ((PyObject*)Py_None); } __pyx_L8:; /* "pyreadstat/_readstat_parser.pyx":406 * fencoding = None * * dc.file_encoding = fencoding # <<<<<<<<<<<<<< * dc.file_label = flabel * */ __Pyx_INCREF(__pyx_v_fencoding); __Pyx_GIVEREF(__pyx_v_fencoding); __Pyx_GOTREF(__pyx_v_dc->file_encoding); __Pyx_DECREF(__pyx_v_dc->file_encoding); __pyx_v_dc->file_encoding = __pyx_v_fencoding; /* "pyreadstat/_readstat_parser.pyx":407 * * dc.file_encoding = fencoding * dc.file_label = flabel # <<<<<<<<<<<<<< * * table = readstat_get_table_name(metadata) */ __Pyx_INCREF(__pyx_v_flabel); __Pyx_GIVEREF(__pyx_v_flabel); __Pyx_GOTREF(__pyx_v_dc->file_label); __Pyx_DECREF(__pyx_v_dc->file_label); __pyx_v_dc->file_label = __pyx_v_flabel; /* "pyreadstat/_readstat_parser.pyx":409 * dc.file_label = flabel * * table = readstat_get_table_name(metadata) # <<<<<<<<<<<<<< * if table != NULL and table[0]: * dc.table_name = table */ __pyx_v_table = readstat_get_table_name(__pyx_v_metadata); /* "pyreadstat/_readstat_parser.pyx":410 * * table = readstat_get_table_name(metadata) * if table != NULL and table[0]: # <<<<<<<<<<<<<< * dc.table_name = table * */ __pyx_t_6 = (__pyx_v_table != NULL); if (__pyx_t_6) { } else { __pyx_t_2 = __pyx_t_6; goto __pyx_L12_bool_binop_done; } __pyx_t_6 = ((__pyx_v_table[0]) != 0); __pyx_t_2 = __pyx_t_6; __pyx_L12_bool_binop_done:; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":411 * table = readstat_get_table_name(metadata) * if table != NULL and table[0]: * dc.table_name = table # <<<<<<<<<<<<<< * * dc.ctime = readstat_get_creation_time(metadata) */ __pyx_t_3 = __Pyx_PyStr_FromString(__pyx_v_table); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_dc->table_name); __Pyx_DECREF(__pyx_v_dc->table_name); __pyx_v_dc->table_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":410 * * table = readstat_get_table_name(metadata) * if table != NULL and table[0]: # <<<<<<<<<<<<<< * dc.table_name = table * */ } /* "pyreadstat/_readstat_parser.pyx":413 * dc.table_name = table * * dc.ctime = readstat_get_creation_time(metadata) # <<<<<<<<<<<<<< * dc.mtime = readstat_get_modified_time(metadata) * */ __pyx_v_dc->ctime = readstat_get_creation_time(__pyx_v_metadata); /* "pyreadstat/_readstat_parser.pyx":414 * * dc.ctime = readstat_get_creation_time(metadata) * dc.mtime = readstat_get_modified_time(metadata) # <<<<<<<<<<<<<< * * return READSTAT_HANDLER_OK */ __pyx_v_dc->mtime = readstat_get_modified_time(__pyx_v_metadata); /* "pyreadstat/_readstat_parser.pyx":416 * dc.mtime = readstat_get_modified_time(metadata) * * return READSTAT_HANDLER_OK # <<<<<<<<<<<<<< * * cdef int handle_variable(int index, readstat_variable_t *variable, */ __pyx_r = READSTAT_HANDLER_OK; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":356 * * * cdef int handle_metadata(readstat_metadata_t *metadata, void *ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * This function sets the number of observations(rows), number of variables */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_parser.handle_metadata", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = READSTAT_HANDLER_ABORT; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_dc); __Pyx_XDECREF(__pyx_v_flabel); __Pyx_XDECREF(__pyx_v_fencoding); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":418 * return READSTAT_HANDLER_OK * * cdef int handle_variable(int index, readstat_variable_t *variable, # <<<<<<<<<<<<<< * char *val_labels, void *ctx) except READSTAT_HANDLER_ABORT: * """ */ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_variable(int __pyx_v_index, readstat_variable_t *__pyx_v_variable, char *__pyx_v_val_labels, void *__pyx_v_ctx) { char *__pyx_v_var_name; char *__pyx_v_var_label; char *__pyx_v_var_format; PyObject *__pyx_v_col_name = 0; PyObject *__pyx_v_col_label = 0; PyObject *__pyx_v_label_name = 0; PyObject *__pyx_v_col_format_original = 0; __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_v_col_format_final; readstat_type_t __pyx_v_var_type; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format; int __pyx_v_n_ranges; readstat_value_t __pyx_v_loval; readstat_value_t __pyx_v_hival; PyObject *__pyx_v_pyloval = 0; PyObject *__pyx_v_pyhival = 0; PyObject *__pyx_v_missing_ranges = 0; PyObject *__pyx_v_curnptype = 0; PyObject *__pyx_v_row = 0; int __pyx_v_metaonly; int __pyx_v_obs_count; int __pyx_v_iscurnptypefloat; int __pyx_v_iscurnptypeobject; PyObject *__pyx_v_newcolname = 0; int __pyx_v_dupcolcnt; struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_dc = 0; PyObject *__pyx_v_msg = NULL; long __pyx_v_i; size_t __pyx_v_storage_width; readstat_alignment_t __pyx_v_align; PyObject *__pyx_v_pyalign = 0; readstat_measure_t __pyx_v_measure; PyObject *__pyx_v_pymeasure = 0; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; int __pyx_t_7; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_t_8; __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_t_9; PyObject *__pyx_t_10 = NULL; int __pyx_t_11; long __pyx_t_12; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_variable", 1); /* "pyreadstat/_readstat_parser.pyx":447 * cdef int dupcolcnt * * cdef data_container dc = ctx # <<<<<<<<<<<<<< * * # get variable name, label, format and type and put into our data container */ __pyx_t_1 = ((PyObject *)__pyx_v_ctx); __Pyx_INCREF(__pyx_t_1); __pyx_v_dc = ((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":450 * * # get variable name, label, format and type and put into our data container * var_name = readstat_variable_get_name(variable) # <<<<<<<<<<<<<< * if var_name == NULL: * col_name = None */ __pyx_v_var_name = readstat_variable_get_name(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":451 * # get variable name, label, format and type and put into our data container * var_name = readstat_variable_get_name(variable) * if var_name == NULL: # <<<<<<<<<<<<<< * col_name = None * else: */ __pyx_t_2 = (__pyx_v_var_name == NULL); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":452 * var_name = readstat_variable_get_name(variable) * if var_name == NULL: * col_name = None # <<<<<<<<<<<<<< * else: * col_name = var_name */ __Pyx_INCREF(Py_None); __pyx_v_col_name = ((PyObject*)Py_None); /* "pyreadstat/_readstat_parser.pyx":451 * # get variable name, label, format and type and put into our data container * var_name = readstat_variable_get_name(variable) * if var_name == NULL: # <<<<<<<<<<<<<< * col_name = None * else: */ goto __pyx_L3; } /* "pyreadstat/_readstat_parser.pyx":454 * col_name = None * else: * col_name = var_name # <<<<<<<<<<<<<< * * # if the user introduced a list of columns to include, continue only if the column is in the list */ /*else*/ { __pyx_t_1 = __Pyx_PyStr_FromString(__pyx_v_var_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_col_name = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; } __pyx_L3:; /* "pyreadstat/_readstat_parser.pyx":457 * * # if the user introduced a list of columns to include, continue only if the column is in the list * if dc.filter_cols and not (col_name in dc.use_cols): # <<<<<<<<<<<<<< * dc.n_vars -= 1 * return READSTAT_HANDLER_SKIP_VARIABLE */ if (__pyx_v_dc->filter_cols) { } else { __pyx_t_2 = __pyx_v_dc->filter_cols; goto __pyx_L5_bool_binop_done; } __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_col_name, __pyx_v_dc->use_cols, Py_NE)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 457, __pyx_L1_error) __pyx_t_2 = __pyx_t_4; __pyx_L5_bool_binop_done:; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":458 * # if the user introduced a list of columns to include, continue only if the column is in the list * if dc.filter_cols and not (col_name in dc.use_cols): * dc.n_vars -= 1 # <<<<<<<<<<<<<< * return READSTAT_HANDLER_SKIP_VARIABLE * */ __pyx_v_dc->n_vars = (__pyx_v_dc->n_vars - 1); /* "pyreadstat/_readstat_parser.pyx":459 * if dc.filter_cols and not (col_name in dc.use_cols): * dc.n_vars -= 1 * return READSTAT_HANDLER_SKIP_VARIABLE # <<<<<<<<<<<<<< * * index = readstat_variable_get_index_after_skipping(variable) */ __pyx_r = READSTAT_HANDLER_SKIP_VARIABLE; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":457 * * # if the user introduced a list of columns to include, continue only if the column is in the list * if dc.filter_cols and not (col_name in dc.use_cols): # <<<<<<<<<<<<<< * dc.n_vars -= 1 * return READSTAT_HANDLER_SKIP_VARIABLE */ } /* "pyreadstat/_readstat_parser.pyx":461 * return READSTAT_HANDLER_SKIP_VARIABLE * * index = readstat_variable_get_index_after_skipping(variable) # <<<<<<<<<<<<<< * * if col_name in dc.col_names: */ __pyx_v_index = readstat_variable_get_index_after_skipping(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":463 * index = readstat_variable_get_index_after_skipping(variable) * * if col_name in dc.col_names: # <<<<<<<<<<<<<< * dupcolcnt = 1 * while True: */ __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_col_name, __pyx_v_dc->col_names, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 463, __pyx_L1_error) if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":464 * * if col_name in dc.col_names: * dupcolcnt = 1 # <<<<<<<<<<<<<< * while True: * newcolname = col_name + "_duplicated" + str(dupcolcnt) */ __pyx_v_dupcolcnt = 1; /* "pyreadstat/_readstat_parser.pyx":465 * if col_name in dc.col_names: * dupcolcnt = 1 * while True: # <<<<<<<<<<<<<< * newcolname = col_name + "_duplicated" + str(dupcolcnt) * if newcolname in col_name: */ while (1) { /* "pyreadstat/_readstat_parser.pyx":466 * dupcolcnt = 1 * while True: * newcolname = col_name + "_duplicated" + str(dupcolcnt) # <<<<<<<<<<<<<< * if newcolname in col_name: * dupcolcnt += 1 */ __pyx_t_3 = __Pyx_PyStr_ConcatSafe(__pyx_v_col_name, __pyx_n_s_duplicated); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_dupcolcnt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_Str(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_1))) __PYX_ERR(0, 466, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_newcolname, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":467 * while True: * newcolname = col_name + "_duplicated" + str(dupcolcnt) * if newcolname in col_name: # <<<<<<<<<<<<<< * dupcolcnt += 1 * continue */ __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_newcolname, __pyx_v_col_name, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 467, __pyx_L1_error) if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":468 * newcolname = col_name + "_duplicated" + str(dupcolcnt) * if newcolname in col_name: * dupcolcnt += 1 # <<<<<<<<<<<<<< * continue * else: */ __pyx_v_dupcolcnt = (__pyx_v_dupcolcnt + 1); /* "pyreadstat/_readstat_parser.pyx":469 * if newcolname in col_name: * dupcolcnt += 1 * continue # <<<<<<<<<<<<<< * else: * msg = "column '{0}' is duplicated, renamed to '{1}'".format(col_name, newcolname) */ goto __pyx_L8_continue; /* "pyreadstat/_readstat_parser.pyx":467 * while True: * newcolname = col_name + "_duplicated" + str(dupcolcnt) * if newcolname in col_name: # <<<<<<<<<<<<<< * dupcolcnt += 1 * continue */ } /* "pyreadstat/_readstat_parser.pyx":471 * continue * else: * msg = "column '{0}' is duplicated, renamed to '{1}'".format(col_name, newcolname) # <<<<<<<<<<<<<< * warnings.warn(msg) * col_name = newcolname */ /*else*/ { __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_column_0_is_duplicated_renamed_t, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_col_name, __pyx_v_newcolname}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_msg = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":472 * else: * msg = "column '{0}' is duplicated, renamed to '{1}'".format(col_name, newcolname) * warnings.warn(msg) # <<<<<<<<<<<<<< * col_name = newcolname * break */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_warnings); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_msg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":473 * msg = "column '{0}' is duplicated, renamed to '{1}'".format(col_name, newcolname) * warnings.warn(msg) * col_name = newcolname # <<<<<<<<<<<<<< * break * */ __Pyx_INCREF(__pyx_v_newcolname); __Pyx_DECREF_SET(__pyx_v_col_name, __pyx_v_newcolname); /* "pyreadstat/_readstat_parser.pyx":474 * warnings.warn(msg) * col_name = newcolname * break # <<<<<<<<<<<<<< * * dc.col_names.append(col_name) */ goto __pyx_L9_break; } __pyx_L8_continue:; } __pyx_L9_break:; /* "pyreadstat/_readstat_parser.pyx":463 * index = readstat_variable_get_index_after_skipping(variable) * * if col_name in dc.col_names: # <<<<<<<<<<<<<< * dupcolcnt = 1 * while True: */ } /* "pyreadstat/_readstat_parser.pyx":476 * break * * dc.col_names.append(col_name) # <<<<<<<<<<<<<< * * # the name of the value label for the variable */ if (unlikely(__pyx_v_dc->col_names == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 476, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_dc->col_names, __pyx_v_col_name); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 476, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":479 * * # the name of the value label for the variable * if val_labels != NULL: # <<<<<<<<<<<<<< * label_name = val_labels * if label_name: */ __pyx_t_2 = (__pyx_v_val_labels != NULL); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":480 * # the name of the value label for the variable * if val_labels != NULL: * label_name = val_labels # <<<<<<<<<<<<<< * if label_name: * dc.label_to_var_name[col_name] = label_name */ __pyx_t_1 = __Pyx_PyStr_FromString(__pyx_v_val_labels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_label_name = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":481 * if val_labels != NULL: * label_name = val_labels * if label_name: # <<<<<<<<<<<<<< * dc.label_to_var_name[col_name] = label_name * */ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_label_name); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 481, __pyx_L1_error) if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":482 * label_name = val_labels * if label_name: * dc.label_to_var_name[col_name] = label_name # <<<<<<<<<<<<<< * * var_label = readstat_variable_get_label(variable) */ if (unlikely((PyObject_SetItem(__pyx_v_dc->label_to_var_name, __pyx_v_col_name, __pyx_v_label_name) < 0))) __PYX_ERR(0, 482, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":481 * if val_labels != NULL: * label_name = val_labels * if label_name: # <<<<<<<<<<<<<< * dc.label_to_var_name[col_name] = label_name * */ } /* "pyreadstat/_readstat_parser.pyx":479 * * # the name of the value label for the variable * if val_labels != NULL: # <<<<<<<<<<<<<< * label_name = val_labels * if label_name: */ } /* "pyreadstat/_readstat_parser.pyx":484 * dc.label_to_var_name[col_name] = label_name * * var_label = readstat_variable_get_label(variable) # <<<<<<<<<<<<<< * if var_label == NULL: * col_label = None */ __pyx_v_var_label = readstat_variable_get_label(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":485 * * var_label = readstat_variable_get_label(variable) * if var_label == NULL: # <<<<<<<<<<<<<< * col_label = None * else: */ __pyx_t_2 = (__pyx_v_var_label == NULL); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":486 * var_label = readstat_variable_get_label(variable) * if var_label == NULL: * col_label = None # <<<<<<<<<<<<<< * else: * col_label = var_label */ __Pyx_INCREF(Py_None); __pyx_v_col_label = ((PyObject*)Py_None); /* "pyreadstat/_readstat_parser.pyx":485 * * var_label = readstat_variable_get_label(variable) * if var_label == NULL: # <<<<<<<<<<<<<< * col_label = None * else: */ goto __pyx_L13; } /* "pyreadstat/_readstat_parser.pyx":488 * col_label = None * else: * col_label = var_label # <<<<<<<<<<<<<< * dc.col_labels.append(col_label) * */ /*else*/ { __pyx_t_3 = __Pyx_PyStr_FromString(__pyx_v_var_label); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 488, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_col_label = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; } __pyx_L13:; /* "pyreadstat/_readstat_parser.pyx":489 * else: * col_label = var_label * dc.col_labels.append(col_label) # <<<<<<<<<<<<<< * * # format, we have to transform it in something more usable */ if (unlikely(__pyx_v_dc->col_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 489, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_dc->col_labels, __pyx_v_col_label); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 489, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":492 * * # format, we have to transform it in something more usable * var_format = readstat_variable_get_format(variable) # <<<<<<<<<<<<<< * if var_format == NULL: * col_format_original = "NULL" */ __pyx_v_var_format = readstat_variable_get_format(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":493 * # format, we have to transform it in something more usable * var_format = readstat_variable_get_format(variable) * if var_format == NULL: # <<<<<<<<<<<<<< * col_format_original = "NULL" * else: */ __pyx_t_2 = (__pyx_v_var_format == NULL); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":494 * var_format = readstat_variable_get_format(variable) * if var_format == NULL: * col_format_original = "NULL" # <<<<<<<<<<<<<< * else: * col_format_original = var_format */ __Pyx_INCREF(__pyx_n_s_NULL); __pyx_v_col_format_original = __pyx_n_s_NULL; /* "pyreadstat/_readstat_parser.pyx":493 * # format, we have to transform it in something more usable * var_format = readstat_variable_get_format(variable) * if var_format == NULL: # <<<<<<<<<<<<<< * col_format_original = "NULL" * else: */ goto __pyx_L14; } /* "pyreadstat/_readstat_parser.pyx":496 * col_format_original = "NULL" * else: * col_format_original = var_format # <<<<<<<<<<<<<< * file_format = dc.file_format * dc.col_formats_original.append(col_format_original) */ /*else*/ { __pyx_t_1 = __Pyx_PyStr_FromString(__pyx_v_var_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 496, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_col_format_original = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; } __pyx_L14:; /* "pyreadstat/_readstat_parser.pyx":497 * else: * col_format_original = var_format * file_format = dc.file_format # <<<<<<<<<<<<<< * dc.col_formats_original.append(col_format_original) * col_format_final = transform_variable_format(col_format_original, file_format) */ __pyx_t_8 = __pyx_v_dc->file_format; __pyx_v_file_format = __pyx_t_8; /* "pyreadstat/_readstat_parser.pyx":498 * col_format_original = var_format * file_format = dc.file_format * dc.col_formats_original.append(col_format_original) # <<<<<<<<<<<<<< * col_format_final = transform_variable_format(col_format_original, file_format) * dc.col_formats.append(col_format_final) */ if (unlikely(__pyx_v_dc->col_formats_original == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 498, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_dc->col_formats_original, __pyx_v_col_format_original); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 498, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":499 * file_format = dc.file_format * dc.col_formats_original.append(col_format_original) * col_format_final = transform_variable_format(col_format_original, file_format) # <<<<<<<<<<<<<< * dc.col_formats.append(col_format_final) * # readstat type */ __pyx_t_9 = __pyx_f_10pyreadstat_16_readstat_parser_transform_variable_format(__pyx_v_col_format_original, __pyx_v_file_format); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 499, __pyx_L1_error) __pyx_v_col_format_final = __pyx_t_9; /* "pyreadstat/_readstat_parser.pyx":500 * dc.col_formats_original.append(col_format_original) * col_format_final = transform_variable_format(col_format_original, file_format) * dc.col_formats.append(col_format_final) # <<<<<<<<<<<<<< * # readstat type * var_type = readstat_variable_get_type(variable) */ if (unlikely(__pyx_v_dc->col_formats == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 500, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format(__pyx_v_col_format_final); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 500, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_dc->col_formats, __pyx_t_3); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 500, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":502 * dc.col_formats.append(col_format_final) * # readstat type * var_type = readstat_variable_get_type(variable) # <<<<<<<<<<<<<< * dc.col_dtypes.append(var_type) * # equivalent numpy type */ __pyx_v_var_type = readstat_variable_get_type(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":503 * # readstat type * var_type = readstat_variable_get_type(variable) * dc.col_dtypes.append(var_type) # <<<<<<<<<<<<<< * # equivalent numpy type * # if it's a date then we need object */ if (unlikely(__pyx_v_dc->col_dtypes == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 503, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyInt_From_readstat_type_t(__pyx_v_var_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_dc->col_dtypes, __pyx_t_3); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 503, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":506 * # equivalent numpy type * # if it's a date then we need object * if col_format_final != DATE_FORMAT_NOTADATE and dc.no_datetime_conversion == 0: # <<<<<<<<<<<<<< * curnptype = object * else: */ __pyx_t_4 = (__pyx_v_col_format_final != __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE); if (__pyx_t_4) { } else { __pyx_t_2 = __pyx_t_4; goto __pyx_L16_bool_binop_done; } __pyx_t_4 = (__pyx_v_dc->no_datetime_conversion == 0); __pyx_t_2 = __pyx_t_4; __pyx_L16_bool_binop_done:; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":507 * # if it's a date then we need object * if col_format_final != DATE_FORMAT_NOTADATE and dc.no_datetime_conversion == 0: * curnptype = object # <<<<<<<<<<<<<< * else: * curnptype = readstat_to_numpy_types[var_type] */ __Pyx_INCREF(__pyx_builtin_object); __pyx_v_curnptype = __pyx_builtin_object; /* "pyreadstat/_readstat_parser.pyx":506 * # equivalent numpy type * # if it's a date then we need object * if col_format_final != DATE_FORMAT_NOTADATE and dc.no_datetime_conversion == 0: # <<<<<<<<<<<<<< * curnptype = object * else: */ goto __pyx_L15; } /* "pyreadstat/_readstat_parser.pyx":509 * curnptype = object * else: * curnptype = readstat_to_numpy_types[var_type] # <<<<<<<<<<<<<< * iscurnptypefloat = 0 * iscurnptypeobject = 0 */ /*else*/ { if (unlikely(__pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 509, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyInt_From_readstat_type_t(__pyx_v_var_type); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_curnptype = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L15:; /* "pyreadstat/_readstat_parser.pyx":510 * else: * curnptype = readstat_to_numpy_types[var_type] * iscurnptypefloat = 0 # <<<<<<<<<<<<<< * iscurnptypeobject = 0 * # book keeping numpy types */ __pyx_v_iscurnptypefloat = 0; /* "pyreadstat/_readstat_parser.pyx":511 * curnptype = readstat_to_numpy_types[var_type] * iscurnptypefloat = 0 * iscurnptypeobject = 0 # <<<<<<<<<<<<<< * # book keeping numpy types * dc.col_numpy_dtypes[index] = curnptype */ __pyx_v_iscurnptypeobject = 0; /* "pyreadstat/_readstat_parser.pyx":513 * iscurnptypeobject = 0 * # book keeping numpy types * dc.col_numpy_dtypes[index] = curnptype # <<<<<<<<<<<<<< * if curnptype == object: * iscurnptypeobject = 1 */ if (unlikely(__pyx_v_dc->col_numpy_dtypes == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 513, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_numpy_dtypes, __pyx_v_index, __pyx_v_curnptype, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 513, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":514 * # book keeping numpy types * dc.col_numpy_dtypes[index] = curnptype * if curnptype == object: # <<<<<<<<<<<<<< * iscurnptypeobject = 1 * if curnptype == np.float64: */ __pyx_t_1 = PyObject_RichCompare(__pyx_v_curnptype, __pyx_builtin_object, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 514, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 514, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":515 * dc.col_numpy_dtypes[index] = curnptype * if curnptype == object: * iscurnptypeobject = 1 # <<<<<<<<<<<<<< * if curnptype == np.float64: * iscurnptypefloat = 1 */ __pyx_v_iscurnptypeobject = 1; /* "pyreadstat/_readstat_parser.pyx":514 * # book keeping numpy types * dc.col_numpy_dtypes[index] = curnptype * if curnptype == object: # <<<<<<<<<<<<<< * iscurnptypeobject = 1 * if curnptype == np.float64: */ } /* "pyreadstat/_readstat_parser.pyx":516 * if curnptype == object: * iscurnptypeobject = 1 * if curnptype == np.float64: # <<<<<<<<<<<<<< * iscurnptypefloat = 1 * dc.col_dtypes_isobject[index] = iscurnptypeobject */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyObject_RichCompare(__pyx_v_curnptype, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 516, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 516, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":517 * iscurnptypeobject = 1 * if curnptype == np.float64: * iscurnptypefloat = 1 # <<<<<<<<<<<<<< * dc.col_dtypes_isobject[index] = iscurnptypeobject * dc.col_dytpes_isfloat[index] = iscurnptypefloat */ __pyx_v_iscurnptypefloat = 1; /* "pyreadstat/_readstat_parser.pyx":516 * if curnptype == object: * iscurnptypeobject = 1 * if curnptype == np.float64: # <<<<<<<<<<<<<< * iscurnptypefloat = 1 * dc.col_dtypes_isobject[index] = iscurnptypeobject */ } /* "pyreadstat/_readstat_parser.pyx":518 * if curnptype == np.float64: * iscurnptypefloat = 1 * dc.col_dtypes_isobject[index] = iscurnptypeobject # <<<<<<<<<<<<<< * dc.col_dytpes_isfloat[index] = iscurnptypefloat * metaonly = dc.metaonly */ __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_iscurnptypeobject); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_v_dc->col_dtypes_isobject == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 518, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_dtypes_isobject, __pyx_v_index, __pyx_t_1, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 518, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":519 * iscurnptypefloat = 1 * dc.col_dtypes_isobject[index] = iscurnptypeobject * dc.col_dytpes_isfloat[index] = iscurnptypefloat # <<<<<<<<<<<<<< * metaonly = dc.metaonly * # pre-allocate data */ __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_iscurnptypefloat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_v_dc->col_dytpes_isfloat == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 519, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_dytpes_isfloat, __pyx_v_index, __pyx_t_1, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 519, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":520 * dc.col_dtypes_isobject[index] = iscurnptypeobject * dc.col_dytpes_isfloat[index] = iscurnptypefloat * metaonly = dc.metaonly # <<<<<<<<<<<<<< * # pre-allocate data * if metaonly: */ __pyx_t_2 = __pyx_v_dc->metaonly; __pyx_v_metaonly = __pyx_t_2; /* "pyreadstat/_readstat_parser.pyx":522 * metaonly = dc.metaonly * # pre-allocate data * if metaonly: # <<<<<<<<<<<<<< * row = np.empty(1, dtype=curnptype) * else: */ if (__pyx_v_metaonly) { /* "pyreadstat/_readstat_parser.pyx":523 * # pre-allocate data * if metaonly: * row = np.empty(1, dtype=curnptype) # <<<<<<<<<<<<<< * else: * obs_count = dc.n_obs */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_curnptype) < 0) __PYX_ERR(0, 523, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_row = __pyx_t_5; __pyx_t_5 = 0; /* "pyreadstat/_readstat_parser.pyx":522 * metaonly = dc.metaonly * # pre-allocate data * if metaonly: # <<<<<<<<<<<<<< * row = np.empty(1, dtype=curnptype) * else: */ goto __pyx_L20; } /* "pyreadstat/_readstat_parser.pyx":525 * row = np.empty(1, dtype=curnptype) * else: * obs_count = dc.n_obs # <<<<<<<<<<<<<< * row = np.empty(obs_count, dtype=curnptype) * if iscurnptypeobject or iscurnptypefloat: */ /*else*/ { __pyx_t_6 = __pyx_v_dc->n_obs; __pyx_v_obs_count = __pyx_t_6; /* "pyreadstat/_readstat_parser.pyx":526 * else: * obs_count = dc.n_obs * row = np.empty(obs_count, dtype=curnptype) # <<<<<<<<<<<<<< * if iscurnptypeobject or iscurnptypefloat: * row.fill(np.nan) */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_obs_count); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5)) __PYX_ERR(0, 526, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_v_curnptype) < 0) __PYX_ERR(0, 526, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_row = __pyx_t_10; __pyx_t_10 = 0; /* "pyreadstat/_readstat_parser.pyx":527 * obs_count = dc.n_obs * row = np.empty(obs_count, dtype=curnptype) * if iscurnptypeobject or iscurnptypefloat: # <<<<<<<<<<<<<< * row.fill(np.nan) * dc.col_data.append(row) */ if (!__pyx_v_iscurnptypeobject) { } else { __pyx_t_2 = __pyx_v_iscurnptypeobject; goto __pyx_L22_bool_binop_done; } __pyx_t_2 = __pyx_v_iscurnptypefloat; __pyx_L22_bool_binop_done:; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":528 * row = np.empty(obs_count, dtype=curnptype) * if iscurnptypeobject or iscurnptypefloat: * row.fill(np.nan) # <<<<<<<<<<<<<< * dc.col_data.append(row) * */ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s_fill); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_1}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_parser.pyx":527 * obs_count = dc.n_obs * row = np.empty(obs_count, dtype=curnptype) * if iscurnptypeobject or iscurnptypefloat: # <<<<<<<<<<<<<< * row.fill(np.nan) * dc.col_data.append(row) */ } } __pyx_L20:; /* "pyreadstat/_readstat_parser.pyx":529 * if iscurnptypeobject or iscurnptypefloat: * row.fill(np.nan) * dc.col_data.append(row) # <<<<<<<<<<<<<< * * # missing values */ if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 529, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_dc->col_data, __pyx_v_row); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 529, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":532 * * # missing values * if dc.usernan: # <<<<<<<<<<<<<< * n_ranges = readstat_variable_get_missing_ranges_count(variable) * if n_ranges>0: */ if (__pyx_v_dc->usernan) { /* "pyreadstat/_readstat_parser.pyx":533 * # missing values * if dc.usernan: * n_ranges = readstat_variable_get_missing_ranges_count(variable) # <<<<<<<<<<<<<< * if n_ranges>0: * missing_ranges = list() */ __pyx_v_n_ranges = readstat_variable_get_missing_ranges_count(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":534 * if dc.usernan: * n_ranges = readstat_variable_get_missing_ranges_count(variable) * if n_ranges>0: # <<<<<<<<<<<<<< * missing_ranges = list() * for i in range(0, n_ranges): */ __pyx_t_2 = (__pyx_v_n_ranges > 0); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":535 * n_ranges = readstat_variable_get_missing_ranges_count(variable) * if n_ranges>0: * missing_ranges = list() # <<<<<<<<<<<<<< * for i in range(0, n_ranges): * loval = readstat_variable_get_missing_range_lo(variable, i) */ __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 535, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_missing_ranges = ((PyObject*)__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_parser.pyx":536 * if n_ranges>0: * missing_ranges = list() * for i in range(0, n_ranges): # <<<<<<<<<<<<<< * loval = readstat_variable_get_missing_range_lo(variable, i) * pyloval = convert_readstat_to_python_value(loval, index, dc) */ __pyx_t_6 = __pyx_v_n_ranges; __pyx_t_11 = __pyx_t_6; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_i = __pyx_t_12; /* "pyreadstat/_readstat_parser.pyx":537 * missing_ranges = list() * for i in range(0, n_ranges): * loval = readstat_variable_get_missing_range_lo(variable, i) # <<<<<<<<<<<<<< * pyloval = convert_readstat_to_python_value(loval, index, dc) * hival = readstat_variable_get_missing_range_hi(variable, i) */ __pyx_v_loval = readstat_variable_get_missing_range_lo(__pyx_v_variable, __pyx_v_i); /* "pyreadstat/_readstat_parser.pyx":538 * for i in range(0, n_ranges): * loval = readstat_variable_get_missing_range_lo(variable, i) * pyloval = convert_readstat_to_python_value(loval, index, dc) # <<<<<<<<<<<<<< * hival = readstat_variable_get_missing_range_hi(variable, i) * pyhival = convert_readstat_to_python_value(hival, index, dc) */ __pyx_t_10 = __pyx_f_10pyreadstat_16_readstat_parser_convert_readstat_to_python_value(__pyx_v_loval, __pyx_v_index, __pyx_v_dc); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_v_pyloval, __pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_parser.pyx":539 * loval = readstat_variable_get_missing_range_lo(variable, i) * pyloval = convert_readstat_to_python_value(loval, index, dc) * hival = readstat_variable_get_missing_range_hi(variable, i) # <<<<<<<<<<<<<< * pyhival = convert_readstat_to_python_value(hival, index, dc) * missing_ranges.append({'lo':pyloval, 'hi':pyhival}) */ __pyx_v_hival = readstat_variable_get_missing_range_hi(__pyx_v_variable, __pyx_v_i); /* "pyreadstat/_readstat_parser.pyx":540 * pyloval = convert_readstat_to_python_value(loval, index, dc) * hival = readstat_variable_get_missing_range_hi(variable, i) * pyhival = convert_readstat_to_python_value(hival, index, dc) # <<<<<<<<<<<<<< * missing_ranges.append({'lo':pyloval, 'hi':pyhival}) * dc.missing_ranges[col_name] = missing_ranges */ __pyx_t_10 = __pyx_f_10pyreadstat_16_readstat_parser_convert_readstat_to_python_value(__pyx_v_hival, __pyx_v_index, __pyx_v_dc); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 540, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_v_pyhival, __pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_parser.pyx":541 * hival = readstat_variable_get_missing_range_hi(variable, i) * pyhival = convert_readstat_to_python_value(hival, index, dc) * missing_ranges.append({'lo':pyloval, 'hi':pyhival}) # <<<<<<<<<<<<<< * dc.missing_ranges[col_name] = missing_ranges * */ __pyx_t_10 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_lo, __pyx_v_pyloval) < 0) __PYX_ERR(0, 541, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_hi, __pyx_v_pyhival) < 0) __PYX_ERR(0, 541, __pyx_L1_error) __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_missing_ranges, __pyx_t_10); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 541, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } /* "pyreadstat/_readstat_parser.pyx":542 * pyhival = convert_readstat_to_python_value(hival, index, dc) * missing_ranges.append({'lo':pyloval, 'hi':pyhival}) * dc.missing_ranges[col_name] = missing_ranges # <<<<<<<<<<<<<< * * cdef size_t storage_width */ if (unlikely(__pyx_v_dc->missing_ranges == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 542, __pyx_L1_error) } if (unlikely((PyDict_SetItem(__pyx_v_dc->missing_ranges, __pyx_v_col_name, __pyx_v_missing_ranges) < 0))) __PYX_ERR(0, 542, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":534 * if dc.usernan: * n_ranges = readstat_variable_get_missing_ranges_count(variable) * if n_ranges>0: # <<<<<<<<<<<<<< * missing_ranges = list() * for i in range(0, n_ranges): */ } /* "pyreadstat/_readstat_parser.pyx":532 * * # missing values * if dc.usernan: # <<<<<<<<<<<<<< * n_ranges = readstat_variable_get_missing_ranges_count(variable) * if n_ranges>0: */ } /* "pyreadstat/_readstat_parser.pyx":545 * * cdef size_t storage_width * storage_width = readstat_variable_get_storage_width(variable) # <<<<<<<<<<<<<< * dc.variable_storage_width[col_name] = storage_width * */ __pyx_v_storage_width = readstat_variable_get_storage_width(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":546 * cdef size_t storage_width * storage_width = readstat_variable_get_storage_width(variable) * dc.variable_storage_width[col_name] = storage_width # <<<<<<<<<<<<<< * * dc.variable_display_width[col_name] = readstat_variable_get_display_width(variable) */ __pyx_t_10 = __Pyx_PyInt_From_int(((int)__pyx_v_storage_width)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (unlikely(__pyx_v_dc->variable_storage_width == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 546, __pyx_L1_error) } if (unlikely((PyDict_SetItem(__pyx_v_dc->variable_storage_width, __pyx_v_col_name, __pyx_t_10) < 0))) __PYX_ERR(0, 546, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_parser.pyx":548 * dc.variable_storage_width[col_name] = storage_width * * dc.variable_display_width[col_name] = readstat_variable_get_display_width(variable) # <<<<<<<<<<<<<< * * cdef readstat_alignment_t align */ __pyx_t_10 = __Pyx_PyInt_From_int(readstat_variable_get_display_width(__pyx_v_variable)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 548, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (unlikely((PyObject_SetItem(__pyx_v_dc->variable_display_width, __pyx_v_col_name, __pyx_t_10) < 0))) __PYX_ERR(0, 548, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_parser.pyx":552 * cdef readstat_alignment_t align * cdef str pyalign * align = readstat_variable_get_alignment(variable) # <<<<<<<<<<<<<< * if align == READSTAT_ALIGNMENT_UNKNOWN: * pyalign = "unknown" */ __pyx_v_align = readstat_variable_get_alignment(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":553 * cdef str pyalign * align = readstat_variable_get_alignment(variable) * if align == READSTAT_ALIGNMENT_UNKNOWN: # <<<<<<<<<<<<<< * pyalign = "unknown" * elif align == READSTAT_ALIGNMENT_LEFT: */ switch (__pyx_v_align) { case READSTAT_ALIGNMENT_UNKNOWN: /* "pyreadstat/_readstat_parser.pyx":554 * align = readstat_variable_get_alignment(variable) * if align == READSTAT_ALIGNMENT_UNKNOWN: * pyalign = "unknown" # <<<<<<<<<<<<<< * elif align == READSTAT_ALIGNMENT_LEFT: * pyalign = "left" */ __Pyx_INCREF(__pyx_n_s_unknown); __pyx_v_pyalign = __pyx_n_s_unknown; /* "pyreadstat/_readstat_parser.pyx":553 * cdef str pyalign * align = readstat_variable_get_alignment(variable) * if align == READSTAT_ALIGNMENT_UNKNOWN: # <<<<<<<<<<<<<< * pyalign = "unknown" * elif align == READSTAT_ALIGNMENT_LEFT: */ break; case READSTAT_ALIGNMENT_LEFT: /* "pyreadstat/_readstat_parser.pyx":556 * pyalign = "unknown" * elif align == READSTAT_ALIGNMENT_LEFT: * pyalign = "left" # <<<<<<<<<<<<<< * elif align == READSTAT_ALIGNMENT_CENTER: * pyalign = "center" */ __Pyx_INCREF(__pyx_n_s_left); __pyx_v_pyalign = __pyx_n_s_left; /* "pyreadstat/_readstat_parser.pyx":555 * if align == READSTAT_ALIGNMENT_UNKNOWN: * pyalign = "unknown" * elif align == READSTAT_ALIGNMENT_LEFT: # <<<<<<<<<<<<<< * pyalign = "left" * elif align == READSTAT_ALIGNMENT_CENTER: */ break; case READSTAT_ALIGNMENT_CENTER: /* "pyreadstat/_readstat_parser.pyx":558 * pyalign = "left" * elif align == READSTAT_ALIGNMENT_CENTER: * pyalign = "center" # <<<<<<<<<<<<<< * elif align == READSTAT_ALIGNMENT_RIGHT: * pyalign = "right" */ __Pyx_INCREF(__pyx_n_s_center); __pyx_v_pyalign = __pyx_n_s_center; /* "pyreadstat/_readstat_parser.pyx":557 * elif align == READSTAT_ALIGNMENT_LEFT: * pyalign = "left" * elif align == READSTAT_ALIGNMENT_CENTER: # <<<<<<<<<<<<<< * pyalign = "center" * elif align == READSTAT_ALIGNMENT_RIGHT: */ break; case READSTAT_ALIGNMENT_RIGHT: /* "pyreadstat/_readstat_parser.pyx":560 * pyalign = "center" * elif align == READSTAT_ALIGNMENT_RIGHT: * pyalign = "right" # <<<<<<<<<<<<<< * else: * pyalign = "undetermined" */ __Pyx_INCREF(__pyx_n_s_right); __pyx_v_pyalign = __pyx_n_s_right; /* "pyreadstat/_readstat_parser.pyx":559 * elif align == READSTAT_ALIGNMENT_CENTER: * pyalign = "center" * elif align == READSTAT_ALIGNMENT_RIGHT: # <<<<<<<<<<<<<< * pyalign = "right" * else: */ break; default: /* "pyreadstat/_readstat_parser.pyx":562 * pyalign = "right" * else: * pyalign = "undetermined" # <<<<<<<<<<<<<< * * dc.variable_alignment[col_name] = pyalign */ __Pyx_INCREF(__pyx_n_s_undetermined); __pyx_v_pyalign = __pyx_n_s_undetermined; break; } /* "pyreadstat/_readstat_parser.pyx":564 * pyalign = "undetermined" * * dc.variable_alignment[col_name] = pyalign # <<<<<<<<<<<<<< * * cdef readstat_measure_t measure */ if (unlikely((PyObject_SetItem(__pyx_v_dc->variable_alignment, __pyx_v_col_name, __pyx_v_pyalign) < 0))) __PYX_ERR(0, 564, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":568 * cdef readstat_measure_t measure * cdef str pymeasure * measure = readstat_variable_get_measure(variable) # <<<<<<<<<<<<<< * if measure == READSTAT_MEASURE_UNKNOWN: * pymeasure = "unknown" */ __pyx_v_measure = readstat_variable_get_measure(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":569 * cdef str pymeasure * measure = readstat_variable_get_measure(variable) * if measure == READSTAT_MEASURE_UNKNOWN: # <<<<<<<<<<<<<< * pymeasure = "unknown" * elif measure == READSTAT_MEASURE_NOMINAL: */ switch (__pyx_v_measure) { case READSTAT_MEASURE_UNKNOWN: /* "pyreadstat/_readstat_parser.pyx":570 * measure = readstat_variable_get_measure(variable) * if measure == READSTAT_MEASURE_UNKNOWN: * pymeasure = "unknown" # <<<<<<<<<<<<<< * elif measure == READSTAT_MEASURE_NOMINAL: * pymeasure = "nominal" */ __Pyx_INCREF(__pyx_n_s_unknown); __pyx_v_pymeasure = __pyx_n_s_unknown; /* "pyreadstat/_readstat_parser.pyx":569 * cdef str pymeasure * measure = readstat_variable_get_measure(variable) * if measure == READSTAT_MEASURE_UNKNOWN: # <<<<<<<<<<<<<< * pymeasure = "unknown" * elif measure == READSTAT_MEASURE_NOMINAL: */ break; case READSTAT_MEASURE_NOMINAL: /* "pyreadstat/_readstat_parser.pyx":572 * pymeasure = "unknown" * elif measure == READSTAT_MEASURE_NOMINAL: * pymeasure = "nominal" # <<<<<<<<<<<<<< * elif measure == READSTAT_MEASURE_ORDINAL: * pymeasure = "ordinal" */ __Pyx_INCREF(__pyx_n_s_nominal); __pyx_v_pymeasure = __pyx_n_s_nominal; /* "pyreadstat/_readstat_parser.pyx":571 * if measure == READSTAT_MEASURE_UNKNOWN: * pymeasure = "unknown" * elif measure == READSTAT_MEASURE_NOMINAL: # <<<<<<<<<<<<<< * pymeasure = "nominal" * elif measure == READSTAT_MEASURE_ORDINAL: */ break; case READSTAT_MEASURE_ORDINAL: /* "pyreadstat/_readstat_parser.pyx":574 * pymeasure = "nominal" * elif measure == READSTAT_MEASURE_ORDINAL: * pymeasure = "ordinal" # <<<<<<<<<<<<<< * elif measure == READSTAT_MEASURE_SCALE: * pymeasure = "scale" */ __Pyx_INCREF(__pyx_n_s_ordinal); __pyx_v_pymeasure = __pyx_n_s_ordinal; /* "pyreadstat/_readstat_parser.pyx":573 * elif measure == READSTAT_MEASURE_NOMINAL: * pymeasure = "nominal" * elif measure == READSTAT_MEASURE_ORDINAL: # <<<<<<<<<<<<<< * pymeasure = "ordinal" * elif measure == READSTAT_MEASURE_SCALE: */ break; case READSTAT_MEASURE_SCALE: /* "pyreadstat/_readstat_parser.pyx":576 * pymeasure = "ordinal" * elif measure == READSTAT_MEASURE_SCALE: * pymeasure = "scale" # <<<<<<<<<<<<<< * else: * pymeasure = "undetermined" */ __Pyx_INCREF(__pyx_n_s_scale); __pyx_v_pymeasure = __pyx_n_s_scale; /* "pyreadstat/_readstat_parser.pyx":575 * elif measure == READSTAT_MEASURE_ORDINAL: * pymeasure = "ordinal" * elif measure == READSTAT_MEASURE_SCALE: # <<<<<<<<<<<<<< * pymeasure = "scale" * else: */ break; default: /* "pyreadstat/_readstat_parser.pyx":578 * pymeasure = "scale" * else: * pymeasure = "undetermined" # <<<<<<<<<<<<<< * * dc.variable_measure[col_name] = pymeasure */ __Pyx_INCREF(__pyx_n_s_undetermined); __pyx_v_pymeasure = __pyx_n_s_undetermined; break; } /* "pyreadstat/_readstat_parser.pyx":580 * pymeasure = "undetermined" * * dc.variable_measure[col_name] = pymeasure # <<<<<<<<<<<<<< * * return READSTAT_HANDLER_OK */ if (unlikely((PyObject_SetItem(__pyx_v_dc->variable_measure, __pyx_v_col_name, __pyx_v_pymeasure) < 0))) __PYX_ERR(0, 580, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":582 * dc.variable_measure[col_name] = pymeasure * * return READSTAT_HANDLER_OK # <<<<<<<<<<<<<< * * */ __pyx_r = READSTAT_HANDLER_OK; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":418 * return READSTAT_HANDLER_OK * * cdef int handle_variable(int index, readstat_variable_t *variable, # <<<<<<<<<<<<<< * char *val_labels, void *ctx) except READSTAT_HANDLER_ABORT: * """ */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("pyreadstat._readstat_parser.handle_variable", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = READSTAT_HANDLER_ABORT; __pyx_L0:; __Pyx_XDECREF(__pyx_v_col_name); __Pyx_XDECREF(__pyx_v_col_label); __Pyx_XDECREF(__pyx_v_label_name); __Pyx_XDECREF(__pyx_v_col_format_original); __Pyx_XDECREF(__pyx_v_pyloval); __Pyx_XDECREF(__pyx_v_pyhival); __Pyx_XDECREF(__pyx_v_missing_ranges); __Pyx_XDECREF(__pyx_v_curnptype); __Pyx_XDECREF(__pyx_v_row); __Pyx_XDECREF(__pyx_v_newcolname); __Pyx_XDECREF((PyObject *)__pyx_v_dc); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_pyalign); __Pyx_XDECREF(__pyx_v_pymeasure); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":585 * * * cdef int handle_value(int obs_index, readstat_variable_t * variable, readstat_value_t value, void *ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * This function transforms every value to python types, and to datetime if */ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_value(int __pyx_v_obs_index, readstat_variable_t *__pyx_v_variable, readstat_value_t __pyx_v_value, void *__pyx_v_ctx) { struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_dc = 0; int __pyx_v_index; int __pyx_v_max_n_obs; int __pyx_v_is_unkown_number_rows; int __pyx_v_var_max_rows; PyObject *__pyx_v_buf_list = 0; int __pyx_v_iscurnptypeobject; int __pyx_v_iscurnptypefloat; int __pyx_v_missing_tag; PyObject *__pyx_v_pyvalue = 0; PyObject *__pyx_v_curset = 0; PyObject *__pyx_v_curnptype = 0; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_value", 1); /* "pyreadstat/_readstat_parser.pyx":607 * * # extract variables we need from data container * dc = ctx # <<<<<<<<<<<<<< * index = readstat_variable_get_index_after_skipping(variable) * max_n_obs = dc.max_n_obs */ __pyx_t_1 = ((PyObject *)__pyx_v_ctx); __Pyx_INCREF(__pyx_t_1); __pyx_v_dc = ((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":608 * # extract variables we need from data container * dc = ctx * index = readstat_variable_get_index_after_skipping(variable) # <<<<<<<<<<<<<< * max_n_obs = dc.max_n_obs * is_unkown_number_rows = dc.is_unkown_number_rows */ __pyx_v_index = readstat_variable_get_index_after_skipping(__pyx_v_variable); /* "pyreadstat/_readstat_parser.pyx":609 * dc = ctx * index = readstat_variable_get_index_after_skipping(variable) * max_n_obs = dc.max_n_obs # <<<<<<<<<<<<<< * is_unkown_number_rows = dc.is_unkown_number_rows * */ __pyx_t_2 = __pyx_v_dc->max_n_obs; __pyx_v_max_n_obs = __pyx_t_2; /* "pyreadstat/_readstat_parser.pyx":610 * index = readstat_variable_get_index_after_skipping(variable) * max_n_obs = dc.max_n_obs * is_unkown_number_rows = dc.is_unkown_number_rows # <<<<<<<<<<<<<< * * # check that we still have enough room in our pre-allocated lists */ __pyx_t_3 = __pyx_v_dc->is_unkown_number_rows; __pyx_v_is_unkown_number_rows = __pyx_t_3; /* "pyreadstat/_readstat_parser.pyx":614 * # check that we still have enough room in our pre-allocated lists * # if not, add more room * iscurnptypeobject = dc.col_dtypes_isobject[index] # <<<<<<<<<<<<<< * iscurnptypefloat = dc.col_dytpes_isfloat[index] * if is_unkown_number_rows: */ if (unlikely(__pyx_v_dc->col_dtypes_isobject == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 614, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_dtypes_isobject, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_iscurnptypeobject = __pyx_t_3; /* "pyreadstat/_readstat_parser.pyx":615 * # if not, add more room * iscurnptypeobject = dc.col_dtypes_isobject[index] * iscurnptypefloat = dc.col_dytpes_isfloat[index] # <<<<<<<<<<<<<< * if is_unkown_number_rows: * if max_n_obs <= obs_index: */ if (unlikely(__pyx_v_dc->col_dytpes_isfloat == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 615, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_dytpes_isfloat, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_iscurnptypefloat = __pyx_t_3; /* "pyreadstat/_readstat_parser.pyx":616 * iscurnptypeobject = dc.col_dtypes_isobject[index] * iscurnptypefloat = dc.col_dytpes_isfloat[index] * if is_unkown_number_rows: # <<<<<<<<<<<<<< * if max_n_obs <= obs_index: * dc.max_n_obs = obs_index + 1 */ if (__pyx_v_is_unkown_number_rows) { /* "pyreadstat/_readstat_parser.pyx":617 * iscurnptypefloat = dc.col_dytpes_isfloat[index] * if is_unkown_number_rows: * if max_n_obs <= obs_index: # <<<<<<<<<<<<<< * dc.max_n_obs = obs_index + 1 * var_max_rows = dc.col_data_len[index] */ __pyx_t_3 = (__pyx_v_max_n_obs <= __pyx_v_obs_index); if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":618 * if is_unkown_number_rows: * if max_n_obs <= obs_index: * dc.max_n_obs = obs_index + 1 # <<<<<<<<<<<<<< * var_max_rows = dc.col_data_len[index] * if var_max_rows <= obs_index: */ __pyx_v_dc->max_n_obs = (__pyx_v_obs_index + 1); /* "pyreadstat/_readstat_parser.pyx":617 * iscurnptypefloat = dc.col_dytpes_isfloat[index] * if is_unkown_number_rows: * if max_n_obs <= obs_index: # <<<<<<<<<<<<<< * dc.max_n_obs = obs_index + 1 * var_max_rows = dc.col_data_len[index] */ } /* "pyreadstat/_readstat_parser.pyx":619 * if max_n_obs <= obs_index: * dc.max_n_obs = obs_index + 1 * var_max_rows = dc.col_data_len[index] # <<<<<<<<<<<<<< * if var_max_rows <= obs_index: * curnptype = dc.col_numpy_dtypes[index] */ if (unlikely(__pyx_v_dc->col_data_len == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 619, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data_len, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_var_max_rows = __pyx_t_2; /* "pyreadstat/_readstat_parser.pyx":620 * dc.max_n_obs = obs_index + 1 * var_max_rows = dc.col_data_len[index] * if var_max_rows <= obs_index: # <<<<<<<<<<<<<< * curnptype = dc.col_numpy_dtypes[index] * buf_list = np.empty(100000, dtype=curnptype) */ __pyx_t_3 = (__pyx_v_var_max_rows <= __pyx_v_obs_index); if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":621 * var_max_rows = dc.col_data_len[index] * if var_max_rows <= obs_index: * curnptype = dc.col_numpy_dtypes[index] # <<<<<<<<<<<<<< * buf_list = np.empty(100000, dtype=curnptype) * if iscurnptypeobject or iscurnptypefloat: */ if (unlikely(__pyx_v_dc->col_numpy_dtypes == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 621, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_numpy_dtypes, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_curnptype = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":622 * if var_max_rows <= obs_index: * curnptype = dc.col_numpy_dtypes[index] * buf_list = np.empty(100000, dtype=curnptype) # <<<<<<<<<<<<<< * if iscurnptypeobject or iscurnptypefloat: * buf_list.fill(np.nan) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_v_curnptype) < 0) __PYX_ERR(0, 622, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_buf_list = __pyx_t_5; __pyx_t_5 = 0; /* "pyreadstat/_readstat_parser.pyx":623 * curnptype = dc.col_numpy_dtypes[index] * buf_list = np.empty(100000, dtype=curnptype) * if iscurnptypeobject or iscurnptypefloat: # <<<<<<<<<<<<<< * buf_list.fill(np.nan) * dc.col_data[index] = np.append(dc.col_data[index], buf_list) */ if (!__pyx_v_iscurnptypeobject) { } else { __pyx_t_3 = __pyx_v_iscurnptypeobject; goto __pyx_L7_bool_binop_done; } __pyx_t_3 = __pyx_v_iscurnptypefloat; __pyx_L7_bool_binop_done:; if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":624 * buf_list = np.empty(100000, dtype=curnptype) * if iscurnptypeobject or iscurnptypefloat: * buf_list.fill(np.nan) # <<<<<<<<<<<<<< * dc.col_data[index] = np.append(dc.col_data[index], buf_list) * var_max_rows += 100000 */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf_list, __pyx_n_s_fill); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_2 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_2 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_6}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_2, 1+__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/_readstat_parser.pyx":623 * curnptype = dc.col_numpy_dtypes[index] * buf_list = np.empty(100000, dtype=curnptype) * if iscurnptypeobject or iscurnptypefloat: # <<<<<<<<<<<<<< * buf_list.fill(np.nan) * dc.col_data[index] = np.append(dc.col_data[index], buf_list) */ } /* "pyreadstat/_readstat_parser.pyx":625 * if iscurnptypeobject or iscurnptypefloat: * buf_list.fill(np.nan) * dc.col_data[index] = np.append(dc.col_data[index], buf_list) # <<<<<<<<<<<<<< * var_max_rows += 100000 * dc.col_data_len[index] = var_max_rows */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_append); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 625, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_2 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_2 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_t_1, __pyx_v_buf_list}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_2, 2+__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 625, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_data, __pyx_v_index, __pyx_t_5, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 625, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/_readstat_parser.pyx":626 * buf_list.fill(np.nan) * dc.col_data[index] = np.append(dc.col_data[index], buf_list) * var_max_rows += 100000 # <<<<<<<<<<<<<< * dc.col_data_len[index] = var_max_rows * */ __pyx_v_var_max_rows = (__pyx_v_var_max_rows + 0x186A0); /* "pyreadstat/_readstat_parser.pyx":627 * dc.col_data[index] = np.append(dc.col_data[index], buf_list) * var_max_rows += 100000 * dc.col_data_len[index] = var_max_rows # <<<<<<<<<<<<<< * * # transform to python value types */ __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_var_max_rows); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 627, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(__pyx_v_dc->col_data_len == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 627, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_data_len, __pyx_v_index, __pyx_t_5, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 627, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/_readstat_parser.pyx":620 * dc.max_n_obs = obs_index + 1 * var_max_rows = dc.col_data_len[index] * if var_max_rows <= obs_index: # <<<<<<<<<<<<<< * curnptype = dc.col_numpy_dtypes[index] * buf_list = np.empty(100000, dtype=curnptype) */ } /* "pyreadstat/_readstat_parser.pyx":616 * iscurnptypeobject = dc.col_dtypes_isobject[index] * iscurnptypefloat = dc.col_dytpes_isfloat[index] * if is_unkown_number_rows: # <<<<<<<<<<<<<< * if max_n_obs <= obs_index: * dc.max_n_obs = obs_index + 1 */ } /* "pyreadstat/_readstat_parser.pyx":630 * * # transform to python value types * if readstat_value_is_missing(value, variable): # <<<<<<<<<<<<<< * # The user does not want to retrieve missing values * if not dc.usernan or readstat_value_is_system_missing(value): */ __pyx_t_3 = (readstat_value_is_missing(__pyx_v_value, __pyx_v_variable) != 0); if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":632 * if readstat_value_is_missing(value, variable): * # The user does not want to retrieve missing values * if not dc.usernan or readstat_value_is_system_missing(value): # <<<<<<<<<<<<<< * if iscurnptypefloat == 1 or iscurnptypeobject == 1: * # already allocated */ __pyx_t_7 = (!__pyx_v_dc->usernan); if (!__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L11_bool_binop_done; } __pyx_t_7 = (readstat_value_is_system_missing(__pyx_v_value) != 0); __pyx_t_3 = __pyx_t_7; __pyx_L11_bool_binop_done:; if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":633 * # The user does not want to retrieve missing values * if not dc.usernan or readstat_value_is_system_missing(value): * if iscurnptypefloat == 1 or iscurnptypeobject == 1: # <<<<<<<<<<<<<< * # already allocated * pass */ __pyx_t_7 = (__pyx_v_iscurnptypefloat == 1); if (!__pyx_t_7) { } else { __pyx_t_3 = __pyx_t_7; goto __pyx_L14_bool_binop_done; } __pyx_t_7 = (__pyx_v_iscurnptypeobject == 1); __pyx_t_3 = __pyx_t_7; __pyx_L14_bool_binop_done:; if (__pyx_t_3) { goto __pyx_L13; } /* "pyreadstat/_readstat_parser.pyx":639 * # for any type except float, the numpy type will be object as now we have nans * else: * dc.col_numpy_dtypes[index] = object # <<<<<<<<<<<<<< * dc.col_dtypes_isobject[index] = 1 * iscurnptypeobject = 1 */ /*else*/ { if (unlikely(__pyx_v_dc->col_numpy_dtypes == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 639, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_numpy_dtypes, __pyx_v_index, __pyx_builtin_object, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 639, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":640 * else: * dc.col_numpy_dtypes[index] = object * dc.col_dtypes_isobject[index] = 1 # <<<<<<<<<<<<<< * iscurnptypeobject = 1 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) */ if (unlikely(__pyx_v_dc->col_dtypes_isobject == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 640, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_dtypes_isobject, __pyx_v_index, __pyx_int_1, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 640, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":641 * dc.col_numpy_dtypes[index] = object * dc.col_dtypes_isobject[index] = 1 * iscurnptypeobject = 1 # <<<<<<<<<<<<<< * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) * dc.col_data[index][obs_index:] = np.nan */ __pyx_v_iscurnptypeobject = 1; /* "pyreadstat/_readstat_parser.pyx":642 * dc.col_dtypes_isobject[index] = 1 * iscurnptypeobject = 1 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) # <<<<<<<<<<<<<< * dc.col_data[index][obs_index:] = np.nan * #dc.col_data[index][obs_index] = NAN */ if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 642, __pyx_L1_error) } __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_astype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 642, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__5, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 642, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_data, __pyx_v_index, __pyx_t_1, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":643 * iscurnptypeobject = 1 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) * dc.col_data[index][obs_index:] = np.nan # <<<<<<<<<<<<<< * #dc.col_data[index][obs_index] = NAN * elif readstat_value_is_defined_missing(value, variable): */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_nan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 643, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_PyObject_SetSlice(__pyx_t_1, __pyx_t_5, __pyx_v_obs_index, 0, NULL, NULL, NULL, 1, 0, 1) < 0) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_L13:; /* "pyreadstat/_readstat_parser.pyx":632 * if readstat_value_is_missing(value, variable): * # The user does not want to retrieve missing values * if not dc.usernan or readstat_value_is_system_missing(value): # <<<<<<<<<<<<<< * if iscurnptypefloat == 1 or iscurnptypeobject == 1: * # already allocated */ goto __pyx_L10; } /* "pyreadstat/_readstat_parser.pyx":645 * dc.col_data[index][obs_index:] = np.nan * #dc.col_data[index][obs_index] = NAN * elif readstat_value_is_defined_missing(value, variable): # <<<<<<<<<<<<<< * # SPSS missing values * pyvalue = convert_readstat_to_python_value(value, index, dc) */ __pyx_t_3 = (readstat_value_is_defined_missing(__pyx_v_value, __pyx_v_variable) != 0); if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":647 * elif readstat_value_is_defined_missing(value, variable): * # SPSS missing values * pyvalue = convert_readstat_to_python_value(value, index, dc) # <<<<<<<<<<<<<< * dc.col_data[index][obs_index] = pyvalue * elif readstat_value_is_tagged_missing(value): */ __pyx_t_5 = __pyx_f_10pyreadstat_16_readstat_parser_convert_readstat_to_python_value(__pyx_v_value, __pyx_v_index, __pyx_v_dc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_pyvalue = __pyx_t_5; __pyx_t_5 = 0; /* "pyreadstat/_readstat_parser.pyx":648 * # SPSS missing values * pyvalue = convert_readstat_to_python_value(value, index, dc) * dc.col_data[index][obs_index] = pyvalue # <<<<<<<<<<<<<< * elif readstat_value_is_tagged_missing(value): * iscurnptypeobject = dc.col_dtypes_isobject[index] */ if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 648, __pyx_L1_error) } __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely((__Pyx_SetItemInt(__pyx_t_5, __pyx_v_obs_index, __pyx_v_pyvalue, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0))) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/_readstat_parser.pyx":645 * dc.col_data[index][obs_index:] = np.nan * #dc.col_data[index][obs_index] = NAN * elif readstat_value_is_defined_missing(value, variable): # <<<<<<<<<<<<<< * # SPSS missing values * pyvalue = convert_readstat_to_python_value(value, index, dc) */ goto __pyx_L10; } /* "pyreadstat/_readstat_parser.pyx":649 * pyvalue = convert_readstat_to_python_value(value, index, dc) * dc.col_data[index][obs_index] = pyvalue * elif readstat_value_is_tagged_missing(value): # <<<<<<<<<<<<<< * iscurnptypeobject = dc.col_dtypes_isobject[index] * # SAS and Stata missing values */ __pyx_t_3 = (readstat_value_is_tagged_missing(__pyx_v_value) != 0); if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":650 * dc.col_data[index][obs_index] = pyvalue * elif readstat_value_is_tagged_missing(value): * iscurnptypeobject = dc.col_dtypes_isobject[index] # <<<<<<<<<<<<<< * # SAS and Stata missing values * missing_tag = readstat_value_tag(value) */ if (unlikely(__pyx_v_dc->col_dtypes_isobject == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 650, __pyx_L1_error) } __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_dc->col_dtypes_isobject, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_iscurnptypeobject = __pyx_t_3; /* "pyreadstat/_readstat_parser.pyx":652 * iscurnptypeobject = dc.col_dtypes_isobject[index] * # SAS and Stata missing values * missing_tag = readstat_value_tag(value) # <<<<<<<<<<<<<< * # In SAS missing values are A to Z or _ in stata a to z * # if (missing_tag >=65 and missing_tag <= 90) or missing_tag == 95 or (missing_tag >=61 and missing_tag <= 122): */ __pyx_v_missing_tag = ((int)readstat_value_tag(__pyx_v_value)); /* "pyreadstat/_readstat_parser.pyx":655 * # In SAS missing values are A to Z or _ in stata a to z * # if (missing_tag >=65 and missing_tag <= 90) or missing_tag == 95 or (missing_tag >=61 and missing_tag <= 122): * if iscurnptypeobject == 1: # <<<<<<<<<<<<<< * dc.col_data[index][obs_index] = chr(missing_tag) * else: */ __pyx_t_3 = (__pyx_v_iscurnptypeobject == 1); if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":656 * # if (missing_tag >=65 and missing_tag <= 90) or missing_tag == 95 or (missing_tag >=61 and missing_tag <= 122): * if iscurnptypeobject == 1: * dc.col_data[index][obs_index] = chr(missing_tag) # <<<<<<<<<<<<<< * else: * dc.col_numpy_dtypes[index] = object */ __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_missing_tag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 656, __pyx_L1_error) } __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely((__Pyx_SetItemInt(__pyx_t_5, __pyx_v_obs_index, __pyx_t_1, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0))) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":655 * # In SAS missing values are A to Z or _ in stata a to z * # if (missing_tag >=65 and missing_tag <= 90) or missing_tag == 95 or (missing_tag >=61 and missing_tag <= 122): * if iscurnptypeobject == 1: # <<<<<<<<<<<<<< * dc.col_data[index][obs_index] = chr(missing_tag) * else: */ goto __pyx_L16; } /* "pyreadstat/_readstat_parser.pyx":658 * dc.col_data[index][obs_index] = chr(missing_tag) * else: * dc.col_numpy_dtypes[index] = object # <<<<<<<<<<<<<< * dc.col_dtypes_isobject[index] = 1 * dc.col_dytpes_isfloat[index] = 0 */ /*else*/ { if (unlikely(__pyx_v_dc->col_numpy_dtypes == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 658, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_numpy_dtypes, __pyx_v_index, __pyx_builtin_object, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 658, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":659 * else: * dc.col_numpy_dtypes[index] = object * dc.col_dtypes_isobject[index] = 1 # <<<<<<<<<<<<<< * dc.col_dytpes_isfloat[index] = 0 * iscurnptypeobject = 1 */ if (unlikely(__pyx_v_dc->col_dtypes_isobject == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 659, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_dtypes_isobject, __pyx_v_index, __pyx_int_1, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 659, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":660 * dc.col_numpy_dtypes[index] = object * dc.col_dtypes_isobject[index] = 1 * dc.col_dytpes_isfloat[index] = 0 # <<<<<<<<<<<<<< * iscurnptypeobject = 1 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) */ if (unlikely(__pyx_v_dc->col_dytpes_isfloat == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 660, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_dytpes_isfloat, __pyx_v_index, __pyx_int_0, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 660, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":661 * dc.col_dtypes_isobject[index] = 1 * dc.col_dytpes_isfloat[index] = 0 * iscurnptypeobject = 1 # <<<<<<<<<<<<<< * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) * dc.col_data[index][obs_index] = chr(missing_tag) */ __pyx_v_iscurnptypeobject = 1; /* "pyreadstat/_readstat_parser.pyx":662 * dc.col_dytpes_isfloat[index] = 0 * iscurnptypeobject = 1 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) # <<<<<<<<<<<<<< * dc.col_data[index][obs_index] = chr(missing_tag) * curset = dc.missing_user_values.get(index) */ if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 662, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_copy, Py_False) < 0) __PYX_ERR(0, 662, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__6, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 662, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_v_dc->col_data, __pyx_v_index, __pyx_t_6, int, 1, __Pyx_PyInt_From_int, 1, 1, 1) < 0))) __PYX_ERR(0, 662, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":663 * iscurnptypeobject = 1 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) * dc.col_data[index][obs_index] = chr(missing_tag) # <<<<<<<<<<<<<< * curset = dc.missing_user_values.get(index) * if curset is None: */ __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_missing_tag); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 663, __pyx_L1_error) } __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely((__Pyx_SetItemInt(__pyx_t_6, __pyx_v_obs_index, __pyx_t_1, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0))) __PYX_ERR(0, 663, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L16:; /* "pyreadstat/_readstat_parser.pyx":664 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) * dc.col_data[index][obs_index] = chr(missing_tag) * curset = dc.missing_user_values.get(index) # <<<<<<<<<<<<<< * if curset is None: * curset = set() */ if (unlikely(__pyx_v_dc->missing_user_values == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 664, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyDict_GetItemDefault(__pyx_v_dc->missing_user_values, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(PySet_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("set", __pyx_t_6))) __PYX_ERR(0, 664, __pyx_L1_error) __pyx_v_curset = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":665 * dc.col_data[index][obs_index] = chr(missing_tag) * curset = dc.missing_user_values.get(index) * if curset is None: # <<<<<<<<<<<<<< * curset = set() * curset.add(chr(missing_tag)) */ __pyx_t_3 = (__pyx_v_curset == ((PyObject*)Py_None)); if (__pyx_t_3) { /* "pyreadstat/_readstat_parser.pyx":666 * curset = dc.missing_user_values.get(index) * if curset is None: * curset = set() # <<<<<<<<<<<<<< * curset.add(chr(missing_tag)) * dc.missing_user_values[index] = curset */ __pyx_t_6 = PySet_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF_SET(__pyx_v_curset, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":665 * dc.col_data[index][obs_index] = chr(missing_tag) * curset = dc.missing_user_values.get(index) * if curset is None: # <<<<<<<<<<<<<< * curset = set() * curset.add(chr(missing_tag)) */ } /* "pyreadstat/_readstat_parser.pyx":667 * if curset is None: * curset = set() * curset.add(chr(missing_tag)) # <<<<<<<<<<<<<< * dc.missing_user_values[index] = curset * else: */ if (unlikely(__pyx_v_curset == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "add"); __PYX_ERR(0, 667, __pyx_L1_error) } __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_missing_tag); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_8 = PySet_Add(__pyx_v_curset, __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 667, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":668 * curset = set() * curset.add(chr(missing_tag)) * dc.missing_user_values[index] = curset # <<<<<<<<<<<<<< * else: * pyvalue = convert_readstat_to_python_value(value, index, dc) */ if (unlikely(__pyx_v_dc->missing_user_values == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 668, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely((PyDict_SetItem(__pyx_v_dc->missing_user_values, __pyx_t_1, __pyx_v_curset) < 0))) __PYX_ERR(0, 668, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":649 * pyvalue = convert_readstat_to_python_value(value, index, dc) * dc.col_data[index][obs_index] = pyvalue * elif readstat_value_is_tagged_missing(value): # <<<<<<<<<<<<<< * iscurnptypeobject = dc.col_dtypes_isobject[index] * # SAS and Stata missing values */ } __pyx_L10:; /* "pyreadstat/_readstat_parser.pyx":630 * * # transform to python value types * if readstat_value_is_missing(value, variable): # <<<<<<<<<<<<<< * # The user does not want to retrieve missing values * if not dc.usernan or readstat_value_is_system_missing(value): */ goto __pyx_L9; } /* "pyreadstat/_readstat_parser.pyx":670 * dc.missing_user_values[index] = curset * else: * pyvalue = convert_readstat_to_python_value(value, index, dc) # <<<<<<<<<<<<<< * dc.col_data[index][obs_index] = pyvalue * */ /*else*/ { __pyx_t_1 = __pyx_f_10pyreadstat_16_readstat_parser_convert_readstat_to_python_value(__pyx_v_value, __pyx_v_index, __pyx_v_dc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 670, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_pyvalue = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":671 * else: * pyvalue = convert_readstat_to_python_value(value, index, dc) * dc.col_data[index][obs_index] = pyvalue # <<<<<<<<<<<<<< * * return READSTAT_HANDLER_OK */ if (unlikely(__pyx_v_dc->col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 671, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_dc->col_data, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely((__Pyx_SetItemInt(__pyx_t_1, __pyx_v_obs_index, __pyx_v_pyvalue, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0))) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L9:; /* "pyreadstat/_readstat_parser.pyx":673 * dc.col_data[index][obs_index] = pyvalue * * return READSTAT_HANDLER_OK # <<<<<<<<<<<<<< * * */ __pyx_r = READSTAT_HANDLER_OK; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":585 * * * cdef int handle_value(int obs_index, readstat_variable_t * variable, readstat_value_t value, void *ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * This function transforms every value to python types, and to datetime if */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("pyreadstat._readstat_parser.handle_value", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = READSTAT_HANDLER_ABORT; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_dc); __Pyx_XDECREF(__pyx_v_buf_list); __Pyx_XDECREF(__pyx_v_pyvalue); __Pyx_XDECREF(__pyx_v_curset); __Pyx_XDECREF(__pyx_v_curnptype); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":676 * * * cdef int handle_value_label(char *val_labels, readstat_value_t value, char *label, void *ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * Reads the label for the value that belongs to the label set val_labels. In Handle variable we need to do a map */ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_value_label(char *__pyx_v_val_labels, readstat_value_t __pyx_v_value, char *__pyx_v_label, void *__pyx_v_ctx) { struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_dc = 0; char *__pyx_v_c_str_value; PyObject *__pyx_v_py_str_value = 0; int8_t __pyx_v_c_int8_value; int16_t __pyx_v_c_int16_value; int32_t __pyx_v_c_int32_value; float __pyx_v_c_float_value; double __pyx_v_c_double_value; long __pyx_v_py_long_value; double __pyx_v_py_float_value; __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format __pyx_v_pyformat; PyObject *__pyx_v_labels_raw = 0; PyObject *__pyx_v_var_label = 0; PyObject *__pyx_v_value_label_name = 0; readstat_type_t __pyx_v_value_type; PyObject *__pyx_v_cur_dict = NULL; int __pyx_v_missing_tag; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_value_label", 1); /* "pyreadstat/_readstat_parser.pyx":682 * """ * * cdef data_container dc = ctx # <<<<<<<<<<<<<< * * cdef char * c_str_value */ __pyx_t_1 = ((PyObject *)__pyx_v_ctx); __Pyx_INCREF(__pyx_t_1); __pyx_v_dc = ((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":700 * cdef str value_label_name * * var_label = val_labels # <<<<<<<<<<<<<< * value_label_name = label * */ __pyx_t_1 = __Pyx_PyStr_FromString(__pyx_v_val_labels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_var_label = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":701 * * var_label = val_labels * value_label_name = label # <<<<<<<<<<<<<< * * cdef readstat_type_t value_type */ __pyx_t_2 = __Pyx_PyStr_FromString(__pyx_v_label); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_value_label_name = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":704 * * cdef readstat_type_t value_type * value_type = readstat_value_type(value) # <<<<<<<<<<<<<< * * labels_raw = dc.labels_raw */ __pyx_v_value_type = readstat_value_type(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":706 * value_type = readstat_value_type(value) * * labels_raw = dc.labels_raw # <<<<<<<<<<<<<< * cur_dict = labels_raw.get(var_label) * if not cur_dict: */ __pyx_t_1 = __pyx_v_dc->labels_raw; __Pyx_INCREF(__pyx_t_1); __pyx_v_labels_raw = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":707 * * labels_raw = dc.labels_raw * cur_dict = labels_raw.get(var_label) # <<<<<<<<<<<<<< * if not cur_dict: * cur_dict = dict() */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_labels_raw, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_var_label}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_cur_dict = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":708 * labels_raw = dc.labels_raw * cur_dict = labels_raw.get(var_label) * if not cur_dict: # <<<<<<<<<<<<<< * cur_dict = dict() * */ __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_cur_dict); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 708, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* "pyreadstat/_readstat_parser.pyx":709 * cur_dict = labels_raw.get(var_label) * if not cur_dict: * cur_dict = dict() # <<<<<<<<<<<<<< * * if readstat_value_is_tagged_missing(value): */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_cur_dict, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":708 * labels_raw = dc.labels_raw * cur_dict = labels_raw.get(var_label) * if not cur_dict: # <<<<<<<<<<<<<< * cur_dict = dict() * */ } /* "pyreadstat/_readstat_parser.pyx":711 * cur_dict = dict() * * if readstat_value_is_tagged_missing(value): # <<<<<<<<<<<<<< * # SAS and Stata missing values * missing_tag = readstat_value_tag(value) */ __pyx_t_6 = (readstat_value_is_tagged_missing(__pyx_v_value) != 0); if (__pyx_t_6) { /* "pyreadstat/_readstat_parser.pyx":713 * if readstat_value_is_tagged_missing(value): * # SAS and Stata missing values * missing_tag = readstat_value_tag(value) # <<<<<<<<<<<<<< * # In SAS missing values are A to Z or _ in stata a to z * cur_dict[chr(missing_tag)] = value_label_name */ __pyx_v_missing_tag = ((int)readstat_value_tag(__pyx_v_value)); /* "pyreadstat/_readstat_parser.pyx":715 * missing_tag = readstat_value_tag(value) * # In SAS missing values are A to Z or _ in stata a to z * cur_dict[chr(missing_tag)] = value_label_name # <<<<<<<<<<<<<< * else: * */ __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_missing_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely((PyObject_SetItem(__pyx_v_cur_dict, __pyx_t_2, __pyx_v_value_label_name) < 0))) __PYX_ERR(0, 715, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":711 * cur_dict = dict() * * if readstat_value_is_tagged_missing(value): # <<<<<<<<<<<<<< * # SAS and Stata missing values * missing_tag = readstat_value_tag(value) */ goto __pyx_L4; } /* "pyreadstat/_readstat_parser.pyx":718 * else: * * if value_type == READSTAT_TYPE_STRING or value_type == READSTAT_TYPE_STRING_REF: # <<<<<<<<<<<<<< * c_str_value = readstat_string_value(value) * py_str_value = c_str_value */ /*else*/ { /* "pyreadstat/_readstat_parser.pyx":738 * py_float_value = c_float_value * pyformat = VAR_FORMAT_FLOAT * elif value_type == READSTAT_TYPE_DOUBLE: # <<<<<<<<<<<<<< * c_double_value = readstat_double_value(value); * py_float_value = c_double_value */ switch (__pyx_v_value_type) { case READSTAT_TYPE_STRING: /* "pyreadstat/_readstat_parser.pyx":718 * else: * * if value_type == READSTAT_TYPE_STRING or value_type == READSTAT_TYPE_STRING_REF: # <<<<<<<<<<<<<< * c_str_value = readstat_string_value(value) * py_str_value = c_str_value */ case READSTAT_TYPE_STRING_REF: /* "pyreadstat/_readstat_parser.pyx":719 * * if value_type == READSTAT_TYPE_STRING or value_type == READSTAT_TYPE_STRING_REF: * c_str_value = readstat_string_value(value) # <<<<<<<<<<<<<< * py_str_value = c_str_value * pyformat = VAR_FORMAT_STRING */ __pyx_v_c_str_value = readstat_string_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":720 * if value_type == READSTAT_TYPE_STRING or value_type == READSTAT_TYPE_STRING_REF: * c_str_value = readstat_string_value(value) * py_str_value = c_str_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_STRING * elif value_type == READSTAT_TYPE_INT8: */ __pyx_t_2 = __Pyx_PyStr_FromString(__pyx_v_c_str_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_py_str_value = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":721 * c_str_value = readstat_string_value(value) * py_str_value = c_str_value * pyformat = VAR_FORMAT_STRING # <<<<<<<<<<<<<< * elif value_type == READSTAT_TYPE_INT8: * c_int8_value = readstat_int8_value(value) */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_STRING; /* "pyreadstat/_readstat_parser.pyx":718 * else: * * if value_type == READSTAT_TYPE_STRING or value_type == READSTAT_TYPE_STRING_REF: # <<<<<<<<<<<<<< * c_str_value = readstat_string_value(value) * py_str_value = c_str_value */ break; case READSTAT_TYPE_INT8: /* "pyreadstat/_readstat_parser.pyx":723 * pyformat = VAR_FORMAT_STRING * elif value_type == READSTAT_TYPE_INT8: * c_int8_value = readstat_int8_value(value) # <<<<<<<<<<<<<< * py_long_value = c_int8_value * pyformat = VAR_FORMAT_LONG */ __pyx_v_c_int8_value = readstat_int8_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":724 * elif value_type == READSTAT_TYPE_INT8: * c_int8_value = readstat_int8_value(value) * py_long_value = c_int8_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_INT16: */ __pyx_v_py_long_value = ((long)__pyx_v_c_int8_value); /* "pyreadstat/_readstat_parser.pyx":725 * c_int8_value = readstat_int8_value(value) * py_long_value = c_int8_value * pyformat = VAR_FORMAT_LONG # <<<<<<<<<<<<<< * elif value_type == READSTAT_TYPE_INT16: * c_int16_value = readstat_int16_value(value) */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG; /* "pyreadstat/_readstat_parser.pyx":722 * py_str_value = c_str_value * pyformat = VAR_FORMAT_STRING * elif value_type == READSTAT_TYPE_INT8: # <<<<<<<<<<<<<< * c_int8_value = readstat_int8_value(value) * py_long_value = c_int8_value */ break; case READSTAT_TYPE_INT16: /* "pyreadstat/_readstat_parser.pyx":727 * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_INT16: * c_int16_value = readstat_int16_value(value) # <<<<<<<<<<<<<< * py_long_value = c_int16_value * pyformat = VAR_FORMAT_LONG */ __pyx_v_c_int16_value = readstat_int16_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":728 * elif value_type == READSTAT_TYPE_INT16: * c_int16_value = readstat_int16_value(value) * py_long_value = c_int16_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_INT32: */ __pyx_v_py_long_value = ((long)__pyx_v_c_int16_value); /* "pyreadstat/_readstat_parser.pyx":729 * c_int16_value = readstat_int16_value(value) * py_long_value = c_int16_value * pyformat = VAR_FORMAT_LONG # <<<<<<<<<<<<<< * elif value_type == READSTAT_TYPE_INT32: * c_int32_value = readstat_int32_value(value) */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG; /* "pyreadstat/_readstat_parser.pyx":726 * py_long_value = c_int8_value * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_INT16: # <<<<<<<<<<<<<< * c_int16_value = readstat_int16_value(value) * py_long_value = c_int16_value */ break; case READSTAT_TYPE_INT32: /* "pyreadstat/_readstat_parser.pyx":731 * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_INT32: * c_int32_value = readstat_int32_value(value) # <<<<<<<<<<<<<< * py_long_value = c_int32_value * pyformat = VAR_FORMAT_LONG */ __pyx_v_c_int32_value = readstat_int32_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":732 * elif value_type == READSTAT_TYPE_INT32: * c_int32_value = readstat_int32_value(value) * py_long_value = c_int32_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_FLOAT: */ __pyx_v_py_long_value = ((long)__pyx_v_c_int32_value); /* "pyreadstat/_readstat_parser.pyx":733 * c_int32_value = readstat_int32_value(value) * py_long_value = c_int32_value * pyformat = VAR_FORMAT_LONG # <<<<<<<<<<<<<< * elif value_type == READSTAT_TYPE_FLOAT: * c_float_value = readstat_float_value(value) */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG; /* "pyreadstat/_readstat_parser.pyx":730 * py_long_value = c_int16_value * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_INT32: # <<<<<<<<<<<<<< * c_int32_value = readstat_int32_value(value) * py_long_value = c_int32_value */ break; case READSTAT_TYPE_FLOAT: /* "pyreadstat/_readstat_parser.pyx":735 * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_FLOAT: * c_float_value = readstat_float_value(value) # <<<<<<<<<<<<<< * py_float_value = c_float_value * pyformat = VAR_FORMAT_FLOAT */ __pyx_v_c_float_value = readstat_float_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":736 * elif value_type == READSTAT_TYPE_FLOAT: * c_float_value = readstat_float_value(value) * py_float_value = c_float_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_FLOAT * elif value_type == READSTAT_TYPE_DOUBLE: */ __pyx_v_py_float_value = ((double)__pyx_v_c_float_value); /* "pyreadstat/_readstat_parser.pyx":737 * c_float_value = readstat_float_value(value) * py_float_value = c_float_value * pyformat = VAR_FORMAT_FLOAT # <<<<<<<<<<<<<< * elif value_type == READSTAT_TYPE_DOUBLE: * c_double_value = readstat_double_value(value); */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT; /* "pyreadstat/_readstat_parser.pyx":734 * py_long_value = c_int32_value * pyformat = VAR_FORMAT_LONG * elif value_type == READSTAT_TYPE_FLOAT: # <<<<<<<<<<<<<< * c_float_value = readstat_float_value(value) * py_float_value = c_float_value */ break; case READSTAT_TYPE_DOUBLE: /* "pyreadstat/_readstat_parser.pyx":739 * pyformat = VAR_FORMAT_FLOAT * elif value_type == READSTAT_TYPE_DOUBLE: * c_double_value = readstat_double_value(value); # <<<<<<<<<<<<<< * py_float_value = c_double_value * pyformat = VAR_FORMAT_FLOAT */ __pyx_v_c_double_value = readstat_double_value(__pyx_v_value); /* "pyreadstat/_readstat_parser.pyx":740 * elif value_type == READSTAT_TYPE_DOUBLE: * c_double_value = readstat_double_value(value); * py_float_value = c_double_value # <<<<<<<<<<<<<< * pyformat = VAR_FORMAT_FLOAT * else: */ __pyx_v_py_float_value = ((double)__pyx_v_c_double_value); /* "pyreadstat/_readstat_parser.pyx":741 * c_double_value = readstat_double_value(value); * py_float_value = c_double_value * pyformat = VAR_FORMAT_FLOAT # <<<<<<<<<<<<<< * else: * raise PyreadstatError("Unkown data type") */ __pyx_v_pyformat = __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT; /* "pyreadstat/_readstat_parser.pyx":738 * py_float_value = c_float_value * pyformat = VAR_FORMAT_FLOAT * elif value_type == READSTAT_TYPE_DOUBLE: # <<<<<<<<<<<<<< * c_double_value = readstat_double_value(value); * py_float_value = c_double_value */ break; default: /* "pyreadstat/_readstat_parser.pyx":743 * pyformat = VAR_FORMAT_FLOAT * else: * raise PyreadstatError("Unkown data type") # <<<<<<<<<<<<<< * * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_kp_s_Unkown_data_type}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 743, __pyx_L1_error) break; } /* "pyreadstat/_readstat_parser.pyx":746 * * * if pyformat == VAR_FORMAT_STRING: # <<<<<<<<<<<<<< * cur_dict[py_str_value] = value_label_name * elif pyformat == VAR_FORMAT_LONG: */ switch (__pyx_v_pyformat) { case __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_STRING: /* "pyreadstat/_readstat_parser.pyx":747 * * if pyformat == VAR_FORMAT_STRING: * cur_dict[py_str_value] = value_label_name # <<<<<<<<<<<<<< * elif pyformat == VAR_FORMAT_LONG: * cur_dict[py_long_value] = value_label_name */ if (unlikely(!__pyx_v_py_str_value)) { __Pyx_RaiseUnboundLocalError("py_str_value"); __PYX_ERR(0, 747, __pyx_L1_error) } if (unlikely((PyObject_SetItem(__pyx_v_cur_dict, __pyx_v_py_str_value, __pyx_v_value_label_name) < 0))) __PYX_ERR(0, 747, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":746 * * * if pyformat == VAR_FORMAT_STRING: # <<<<<<<<<<<<<< * cur_dict[py_str_value] = value_label_name * elif pyformat == VAR_FORMAT_LONG: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG: /* "pyreadstat/_readstat_parser.pyx":749 * cur_dict[py_str_value] = value_label_name * elif pyformat == VAR_FORMAT_LONG: * cur_dict[py_long_value] = value_label_name # <<<<<<<<<<<<<< * elif pyformat == VAR_FORMAT_FLOAT: * cur_dict[py_float_value] = value_label_name */ if (unlikely((__Pyx_SetItemInt(__pyx_v_cur_dict, __pyx_v_py_long_value, __pyx_v_value_label_name, long, 1, __Pyx_PyInt_From_long, 0, 1, 1) < 0))) __PYX_ERR(0, 749, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":748 * if pyformat == VAR_FORMAT_STRING: * cur_dict[py_str_value] = value_label_name * elif pyformat == VAR_FORMAT_LONG: # <<<<<<<<<<<<<< * cur_dict[py_long_value] = value_label_name * elif pyformat == VAR_FORMAT_FLOAT: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT: /* "pyreadstat/_readstat_parser.pyx":751 * cur_dict[py_long_value] = value_label_name * elif pyformat == VAR_FORMAT_FLOAT: * cur_dict[py_float_value] = value_label_name # <<<<<<<<<<<<<< * elif pyformat == VAR_FORMAT_MISSING: * pass */ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_py_float_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely((PyObject_SetItem(__pyx_v_cur_dict, __pyx_t_1, __pyx_v_value_label_name) < 0))) __PYX_ERR(0, 751, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":750 * elif pyformat == VAR_FORMAT_LONG: * cur_dict[py_long_value] = value_label_name * elif pyformat == VAR_FORMAT_FLOAT: # <<<<<<<<<<<<<< * cur_dict[py_float_value] = value_label_name * elif pyformat == VAR_FORMAT_MISSING: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_MISSING: /* "pyreadstat/_readstat_parser.pyx":752 * elif pyformat == VAR_FORMAT_FLOAT: * cur_dict[py_float_value] = value_label_name * elif pyformat == VAR_FORMAT_MISSING: # <<<<<<<<<<<<<< * pass * else: */ break; default: /* "pyreadstat/_readstat_parser.pyx":755 * pass * else: * raise PyreadstatError("Failed convert C to python value") # <<<<<<<<<<<<<< * * dc.labels_raw[var_label] = cur_dict */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_kp_s_Failed_convert_C_to_python_value}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 755, __pyx_L1_error) break; } } __pyx_L4:; /* "pyreadstat/_readstat_parser.pyx":757 * raise PyreadstatError("Failed convert C to python value") * * dc.labels_raw[var_label] = cur_dict # <<<<<<<<<<<<<< * * return READSTAT_HANDLER_OK */ if (unlikely((PyObject_SetItem(__pyx_v_dc->labels_raw, __pyx_v_var_label, __pyx_v_cur_dict) < 0))) __PYX_ERR(0, 757, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":759 * dc.labels_raw[var_label] = cur_dict * * return READSTAT_HANDLER_OK # <<<<<<<<<<<<<< * * cdef int handle_note (int note_index, char *note, void *ctx) except READSTAT_HANDLER_ABORT: */ __pyx_r = READSTAT_HANDLER_OK; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":676 * * * cdef int handle_value_label(char *val_labels, readstat_value_t value, char *label, void *ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * Reads the label for the value that belongs to the label set val_labels. In Handle variable we need to do a map */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("pyreadstat._readstat_parser.handle_value_label", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = READSTAT_HANDLER_ABORT; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_dc); __Pyx_XDECREF(__pyx_v_py_str_value); __Pyx_XDECREF(__pyx_v_labels_raw); __Pyx_XDECREF(__pyx_v_var_label); __Pyx_XDECREF(__pyx_v_value_label_name); __Pyx_XDECREF(__pyx_v_cur_dict); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":761 * return READSTAT_HANDLER_OK * * cdef int handle_note (int note_index, char *note, void *ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * Collects notes (text annotations) attached to the documents. It happens for spss and stata */ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_note(CYTHON_UNUSED int __pyx_v_note_index, char *__pyx_v_note, void *__pyx_v_ctx) { PyObject *__pyx_v_pynote = 0; struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_dc = 0; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_note", 1); /* "pyreadstat/_readstat_parser.pyx":767 * * cdef str pynote * cdef data_container dc = ctx # <<<<<<<<<<<<<< * * pynote = note */ __pyx_t_1 = ((PyObject *)__pyx_v_ctx); __Pyx_INCREF(__pyx_t_1); __pyx_v_dc = ((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":769 * cdef data_container dc = ctx * * pynote = note # <<<<<<<<<<<<<< * dc.notes.append(pynote) * */ __pyx_t_1 = __Pyx_PyStr_FromString(__pyx_v_note); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_pynote = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":770 * * pynote = note * dc.notes.append(pynote) # <<<<<<<<<<<<<< * * return READSTAT_HANDLER_OK */ __pyx_t_3 = __Pyx_PyObject_Append(__pyx_v_dc->notes, __pyx_v_pynote); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 770, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":772 * dc.notes.append(pynote) * * return READSTAT_HANDLER_OK # <<<<<<<<<<<<<< * * cdef int handle_open(const char *u8_path, void *io_ctx) except READSTAT_HANDLER_ABORT: */ __pyx_r = READSTAT_HANDLER_OK; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":761 * return READSTAT_HANDLER_OK * * cdef int handle_note (int note_index, char *note, void *ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * Collects notes (text annotations) attached to the documents. It happens for spss and stata */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("pyreadstat._readstat_parser.handle_note", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = READSTAT_HANDLER_ABORT; __pyx_L0:; __Pyx_XDECREF(__pyx_v_pynote); __Pyx_XDECREF((PyObject *)__pyx_v_dc); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":774 * return READSTAT_HANDLER_OK * * cdef int handle_open(const char *u8_path, void *io_ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * Special open handler for windows in order to be able to handle paths with international characters */ static int __pyx_f_10pyreadstat_16_readstat_parser_handle_open(char const *__pyx_v_u8_path, void *__pyx_v_io_ctx) { int __pyx_v_fd; Py_ssize_t __pyx_v_length; wchar_t *__pyx_v_u16_path; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; wchar_t *__pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("handle_open", 1); /* "pyreadstat/_readstat_parser.pyx":782 * cdef Py_ssize_t length * * if not os.path.isfile(u8_path): # <<<<<<<<<<<<<< * return -1 * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isfile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_FromString(__pyx_v_u8_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 782, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (!__pyx_t_6); if (__pyx_t_7) { /* "pyreadstat/_readstat_parser.pyx":783 * * if not os.path.isfile(u8_path): * return -1 # <<<<<<<<<<<<<< * * if os.name == "nt": */ __pyx_r = -1; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":782 * cdef Py_ssize_t length * * if not os.path.isfile(u8_path): # <<<<<<<<<<<<<< * return -1 * */ } /* "pyreadstat/_readstat_parser.pyx":785 * return -1 * * if os.name == "nt": # <<<<<<<<<<<<<< * u16_path = PyUnicode_AsWideCharString(u8_path, &length) * fd = _wsopen(u16_path, _O_RDONLY | _O_BINARY, _SH_DENYWR, 0) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_nt, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 785, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_7) { /* "pyreadstat/_readstat_parser.pyx":786 * * if os.name == "nt": * u16_path = PyUnicode_AsWideCharString(u8_path, &length) # <<<<<<<<<<<<<< * fd = _wsopen(u16_path, _O_RDONLY | _O_BINARY, _SH_DENYWR, 0) * assign_fd(io_ctx, fd) */ __pyx_t_2 = __Pyx_PyUnicode_FromString(__pyx_v_u8_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyUnicode_AsWideCharString(__pyx_t_2, (&__pyx_v_length)); if (unlikely(__pyx_t_8 == ((wchar_t *)NULL))) __PYX_ERR(0, 786, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_u16_path = __pyx_t_8; /* "pyreadstat/_readstat_parser.pyx":787 * if os.name == "nt": * u16_path = PyUnicode_AsWideCharString(u8_path, &length) * fd = _wsopen(u16_path, _O_RDONLY | _O_BINARY, _SH_DENYWR, 0) # <<<<<<<<<<<<<< * assign_fd(io_ctx, fd) * return fd */ __pyx_v_fd = _wsopen(__pyx_v_u16_path, (_O_RDONLY | _O_BINARY), _SH_DENYWR, 0); /* "pyreadstat/_readstat_parser.pyx":788 * u16_path = PyUnicode_AsWideCharString(u8_path, &length) * fd = _wsopen(u16_path, _O_RDONLY | _O_BINARY, _SH_DENYWR, 0) * assign_fd(io_ctx, fd) # <<<<<<<<<<<<<< * return fd * else: */ assign_fd(__pyx_v_io_ctx, __pyx_v_fd); /* "pyreadstat/_readstat_parser.pyx":789 * fd = _wsopen(u16_path, _O_RDONLY | _O_BINARY, _SH_DENYWR, 0) * assign_fd(io_ctx, fd) * return fd # <<<<<<<<<<<<<< * else: * return -1 */ __pyx_r = __pyx_v_fd; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":785 * return -1 * * if os.name == "nt": # <<<<<<<<<<<<<< * u16_path = PyUnicode_AsWideCharString(u8_path, &length) * fd = _wsopen(u16_path, _O_RDONLY | _O_BINARY, _SH_DENYWR, 0) */ } /* "pyreadstat/_readstat_parser.pyx":791 * return fd * else: * return -1 # <<<<<<<<<<<<<< * * */ /*else*/ { __pyx_r = -1; goto __pyx_L0; } /* "pyreadstat/_readstat_parser.pyx":774 * return READSTAT_HANDLER_OK * * cdef int handle_open(const char *u8_path, void *io_ctx) except READSTAT_HANDLER_ABORT: # <<<<<<<<<<<<<< * """ * Special open handler for windows in order to be able to handle paths with international characters */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_parser.handle_open", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = READSTAT_HANDLER_ABORT; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":794 * * * cdef void check_exit_status(readstat_error_t retcode) except *: # <<<<<<<<<<<<<< * """ * transforms a readstat exit status to a python error if status is not READSTAT OK */ static void __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_error_t __pyx_v_retcode) { char *__pyx_v_err_readstat; PyObject *__pyx_v_err_message = 0; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("check_exit_status", 1); /* "pyreadstat/_readstat_parser.pyx":801 * cdef char * err_readstat * cdef str err_message * if retcode != READSTAT_OK: # <<<<<<<<<<<<<< * err_readstat = readstat_error_message(retcode) * err_message = err_readstat */ __pyx_t_1 = (__pyx_v_retcode != READSTAT_OK); if (unlikely(__pyx_t_1)) { /* "pyreadstat/_readstat_parser.pyx":802 * cdef str err_message * if retcode != READSTAT_OK: * err_readstat = readstat_error_message(retcode) # <<<<<<<<<<<<<< * err_message = err_readstat * raise ReadstatError(err_message) */ __pyx_v_err_readstat = readstat_error_message(__pyx_v_retcode); /* "pyreadstat/_readstat_parser.pyx":803 * if retcode != READSTAT_OK: * err_readstat = readstat_error_message(retcode) * err_message = err_readstat # <<<<<<<<<<<<<< * raise ReadstatError(err_message) * */ __pyx_t_2 = __Pyx_PyStr_FromString(__pyx_v_err_readstat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_err_message = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":804 * err_readstat = readstat_error_message(retcode) * err_message = err_readstat * raise ReadstatError(err_message) # <<<<<<<<<<<<<< * * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ReadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_err_message}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 804, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":801 * cdef char * err_readstat * cdef str err_message * if retcode != READSTAT_OK: # <<<<<<<<<<<<<< * err_readstat = readstat_error_message(retcode) * err_message = err_readstat */ } /* "pyreadstat/_readstat_parser.pyx":794 * * * cdef void check_exit_status(readstat_error_t retcode) except *: # <<<<<<<<<<<<<< * """ * transforms a readstat exit status to a python error if status is not READSTAT OK */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_parser.check_exit_status", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_v_err_message); __Pyx_RefNannyFinishContext(); } /* "pyreadstat/_readstat_parser.pyx":807 * * * cdef void run_readstat_parser(char * filename, data_container data, py_file_extension file_extension, long row_limit, long row_offset) except *: # <<<<<<<<<<<<<< * """ * Runs the parsing of the file by readstat library */ static void __pyx_f_10pyreadstat_16_readstat_parser_run_readstat_parser(char *__pyx_v_filename, struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_data, __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_v_file_extension, long __pyx_v_row_limit, long __pyx_v_row_offset) { readstat_parser_t *__pyx_v_parser; readstat_error_t __pyx_v_error; readstat_metadata_handler __pyx_v_metadata_handler; readstat_variable_handler __pyx_v_variable_handler; readstat_value_handler __pyx_v_value_handler; readstat_value_label_handler __pyx_v_value_label_handler; readstat_note_handler __pyx_v_note_handler; void *__pyx_v_ctx; PyObject *__pyx_v_pyerr; int __pyx_v_metaonly; readstat_open_handler __pyx_v_open_handler; PyObject *__pyx_v_encoding_bytes = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; char *__pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("run_readstat_parser", 1); /* "pyreadstat/_readstat_parser.pyx":827 * cdef bytes encoding_byte * * metaonly = data.metaonly # <<<<<<<<<<<<<< * ctx = data * */ __pyx_t_1 = __pyx_v_data->metaonly; __pyx_v_metaonly = __pyx_t_1; /* "pyreadstat/_readstat_parser.pyx":828 * * metaonly = data.metaonly * ctx = data # <<<<<<<<<<<<<< * * #readstat_error_t error = READSTAT_OK; */ __pyx_v_ctx = ((void *)__pyx_v_data); /* "pyreadstat/_readstat_parser.pyx":831 * * #readstat_error_t error = READSTAT_OK; * parser = readstat_parser_init() # <<<<<<<<<<<<<< * metadata_handler = handle_metadata * variable_handler = handle_variable */ __pyx_v_parser = readstat_parser_init(); /* "pyreadstat/_readstat_parser.pyx":832 * #readstat_error_t error = READSTAT_OK; * parser = readstat_parser_init() * metadata_handler = handle_metadata # <<<<<<<<<<<<<< * variable_handler = handle_variable * value_handler = handle_value */ __pyx_v_metadata_handler = ((readstat_metadata_handler)__pyx_f_10pyreadstat_16_readstat_parser_handle_metadata); /* "pyreadstat/_readstat_parser.pyx":833 * parser = readstat_parser_init() * metadata_handler = handle_metadata * variable_handler = handle_variable # <<<<<<<<<<<<<< * value_handler = handle_value * value_label_handler = handle_value_label */ __pyx_v_variable_handler = ((readstat_variable_handler)__pyx_f_10pyreadstat_16_readstat_parser_handle_variable); /* "pyreadstat/_readstat_parser.pyx":834 * metadata_handler = handle_metadata * variable_handler = handle_variable * value_handler = handle_value # <<<<<<<<<<<<<< * value_label_handler = handle_value_label * note_handler = handle_note */ __pyx_v_value_handler = ((readstat_value_handler)__pyx_f_10pyreadstat_16_readstat_parser_handle_value); /* "pyreadstat/_readstat_parser.pyx":835 * variable_handler = handle_variable * value_handler = handle_value * value_label_handler = handle_value_label # <<<<<<<<<<<<<< * note_handler = handle_note * */ __pyx_v_value_label_handler = ((readstat_value_label_handler)__pyx_f_10pyreadstat_16_readstat_parser_handle_value_label); /* "pyreadstat/_readstat_parser.pyx":836 * value_handler = handle_value * value_label_handler = handle_value_label * note_handler = handle_note # <<<<<<<<<<<<<< * * */ __pyx_v_note_handler = ((readstat_note_handler)__pyx_f_10pyreadstat_16_readstat_parser_handle_note); /* "pyreadstat/_readstat_parser.pyx":839 * * * check_exit_status(readstat_set_metadata_handler(parser, metadata_handler)) # <<<<<<<<<<<<<< * check_exit_status(readstat_set_variable_handler(parser, variable_handler)) * check_exit_status(readstat_set_value_label_handler(parser, value_label_handler)) */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_set_metadata_handler(__pyx_v_parser, __pyx_v_metadata_handler)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 839, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":840 * * check_exit_status(readstat_set_metadata_handler(parser, metadata_handler)) * check_exit_status(readstat_set_variable_handler(parser, variable_handler)) # <<<<<<<<<<<<<< * check_exit_status(readstat_set_value_label_handler(parser, value_label_handler)) * check_exit_status(readstat_set_note_handler(parser, note_handler)) */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_set_variable_handler(__pyx_v_parser, __pyx_v_variable_handler)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 840, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":841 * check_exit_status(readstat_set_metadata_handler(parser, metadata_handler)) * check_exit_status(readstat_set_variable_handler(parser, variable_handler)) * check_exit_status(readstat_set_value_label_handler(parser, value_label_handler)) # <<<<<<<<<<<<<< * check_exit_status(readstat_set_note_handler(parser, note_handler)) * */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_set_value_label_handler(__pyx_v_parser, __pyx_v_value_label_handler)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 841, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":842 * check_exit_status(readstat_set_variable_handler(parser, variable_handler)) * check_exit_status(readstat_set_value_label_handler(parser, value_label_handler)) * check_exit_status(readstat_set_note_handler(parser, note_handler)) # <<<<<<<<<<<<<< * * # on windows we need a custom open handler in order to deal with internation characters in the path. */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_set_note_handler(__pyx_v_parser, __pyx_v_note_handler)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 842, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":845 * * # on windows we need a custom open handler in order to deal with internation characters in the path. * if os.name == "nt": # <<<<<<<<<<<<<< * open_handler = handle_open * readstat_set_open_handler(parser, open_handler) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 845, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 845, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_t_3, __pyx_n_s_nt, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 845, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":846 * # on windows we need a custom open handler in order to deal with internation characters in the path. * if os.name == "nt": * open_handler = handle_open # <<<<<<<<<<<<<< * readstat_set_open_handler(parser, open_handler) * */ __pyx_v_open_handler = ((readstat_open_handler)__pyx_f_10pyreadstat_16_readstat_parser_handle_open); /* "pyreadstat/_readstat_parser.pyx":847 * if os.name == "nt": * open_handler = handle_open * readstat_set_open_handler(parser, open_handler) # <<<<<<<<<<<<<< * * if not metaonly: */ (void)(readstat_set_open_handler(__pyx_v_parser, __pyx_v_open_handler)); /* "pyreadstat/_readstat_parser.pyx":845 * * # on windows we need a custom open handler in order to deal with internation characters in the path. * if os.name == "nt": # <<<<<<<<<<<<<< * open_handler = handle_open * readstat_set_open_handler(parser, open_handler) */ } /* "pyreadstat/_readstat_parser.pyx":849 * readstat_set_open_handler(parser, open_handler) * * if not metaonly: # <<<<<<<<<<<<<< * check_exit_status(readstat_set_value_handler(parser, value_handler)) * */ __pyx_t_1 = (!__pyx_v_metaonly); if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":850 * * if not metaonly: * check_exit_status(readstat_set_value_handler(parser, value_handler)) # <<<<<<<<<<<<<< * * # if the user set the encoding manually */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_set_value_handler(__pyx_v_parser, __pyx_v_value_handler)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 850, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":849 * readstat_set_open_handler(parser, open_handler) * * if not metaonly: # <<<<<<<<<<<<<< * check_exit_status(readstat_set_value_handler(parser, value_handler)) * */ } /* "pyreadstat/_readstat_parser.pyx":853 * * # if the user set the encoding manually * if data.user_encoding: # <<<<<<<<<<<<<< * encoding_bytes = data.user_encoding.encode("utf-8") * readstat_set_file_character_encoding(parser, encoding_bytes) */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_data->user_encoding); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 853, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":854 * # if the user set the encoding manually * if data.user_encoding: * encoding_bytes = data.user_encoding.encode("utf-8") # <<<<<<<<<<<<<< * readstat_set_file_character_encoding(parser, encoding_bytes) * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data->user_encoding, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 854, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_kp_s_utf_8}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 854, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_encoding_bytes = __pyx_t_3; __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":855 * if data.user_encoding: * encoding_bytes = data.user_encoding.encode("utf-8") * readstat_set_file_character_encoding(parser, encoding_bytes) # <<<<<<<<<<<<<< * * if row_limit: */ __pyx_t_6 = __Pyx_PyObject_AsWritableString(__pyx_v_encoding_bytes); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 855, __pyx_L1_error) (void)(readstat_set_file_character_encoding(__pyx_v_parser, ((char *)__pyx_t_6))); /* "pyreadstat/_readstat_parser.pyx":853 * * # if the user set the encoding manually * if data.user_encoding: # <<<<<<<<<<<<<< * encoding_bytes = data.user_encoding.encode("utf-8") * readstat_set_file_character_encoding(parser, encoding_bytes) */ } /* "pyreadstat/_readstat_parser.pyx":857 * readstat_set_file_character_encoding(parser, encoding_bytes) * * if row_limit: # <<<<<<<<<<<<<< * check_exit_status(readstat_set_row_limit(parser, row_limit)) * */ __pyx_t_1 = (__pyx_v_row_limit != 0); if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":858 * * if row_limit: * check_exit_status(readstat_set_row_limit(parser, row_limit)) # <<<<<<<<<<<<<< * * if row_offset: */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_set_row_limit(__pyx_v_parser, __pyx_v_row_limit)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 858, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":857 * readstat_set_file_character_encoding(parser, encoding_bytes) * * if row_limit: # <<<<<<<<<<<<<< * check_exit_status(readstat_set_row_limit(parser, row_limit)) * */ } /* "pyreadstat/_readstat_parser.pyx":860 * check_exit_status(readstat_set_row_limit(parser, row_limit)) * * if row_offset: # <<<<<<<<<<<<<< * check_exit_status(readstat_set_row_offset(parser, row_offset)) * */ __pyx_t_1 = (__pyx_v_row_offset != 0); if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":861 * * if row_offset: * check_exit_status(readstat_set_row_offset(parser, row_offset)) # <<<<<<<<<<<<<< * * # parse! */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_set_row_offset(__pyx_v_parser, __pyx_v_row_offset)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 861, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":860 * check_exit_status(readstat_set_row_limit(parser, row_limit)) * * if row_offset: # <<<<<<<<<<<<<< * check_exit_status(readstat_set_row_offset(parser, row_offset)) * */ } /* "pyreadstat/_readstat_parser.pyx":864 * * # parse! * if file_extension == FILE_EXT_SAV: # <<<<<<<<<<<<<< * error = readstat_parse_sav(parser, filename, ctx); * elif file_extension == FILE_EXT_SAS7BDAT: */ switch (__pyx_v_file_extension) { case __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAV: /* "pyreadstat/_readstat_parser.pyx":865 * # parse! * if file_extension == FILE_EXT_SAV: * error = readstat_parse_sav(parser, filename, ctx); # <<<<<<<<<<<<<< * elif file_extension == FILE_EXT_SAS7BDAT: * error = readstat_parse_sas7bdat(parser, filename, ctx); */ __pyx_v_error = readstat_parse_sav(__pyx_v_parser, __pyx_v_filename, __pyx_v_ctx); /* "pyreadstat/_readstat_parser.pyx":864 * * # parse! * if file_extension == FILE_EXT_SAV: # <<<<<<<<<<<<<< * error = readstat_parse_sav(parser, filename, ctx); * elif file_extension == FILE_EXT_SAS7BDAT: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BDAT: /* "pyreadstat/_readstat_parser.pyx":867 * error = readstat_parse_sav(parser, filename, ctx); * elif file_extension == FILE_EXT_SAS7BDAT: * error = readstat_parse_sas7bdat(parser, filename, ctx); # <<<<<<<<<<<<<< * elif file_extension == FILE_EXT_DTA: * error = readstat_parse_dta(parser, filename, ctx); */ __pyx_v_error = readstat_parse_sas7bdat(__pyx_v_parser, __pyx_v_filename, __pyx_v_ctx); /* "pyreadstat/_readstat_parser.pyx":866 * if file_extension == FILE_EXT_SAV: * error = readstat_parse_sav(parser, filename, ctx); * elif file_extension == FILE_EXT_SAS7BDAT: # <<<<<<<<<<<<<< * error = readstat_parse_sas7bdat(parser, filename, ctx); * elif file_extension == FILE_EXT_DTA: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_DTA: /* "pyreadstat/_readstat_parser.pyx":869 * error = readstat_parse_sas7bdat(parser, filename, ctx); * elif file_extension == FILE_EXT_DTA: * error = readstat_parse_dta(parser, filename, ctx); # <<<<<<<<<<<<<< * elif file_extension == FILE_EXT_XPORT: * error = readstat_parse_xport(parser, filename, ctx); */ __pyx_v_error = readstat_parse_dta(__pyx_v_parser, __pyx_v_filename, __pyx_v_ctx); /* "pyreadstat/_readstat_parser.pyx":868 * elif file_extension == FILE_EXT_SAS7BDAT: * error = readstat_parse_sas7bdat(parser, filename, ctx); * elif file_extension == FILE_EXT_DTA: # <<<<<<<<<<<<<< * error = readstat_parse_dta(parser, filename, ctx); * elif file_extension == FILE_EXT_XPORT: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_XPORT: /* "pyreadstat/_readstat_parser.pyx":871 * error = readstat_parse_dta(parser, filename, ctx); * elif file_extension == FILE_EXT_XPORT: * error = readstat_parse_xport(parser, filename, ctx); # <<<<<<<<<<<<<< * elif file_extension == FILE_EXT_POR: * error = readstat_parse_por(parser, filename, ctx); */ __pyx_v_error = readstat_parse_xport(__pyx_v_parser, __pyx_v_filename, __pyx_v_ctx); /* "pyreadstat/_readstat_parser.pyx":870 * elif file_extension == FILE_EXT_DTA: * error = readstat_parse_dta(parser, filename, ctx); * elif file_extension == FILE_EXT_XPORT: # <<<<<<<<<<<<<< * error = readstat_parse_xport(parser, filename, ctx); * elif file_extension == FILE_EXT_POR: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_POR: /* "pyreadstat/_readstat_parser.pyx":873 * error = readstat_parse_xport(parser, filename, ctx); * elif file_extension == FILE_EXT_POR: * error = readstat_parse_por(parser, filename, ctx); # <<<<<<<<<<<<<< * elif file_extension == FILE_EXT_SAS7BCAT: * error = readstat_parse_sas7bcat(parser, filename, ctx); */ __pyx_v_error = readstat_parse_por(__pyx_v_parser, __pyx_v_filename, __pyx_v_ctx); /* "pyreadstat/_readstat_parser.pyx":872 * elif file_extension == FILE_EXT_XPORT: * error = readstat_parse_xport(parser, filename, ctx); * elif file_extension == FILE_EXT_POR: # <<<<<<<<<<<<<< * error = readstat_parse_por(parser, filename, ctx); * elif file_extension == FILE_EXT_SAS7BCAT: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BCAT: /* "pyreadstat/_readstat_parser.pyx":875 * error = readstat_parse_por(parser, filename, ctx); * elif file_extension == FILE_EXT_SAS7BCAT: * error = readstat_parse_sas7bcat(parser, filename, ctx); # <<<<<<<<<<<<<< * #error = parse_func(parser, filename, ctx); * readstat_parser_free(parser) */ __pyx_v_error = readstat_parse_sas7bcat(__pyx_v_parser, __pyx_v_filename, __pyx_v_ctx); /* "pyreadstat/_readstat_parser.pyx":874 * elif file_extension == FILE_EXT_POR: * error = readstat_parse_por(parser, filename, ctx); * elif file_extension == FILE_EXT_SAS7BCAT: # <<<<<<<<<<<<<< * error = readstat_parse_sas7bcat(parser, filename, ctx); * #error = parse_func(parser, filename, ctx); */ break; default: break; } /* "pyreadstat/_readstat_parser.pyx":877 * error = readstat_parse_sas7bcat(parser, filename, ctx); * #error = parse_func(parser, filename, ctx); * readstat_parser_free(parser) # <<<<<<<<<<<<<< * # check if a python error ocurred, if yes, it will be printed by the interpreter, * # if not, make sure that the return from parse_func is OK, if not print */ readstat_parser_free(__pyx_v_parser); /* "pyreadstat/_readstat_parser.pyx":880 * # check if a python error ocurred, if yes, it will be printed by the interpreter, * # if not, make sure that the return from parse_func is OK, if not print * pyerr = PyErr_Occurred() # <<<<<<<<<<<<<< * if pyerr == NULL: * check_exit_status(error) */ __pyx_v_pyerr = PyErr_Occurred(); /* "pyreadstat/_readstat_parser.pyx":881 * # if not, make sure that the return from parse_func is OK, if not print * pyerr = PyErr_Occurred() * if pyerr == NULL: # <<<<<<<<<<<<<< * check_exit_status(error) * */ __pyx_t_1 = (((void *)__pyx_v_pyerr) == NULL); if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":882 * pyerr = PyErr_Occurred() * if pyerr == NULL: * check_exit_status(error) # <<<<<<<<<<<<<< * * */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(__pyx_v_error); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 882, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":881 * # if not, make sure that the return from parse_func is OK, if not print * pyerr = PyErr_Occurred() * if pyerr == NULL: # <<<<<<<<<<<<<< * check_exit_status(error) * */ } /* "pyreadstat/_readstat_parser.pyx":807 * * * cdef void run_readstat_parser(char * filename, data_container data, py_file_extension file_extension, long row_limit, long row_offset) except *: # <<<<<<<<<<<<<< * """ * Runs the parsing of the file by readstat library */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_parser.run_readstat_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_v_encoding_bytes); __Pyx_RefNannyFinishContext(); } /* "pyreadstat/_readstat_parser.pyx":885 * * * cdef object data_container_to_dict(data_container data): # <<<<<<<<<<<<<< * """ * Transforms a data container object to a pandas data frame */ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_data_container_to_dict(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_data) { PyObject *__pyx_v_final_container = 0; PyObject *__pyx_v_col_data = 0; PyObject *__pyx_v_col_names = 0; PyObject *__pyx_v_cur_name_str = 0; int __pyx_v_fc_cnt; int __pyx_v_is_unkown_number_rows; int __pyx_v_max_n_obs; int __pyx_v_metaonly; PyObject *__pyx_v_cur_data = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; Py_ssize_t __pyx_t_6; Py_ssize_t __pyx_t_7; int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("data_container_to_dict", 1); /* "pyreadstat/_readstat_parser.pyx":899 * cdef bint metaonly * * final_container = OrderedDict() # <<<<<<<<<<<<<< * col_data = data.col_data * col_names = data.col_names */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_final_container = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":900 * * final_container = OrderedDict() * col_data = data.col_data # <<<<<<<<<<<<<< * col_names = data.col_names * is_unkown_number_rows = data.is_unkown_number_rows */ __pyx_t_1 = __pyx_v_data->col_data; __Pyx_INCREF(__pyx_t_1); __pyx_v_col_data = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":901 * final_container = OrderedDict() * col_data = data.col_data * col_names = data.col_names # <<<<<<<<<<<<<< * is_unkown_number_rows = data.is_unkown_number_rows * max_n_obs = data.max_n_obs */ __pyx_t_1 = __pyx_v_data->col_names; __Pyx_INCREF(__pyx_t_1); __pyx_v_col_names = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":902 * col_data = data.col_data * col_names = data.col_names * is_unkown_number_rows = data.is_unkown_number_rows # <<<<<<<<<<<<<< * max_n_obs = data.max_n_obs * metaonly = data.metaonly */ __pyx_t_5 = __pyx_v_data->is_unkown_number_rows; __pyx_v_is_unkown_number_rows = __pyx_t_5; /* "pyreadstat/_readstat_parser.pyx":903 * col_names = data.col_names * is_unkown_number_rows = data.is_unkown_number_rows * max_n_obs = data.max_n_obs # <<<<<<<<<<<<<< * metaonly = data.metaonly * */ __pyx_t_4 = __pyx_v_data->max_n_obs; __pyx_v_max_n_obs = __pyx_t_4; /* "pyreadstat/_readstat_parser.pyx":904 * is_unkown_number_rows = data.is_unkown_number_rows * max_n_obs = data.max_n_obs * metaonly = data.metaonly # <<<<<<<<<<<<<< * * for fc_cnt in range(0, len(col_names)): */ __pyx_t_5 = __pyx_v_data->metaonly; __pyx_v_metaonly = __pyx_t_5; /* "pyreadstat/_readstat_parser.pyx":906 * metaonly = data.metaonly * * for fc_cnt in range(0, len(col_names)): # <<<<<<<<<<<<<< * cur_name_str = col_names[fc_cnt] * cur_data = col_data[fc_cnt] */ if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 906, __pyx_L1_error) } __pyx_t_6 = __Pyx_PyList_GET_SIZE(__pyx_v_col_names); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 906, __pyx_L1_error) __pyx_t_7 = __pyx_t_6; for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_7; __pyx_t_4+=1) { __pyx_v_fc_cnt = __pyx_t_4; /* "pyreadstat/_readstat_parser.pyx":907 * * for fc_cnt in range(0, len(col_names)): * cur_name_str = col_names[fc_cnt] # <<<<<<<<<<<<<< * cur_data = col_data[fc_cnt] * if is_unkown_number_rows and not metaonly: */ if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 907, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_col_names, __pyx_v_fc_cnt, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_1))) __PYX_ERR(0, 907, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_cur_name_str, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":908 * for fc_cnt in range(0, len(col_names)): * cur_name_str = col_names[fc_cnt] * cur_data = col_data[fc_cnt] # <<<<<<<<<<<<<< * if is_unkown_number_rows and not metaonly: * cur_data = cur_data[0:max_n_obs] */ if (unlikely(__pyx_v_col_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 908, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_col_data, __pyx_v_fc_cnt, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_cur_data, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":909 * cur_name_str = col_names[fc_cnt] * cur_data = col_data[fc_cnt] * if is_unkown_number_rows and not metaonly: # <<<<<<<<<<<<<< * cur_data = cur_data[0:max_n_obs] * if not metaonly: */ if (__pyx_v_is_unkown_number_rows) { } else { __pyx_t_5 = __pyx_v_is_unkown_number_rows; goto __pyx_L6_bool_binop_done; } __pyx_t_8 = (!__pyx_v_metaonly); __pyx_t_5 = __pyx_t_8; __pyx_L6_bool_binop_done:; if (__pyx_t_5) { /* "pyreadstat/_readstat_parser.pyx":910 * cur_data = col_data[fc_cnt] * if is_unkown_number_rows and not metaonly: * cur_data = cur_data[0:max_n_obs] # <<<<<<<<<<<<<< * if not metaonly: * final_container[cur_name_str] = cur_data */ __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_cur_data, 0, __pyx_v_max_n_obs, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_cur_data, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":909 * cur_name_str = col_names[fc_cnt] * cur_data = col_data[fc_cnt] * if is_unkown_number_rows and not metaonly: # <<<<<<<<<<<<<< * cur_data = cur_data[0:max_n_obs] * if not metaonly: */ } /* "pyreadstat/_readstat_parser.pyx":911 * if is_unkown_number_rows and not metaonly: * cur_data = cur_data[0:max_n_obs] * if not metaonly: # <<<<<<<<<<<<<< * final_container[cur_name_str] = cur_data * else: */ __pyx_t_5 = (!__pyx_v_metaonly); if (__pyx_t_5) { /* "pyreadstat/_readstat_parser.pyx":912 * cur_data = cur_data[0:max_n_obs] * if not metaonly: * final_container[cur_name_str] = cur_data # <<<<<<<<<<<<<< * else: * final_container[cur_name_str] = list() */ if (unlikely((PyObject_SetItem(__pyx_v_final_container, __pyx_v_cur_name_str, __pyx_v_cur_data) < 0))) __PYX_ERR(0, 912, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":911 * if is_unkown_number_rows and not metaonly: * cur_data = cur_data[0:max_n_obs] * if not metaonly: # <<<<<<<<<<<<<< * final_container[cur_name_str] = cur_data * else: */ goto __pyx_L8; } /* "pyreadstat/_readstat_parser.pyx":914 * final_container[cur_name_str] = cur_data * else: * final_container[cur_name_str] = list() # <<<<<<<<<<<<<< * * return final_container */ /*else*/ { __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely((PyObject_SetItem(__pyx_v_final_container, __pyx_v_cur_name_str, __pyx_t_1) < 0))) __PYX_ERR(0, 914, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L8:; } /* "pyreadstat/_readstat_parser.pyx":916 * final_container[cur_name_str] = list() * * return final_container # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_final_container); __pyx_r = __pyx_v_final_container; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":885 * * * cdef object data_container_to_dict(data_container data): # <<<<<<<<<<<<<< * """ * Transforms a data container object to a pandas data frame */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("pyreadstat._readstat_parser.data_container_to_dict", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_final_container); __Pyx_XDECREF(__pyx_v_col_data); __Pyx_XDECREF(__pyx_v_col_names); __Pyx_XDECREF(__pyx_v_cur_name_str); __Pyx_XDECREF(__pyx_v_cur_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":919 * * * cdef object dict_to_pandas_dataframe(object dict_data, data_container dc): # <<<<<<<<<<<<<< * """ * Transforms a dict of numpy arrays to a pandas data frame */ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_dict_to_pandas_dataframe(PyObject *__pyx_v_dict_data, struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_dc) { int __pyx_v_dates_as_pandas; int __pyx_v_index; PyObject *__pyx_v_column = 0; __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_v_var_format; PyObject *__pyx_v_dtypes = 0; PyObject *__pyx_v_data_frame = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; Py_ssize_t __pyx_t_6; PyObject *(*__pyx_t_7)(PyObject *); __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_t_8; int __pyx_t_9; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; int __pyx_t_12; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("dict_to_pandas_dataframe", 1); /* "pyreadstat/_readstat_parser.pyx":930 * cdef list dtypes * * dates_as_pandas = dc.dates_as_pandas # <<<<<<<<<<<<<< * * if dict_data: */ __pyx_t_1 = __pyx_v_dc->dates_as_pandas; __pyx_v_dates_as_pandas = __pyx_t_1; /* "pyreadstat/_readstat_parser.pyx":932 * dates_as_pandas = dc.dates_as_pandas * * if dict_data: # <<<<<<<<<<<<<< * data_frame = pd.DataFrame.from_dict(dict_data) * if dates_as_pandas: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_dict_data); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 932, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":933 * * if dict_data: * data_frame = pd.DataFrame.from_dict(dict_data) # <<<<<<<<<<<<<< * if dates_as_pandas: * dtypes = data_frame.dtypes.tolist() */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_from_dict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_dict_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_data_frame = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":934 * if dict_data: * data_frame = pd.DataFrame.from_dict(dict_data) * if dates_as_pandas: # <<<<<<<<<<<<<< * dtypes = data_frame.dtypes.tolist() * # check that datetime columns are datetime type */ if (__pyx_v_dates_as_pandas) { /* "pyreadstat/_readstat_parser.pyx":935 * data_frame = pd.DataFrame.from_dict(dict_data) * if dates_as_pandas: * dtypes = data_frame.dtypes.tolist() # <<<<<<<<<<<<<< * # check that datetime columns are datetime type * # this is needed in case all date values are nan */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data_frame, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 935, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 935, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 935, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_2))) __PYX_ERR(0, 935, __pyx_L1_error) __pyx_v_dtypes = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":938 * # check that datetime columns are datetime type * # this is needed in case all date values are nan * for index, column in enumerate(data_frame.columns): # <<<<<<<<<<<<<< * var_format = dc.col_formats[index] * if dtypes[index] != '= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 938, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 938, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 938, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 938, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 938, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_7(__pyx_t_4); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 938, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_2))) __PYX_ERR(0, 938, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_column, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_index = __pyx_t_5; __pyx_t_5 = (__pyx_t_5 + 1); /* "pyreadstat/_readstat_parser.pyx":939 * # this is needed in case all date values are nan * for index, column in enumerate(data_frame.columns): * var_format = dc.col_formats[index] # <<<<<<<<<<<<<< * if dtypes[index] != 'col_formats == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 939, __pyx_L1_error) } __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_dc->col_formats, __pyx_v_index, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 939, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = ((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)__Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format(__pyx_t_2)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 939, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_var_format = __pyx_t_8; /* "pyreadstat/_readstat_parser.pyx":940 * for index, column in enumerate(data_frame.columns): * var_format = dc.col_formats[index] * if dtypes[index] != 'metaonly; __pyx_v_metaonly = __pyx_t_1; /* "pyreadstat/_readstat_parser.pyx":966 * * metaonly = data.metaonly * is_unkown_number_rows = data.is_unkown_number_rows # <<<<<<<<<<<<<< * * cdef object metadata = metadata_container() */ __pyx_t_1 = __pyx_v_data->is_unkown_number_rows; __pyx_v_is_unkown_number_rows = __pyx_t_1; /* "pyreadstat/_readstat_parser.pyx":968 * is_unkown_number_rows = data.is_unkown_number_rows * * cdef object metadata = metadata_container() # <<<<<<<<<<<<<< * * # number of rows */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_metadata_container); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_metadata = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":971 * * # number of rows * metadata.number_columns = data.n_vars # <<<<<<<<<<<<<< * if is_unkown_number_rows: * if not metaonly: */ __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_data->n_vars); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_number_columns, __pyx_t_2) < 0) __PYX_ERR(0, 971, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":972 * # number of rows * metadata.number_columns = data.n_vars * if is_unkown_number_rows: # <<<<<<<<<<<<<< * if not metaonly: * metadata.number_rows = data.max_n_obs */ if (__pyx_v_is_unkown_number_rows) { /* "pyreadstat/_readstat_parser.pyx":973 * metadata.number_columns = data.n_vars * if is_unkown_number_rows: * if not metaonly: # <<<<<<<<<<<<<< * metadata.number_rows = data.max_n_obs * else: */ __pyx_t_1 = (!__pyx_v_metaonly); if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":974 * if is_unkown_number_rows: * if not metaonly: * metadata.number_rows = data.max_n_obs # <<<<<<<<<<<<<< * else: * metadata.number_rows = data.n_obs */ __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_data->max_n_obs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_number_rows, __pyx_t_2) < 0) __PYX_ERR(0, 974, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":973 * metadata.number_columns = data.n_vars * if is_unkown_number_rows: * if not metaonly: # <<<<<<<<<<<<<< * metadata.number_rows = data.max_n_obs * else: */ } /* "pyreadstat/_readstat_parser.pyx":972 * # number of rows * metadata.number_columns = data.n_vars * if is_unkown_number_rows: # <<<<<<<<<<<<<< * if not metaonly: * metadata.number_rows = data.max_n_obs */ goto __pyx_L3; } /* "pyreadstat/_readstat_parser.pyx":976 * metadata.number_rows = data.max_n_obs * else: * metadata.number_rows = data.n_obs # <<<<<<<<<<<<<< * * # value labels */ /*else*/ { __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_data->n_obs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 976, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_number_rows, __pyx_t_2) < 0) __PYX_ERR(0, 976, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_L3:; /* "pyreadstat/_readstat_parser.pyx":979 * * # value labels * labels_raw = data.labels_raw # <<<<<<<<<<<<<< * label_to_var_name = data.label_to_var_name * variable_value_labels = dict() */ __pyx_t_2 = __pyx_v_data->labels_raw; __Pyx_INCREF(__pyx_t_2); __pyx_v_labels_raw = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":980 * # value labels * labels_raw = data.labels_raw * label_to_var_name = data.label_to_var_name # <<<<<<<<<<<<<< * variable_value_labels = dict() * */ __pyx_t_2 = __pyx_v_data->label_to_var_name; __Pyx_INCREF(__pyx_t_2); __pyx_v_label_to_var_name = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":981 * labels_raw = data.labels_raw * label_to_var_name = data.label_to_var_name * variable_value_labels = dict() # <<<<<<<<<<<<<< * * if labels_raw: */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 981, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_variable_value_labels = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":983 * variable_value_labels = dict() * * if labels_raw: # <<<<<<<<<<<<<< * for var_name, var_label in label_to_var_name.items(): * current_labels = labels_raw.get(var_label) */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_labels_raw); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 983, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":984 * * if labels_raw: * for var_name, var_label in label_to_var_name.items(): # <<<<<<<<<<<<<< * current_labels = labels_raw.get(var_label) * if current_labels: */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_label_to_var_name, __pyx_n_s_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 984, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 984, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 984, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 984, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 984, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 984, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 984, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_4 = PyList_GET_ITEM(sequence, 0); __pyx_t_8 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); #else __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L8_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L8_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 984, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L9_unpacking_done; __pyx_L8_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 984, __pyx_L1_error) __pyx_L9_unpacking_done:; } if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_4))) __PYX_ERR(0, 984, __pyx_L1_error) if (!(likely(PyString_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_8))) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_var_name, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_var_label, ((PyObject*)__pyx_t_8)); __pyx_t_8 = 0; /* "pyreadstat/_readstat_parser.pyx":985 * if labels_raw: * for var_name, var_label in label_to_var_name.items(): * current_labels = labels_raw.get(var_label) # <<<<<<<<<<<<<< * if current_labels: * variable_value_labels[var_name] = current_labels */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_labels_raw, __pyx_n_s_get); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_var_label}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_XDECREF_SET(__pyx_v_current_labels, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":986 * for var_name, var_label in label_to_var_name.items(): * current_labels = labels_raw.get(var_label) * if current_labels: # <<<<<<<<<<<<<< * variable_value_labels[var_name] = current_labels * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_current_labels); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 986, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_parser.pyx":987 * current_labels = labels_raw.get(var_label) * if current_labels: * variable_value_labels[var_name] = current_labels # <<<<<<<<<<<<<< * * original_types = dict() */ if (unlikely((PyDict_SetItem(__pyx_v_variable_value_labels, __pyx_v_var_name, __pyx_v_current_labels) < 0))) __PYX_ERR(0, 987, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":986 * for var_name, var_label in label_to_var_name.items(): * current_labels = labels_raw.get(var_label) * if current_labels: # <<<<<<<<<<<<<< * variable_value_labels[var_name] = current_labels * */ } /* "pyreadstat/_readstat_parser.pyx":984 * * if labels_raw: * for var_name, var_label in label_to_var_name.items(): # <<<<<<<<<<<<<< * current_labels = labels_raw.get(var_label) * if current_labels: */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":983 * variable_value_labels = dict() * * if labels_raw: # <<<<<<<<<<<<<< * for var_name, var_label in label_to_var_name.items(): * current_labels = labels_raw.get(var_label) */ } /* "pyreadstat/_readstat_parser.pyx":989 * variable_value_labels[var_name] = current_labels * * original_types = dict() # <<<<<<<<<<<<<< * readstat_types = dict() * for indx in range(metadata.number_columns): */ __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_original_types = __pyx_t_3; __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":990 * * original_types = dict() * readstat_types = dict() # <<<<<<<<<<<<<< * for indx in range(metadata.number_columns): * cur_col = data.col_names[indx] */ __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_readstat_types = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":991 * original_types = dict() * readstat_types = dict() * for indx in range(metadata.number_columns): # <<<<<<<<<<<<<< * cur_col = data.col_names[indx] * cur_type = data.col_formats_original[indx] */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_metadata, __pyx_n_s_number_columns); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 991, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 991, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 991, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 991, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 991, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 991, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_indx, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":992 * readstat_types = dict() * for indx in range(metadata.number_columns): * cur_col = data.col_names[indx] # <<<<<<<<<<<<<< * cur_type = data.col_formats_original[indx] * original_types[cur_col] = cur_type */ if (unlikely(__pyx_v_data->col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 992, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_data->col_names, __pyx_v_indx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 992, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_cur_col, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":993 * for indx in range(metadata.number_columns): * cur_col = data.col_names[indx] * cur_type = data.col_formats_original[indx] # <<<<<<<<<<<<<< * original_types[cur_col] = cur_type * var_type = data.col_dtypes[indx] */ if (unlikely(__pyx_v_data->col_formats_original == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 993, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_data->col_formats_original, __pyx_v_indx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 993, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_cur_type, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":994 * cur_col = data.col_names[indx] * cur_type = data.col_formats_original[indx] * original_types[cur_col] = cur_type # <<<<<<<<<<<<<< * var_type = data.col_dtypes[indx] * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: */ if (unlikely((PyObject_SetItem(__pyx_v_original_types, __pyx_v_cur_col, __pyx_v_cur_type) < 0))) __PYX_ERR(0, 994, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":995 * cur_type = data.col_formats_original[indx] * original_types[cur_col] = cur_type * var_type = data.col_dtypes[indx] # <<<<<<<<<<<<<< * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: * readstat_types[cur_col] = "string" */ if (unlikely(__pyx_v_data->col_dtypes == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 995, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_data->col_dtypes, __pyx_v_indx); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 995, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = ((readstat_type_t)__Pyx_PyInt_As_readstat_type_t(__pyx_t_2)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 995, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_var_type = __pyx_t_11; /* "pyreadstat/_readstat_parser.pyx":996 * original_types[cur_col] = cur_type * var_type = data.col_dtypes[indx] * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: # <<<<<<<<<<<<<< * readstat_types[cur_col] = "string" * elif var_type == READSTAT_TYPE_INT8: */ switch (__pyx_v_var_type) { case READSTAT_TYPE_STRING: case READSTAT_TYPE_STRING_REF: /* "pyreadstat/_readstat_parser.pyx":997 * var_type = data.col_dtypes[indx] * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: * readstat_types[cur_col] = "string" # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_INT8: * readstat_types[cur_col] = "int8" */ if (unlikely((PyDict_SetItem(__pyx_v_readstat_types, __pyx_v_cur_col, __pyx_n_s_string) < 0))) __PYX_ERR(0, 997, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":996 * original_types[cur_col] = cur_type * var_type = data.col_dtypes[indx] * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: # <<<<<<<<<<<<<< * readstat_types[cur_col] = "string" * elif var_type == READSTAT_TYPE_INT8: */ break; case READSTAT_TYPE_INT8: /* "pyreadstat/_readstat_parser.pyx":999 * readstat_types[cur_col] = "string" * elif var_type == READSTAT_TYPE_INT8: * readstat_types[cur_col] = "int8" # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_INT16: * readstat_types[cur_col] = "int16" */ if (unlikely((PyDict_SetItem(__pyx_v_readstat_types, __pyx_v_cur_col, __pyx_n_s_int8) < 0))) __PYX_ERR(0, 999, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":998 * if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: * readstat_types[cur_col] = "string" * elif var_type == READSTAT_TYPE_INT8: # <<<<<<<<<<<<<< * readstat_types[cur_col] = "int8" * elif var_type == READSTAT_TYPE_INT16: */ break; case READSTAT_TYPE_INT16: /* "pyreadstat/_readstat_parser.pyx":1001 * readstat_types[cur_col] = "int8" * elif var_type == READSTAT_TYPE_INT16: * readstat_types[cur_col] = "int16" # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_INT32: * readstat_types[cur_col] = "int32" */ if (unlikely((PyDict_SetItem(__pyx_v_readstat_types, __pyx_v_cur_col, __pyx_n_s_int16) < 0))) __PYX_ERR(0, 1001, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1000 * elif var_type == READSTAT_TYPE_INT8: * readstat_types[cur_col] = "int8" * elif var_type == READSTAT_TYPE_INT16: # <<<<<<<<<<<<<< * readstat_types[cur_col] = "int16" * elif var_type == READSTAT_TYPE_INT32: */ break; case READSTAT_TYPE_INT32: /* "pyreadstat/_readstat_parser.pyx":1003 * readstat_types[cur_col] = "int16" * elif var_type == READSTAT_TYPE_INT32: * readstat_types[cur_col] = "int32" # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_FLOAT: * readstat_types[cur_col] = "float" */ if (unlikely((PyDict_SetItem(__pyx_v_readstat_types, __pyx_v_cur_col, __pyx_n_s_int32) < 0))) __PYX_ERR(0, 1003, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1002 * elif var_type == READSTAT_TYPE_INT16: * readstat_types[cur_col] = "int16" * elif var_type == READSTAT_TYPE_INT32: # <<<<<<<<<<<<<< * readstat_types[cur_col] = "int32" * elif var_type == READSTAT_TYPE_FLOAT: */ break; case READSTAT_TYPE_FLOAT: /* "pyreadstat/_readstat_parser.pyx":1005 * readstat_types[cur_col] = "int32" * elif var_type == READSTAT_TYPE_FLOAT: * readstat_types[cur_col] = "float" # <<<<<<<<<<<<<< * elif var_type == READSTAT_TYPE_DOUBLE: * readstat_types[cur_col] = "double" */ if (unlikely((PyDict_SetItem(__pyx_v_readstat_types, __pyx_v_cur_col, __pyx_n_s_float) < 0))) __PYX_ERR(0, 1005, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1004 * elif var_type == READSTAT_TYPE_INT32: * readstat_types[cur_col] = "int32" * elif var_type == READSTAT_TYPE_FLOAT: # <<<<<<<<<<<<<< * readstat_types[cur_col] = "float" * elif var_type == READSTAT_TYPE_DOUBLE: */ break; case READSTAT_TYPE_DOUBLE: /* "pyreadstat/_readstat_parser.pyx":1007 * readstat_types[cur_col] = "float" * elif var_type == READSTAT_TYPE_DOUBLE: * readstat_types[cur_col] = "double" # <<<<<<<<<<<<<< * else: * raise PyreadstatError("Unkown data type") */ if (unlikely((PyDict_SetItem(__pyx_v_readstat_types, __pyx_v_cur_col, __pyx_n_s_double) < 0))) __PYX_ERR(0, 1007, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1006 * elif var_type == READSTAT_TYPE_FLOAT: * readstat_types[cur_col] = "float" * elif var_type == READSTAT_TYPE_DOUBLE: # <<<<<<<<<<<<<< * readstat_types[cur_col] = "double" * else: */ break; default: /* "pyreadstat/_readstat_parser.pyx":1009 * readstat_types[cur_col] = "double" * else: * raise PyreadstatError("Unkown data type") # <<<<<<<<<<<<<< * * for indx, curset in data.missing_user_values.items(): */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1009, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_kp_s_Unkown_data_type}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1009, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 1009, __pyx_L1_error) break; } /* "pyreadstat/_readstat_parser.pyx":991 * original_types = dict() * readstat_types = dict() * for indx in range(metadata.number_columns): # <<<<<<<<<<<<<< * cur_col = data.col_names[indx] * cur_type = data.col_formats_original[indx] */ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":1011 * raise PyreadstatError("Unkown data type") * * for indx, curset in data.missing_user_values.items(): # <<<<<<<<<<<<<< * cur_col = data.col_names[indx] * metadata.missing_user_values[cur_col] = sorted(list(curset)) */ if (unlikely(__pyx_v_data->missing_user_values == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 1011, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyDict_Items(__pyx_v_data->missing_user_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1011, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1011, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 1011, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1011, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 1011, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1011, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1011, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_8 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); index = 0; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 1011, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L18_unpacking_done; __pyx_L17_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1011, __pyx_L1_error) __pyx_L18_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_indx, __pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_curset, __pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_parser.pyx":1012 * * for indx, curset in data.missing_user_values.items(): * cur_col = data.col_names[indx] # <<<<<<<<<<<<<< * metadata.missing_user_values[cur_col] = sorted(list(curset)) * */ if (unlikely(__pyx_v_data->col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 1012, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_data->col_names, __pyx_v_indx); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1012, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_cur_col, __pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":1013 * for indx, curset in data.missing_user_values.items(): * cur_col = data.col_names[indx] * metadata.missing_user_values[cur_col] = sorted(list(curset)) # <<<<<<<<<<<<<< * * metadata.notes = data.notes */ __pyx_t_4 = PySequence_List(__pyx_v_curset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = PySequence_List(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = ((PyObject*)__pyx_t_8); __pyx_t_8 = 0; __pyx_t_12 = PyList_Sort(__pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 1013, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_metadata, __pyx_n_s_missing_user_values); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_t_8, __pyx_v_cur_col, __pyx_t_3) < 0))) __PYX_ERR(0, 1013, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":1011 * raise PyreadstatError("Unkown data type") * * for indx, curset in data.missing_user_values.items(): # <<<<<<<<<<<<<< * cur_col = data.col_names[indx] * metadata.missing_user_values[cur_col] = sorted(list(curset)) */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1015 * metadata.missing_user_values[cur_col] = sorted(list(curset)) * * metadata.notes = data.notes # <<<<<<<<<<<<<< * metadata.column_names = data.col_names * metadata.column_labels = data.col_labels */ __pyx_t_2 = __pyx_v_data->notes; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_notes, __pyx_t_2) < 0) __PYX_ERR(0, 1015, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1016 * * metadata.notes = data.notes * metadata.column_names = data.col_names # <<<<<<<<<<<<<< * metadata.column_labels = data.col_labels * metadata.column_names_to_labels = {k:v for k,v in zip(data.col_names, data.col_labels)} */ __pyx_t_2 = __pyx_v_data->col_names; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_column_names, __pyx_t_2) < 0) __PYX_ERR(0, 1016, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1017 * metadata.notes = data.notes * metadata.column_names = data.col_names * metadata.column_labels = data.col_labels # <<<<<<<<<<<<<< * metadata.column_names_to_labels = {k:v for k,v in zip(data.col_names, data.col_labels)} * metadata.file_encoding = data.file_encoding */ __pyx_t_2 = __pyx_v_data->col_labels; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_column_labels, __pyx_t_2) < 0) __PYX_ERR(0, 1017, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1018 * metadata.column_names = data.col_names * metadata.column_labels = data.col_labels * metadata.column_names_to_labels = {k:v for k,v in zip(data.col_names, data.col_labels)} # <<<<<<<<<<<<<< * metadata.file_encoding = data.file_encoding * metadata.file_label = data.file_label */ { /* enter inner scope */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_data->col_names); __Pyx_GIVEREF(__pyx_v_data->col_names); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data->col_names)) __PYX_ERR(0, 1018, __pyx_L22_error); __Pyx_INCREF(__pyx_v_data->col_labels); __Pyx_GIVEREF(__pyx_v_data->col_labels); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_data->col_labels)) __PYX_ERR(0, 1018, __pyx_L22_error); __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) { __pyx_t_3 = __pyx_t_8; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1018, __pyx_L22_error) } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1018, __pyx_L22_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 1018, __pyx_L22_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1018, __pyx_L22_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 1018, __pyx_L22_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1018, __pyx_L22_error) } break; } __Pyx_GOTREF(__pyx_t_8); } if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) { PyObject* sequence = __pyx_t_8; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1018, __pyx_L22_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_4 = PyList_GET_ITEM(sequence, 0); __pyx_t_9 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_9); #else __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else { Py_ssize_t index = -1; __pyx_t_13 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1018, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_13); index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_4)) goto __pyx_L25_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_9 = __pyx_t_10(__pyx_t_13); if (unlikely(!__pyx_t_9)) goto __pyx_L25_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_13), 2) < 0) __PYX_ERR(0, 1018, __pyx_L22_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L26_unpacking_done; __pyx_L25_unpacking_failed:; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1018, __pyx_L22_error) __pyx_L26_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_k, __pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_v, __pyx_t_9); __pyx_t_9 = 0; if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_7genexpr__pyx_v_k, (PyObject*)__pyx_7genexpr__pyx_v_v))) __PYX_ERR(0, 1018, __pyx_L22_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __pyx_7genexpr__pyx_v_k = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __pyx_7genexpr__pyx_v_v = 0; goto __pyx_L28_exit_scope; __pyx_L22_error:; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __pyx_7genexpr__pyx_v_k = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __pyx_7genexpr__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L28_exit_scope:; } /* exit inner scope */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_column_names_to_labels, __pyx_t_2) < 0) __PYX_ERR(0, 1018, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1019 * metadata.column_labels = data.col_labels * metadata.column_names_to_labels = {k:v for k,v in zip(data.col_names, data.col_labels)} * metadata.file_encoding = data.file_encoding # <<<<<<<<<<<<<< * metadata.file_label = data.file_label * metadata.variable_value_labels = variable_value_labels */ __pyx_t_2 = __pyx_v_data->file_encoding; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_file_encoding, __pyx_t_2) < 0) __PYX_ERR(0, 1019, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1020 * metadata.column_names_to_labels = {k:v for k,v in zip(data.col_names, data.col_labels)} * metadata.file_encoding = data.file_encoding * metadata.file_label = data.file_label # <<<<<<<<<<<<<< * metadata.variable_value_labels = variable_value_labels * metadata.value_labels = labels_raw */ __pyx_t_2 = __pyx_v_data->file_label; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_file_label, __pyx_t_2) < 0) __PYX_ERR(0, 1020, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1021 * metadata.file_encoding = data.file_encoding * metadata.file_label = data.file_label * metadata.variable_value_labels = variable_value_labels # <<<<<<<<<<<<<< * metadata.value_labels = labels_raw * metadata.variable_to_label = label_to_var_name */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_variable_value_labels, __pyx_v_variable_value_labels) < 0) __PYX_ERR(0, 1021, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1022 * metadata.file_label = data.file_label * metadata.variable_value_labels = variable_value_labels * metadata.value_labels = labels_raw # <<<<<<<<<<<<<< * metadata.variable_to_label = label_to_var_name * metadata.original_variable_types = original_types */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_value_labels, __pyx_v_labels_raw) < 0) __PYX_ERR(0, 1022, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1023 * metadata.variable_value_labels = variable_value_labels * metadata.value_labels = labels_raw * metadata.variable_to_label = label_to_var_name # <<<<<<<<<<<<<< * metadata.original_variable_types = original_types * metadata.readstat_variable_types = readstat_types */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_variable_to_label, __pyx_v_label_to_var_name) < 0) __PYX_ERR(0, 1023, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1024 * metadata.value_labels = labels_raw * metadata.variable_to_label = label_to_var_name * metadata.original_variable_types = original_types # <<<<<<<<<<<<<< * metadata.readstat_variable_types = readstat_types * metadata.table_name = data.table_name */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_original_variable_types, __pyx_v_original_types) < 0) __PYX_ERR(0, 1024, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1025 * metadata.variable_to_label = label_to_var_name * metadata.original_variable_types = original_types * metadata.readstat_variable_types = readstat_types # <<<<<<<<<<<<<< * metadata.table_name = data.table_name * metadata.missing_ranges = data.missing_ranges */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_readstat_variable_types, __pyx_v_readstat_types) < 0) __PYX_ERR(0, 1025, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1026 * metadata.original_variable_types = original_types * metadata.readstat_variable_types = readstat_types * metadata.table_name = data.table_name # <<<<<<<<<<<<<< * metadata.missing_ranges = data.missing_ranges * metadata.variable_storage_width = data.variable_storage_width */ __pyx_t_2 = __pyx_v_data->table_name; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_table_name, __pyx_t_2) < 0) __PYX_ERR(0, 1026, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1027 * metadata.readstat_variable_types = readstat_types * metadata.table_name = data.table_name * metadata.missing_ranges = data.missing_ranges # <<<<<<<<<<<<<< * metadata.variable_storage_width = data.variable_storage_width * metadata.variable_display_width = data.variable_display_width */ __pyx_t_2 = __pyx_v_data->missing_ranges; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_missing_ranges, __pyx_t_2) < 0) __PYX_ERR(0, 1027, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1028 * metadata.table_name = data.table_name * metadata.missing_ranges = data.missing_ranges * metadata.variable_storage_width = data.variable_storage_width # <<<<<<<<<<<<<< * metadata.variable_display_width = data.variable_display_width * metadata.variable_alignment = data.variable_alignment */ __pyx_t_2 = __pyx_v_data->variable_storage_width; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_variable_storage_width, __pyx_t_2) < 0) __PYX_ERR(0, 1028, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1029 * metadata.missing_ranges = data.missing_ranges * metadata.variable_storage_width = data.variable_storage_width * metadata.variable_display_width = data.variable_display_width # <<<<<<<<<<<<<< * metadata.variable_alignment = data.variable_alignment * metadata.variable_measure = data.variable_measure */ __pyx_t_2 = __pyx_v_data->variable_display_width; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_variable_display_width, __pyx_t_2) < 0) __PYX_ERR(0, 1029, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1030 * metadata.variable_storage_width = data.variable_storage_width * metadata.variable_display_width = data.variable_display_width * metadata.variable_alignment = data.variable_alignment # <<<<<<<<<<<<<< * metadata.variable_measure = data.variable_measure * metadata.creation_time = datetime.datetime.fromtimestamp(data.ctime) */ __pyx_t_2 = __pyx_v_data->variable_alignment; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_variable_alignment, __pyx_t_2) < 0) __PYX_ERR(0, 1030, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1031 * metadata.variable_display_width = data.variable_display_width * metadata.variable_alignment = data.variable_alignment * metadata.variable_measure = data.variable_measure # <<<<<<<<<<<<<< * metadata.creation_time = datetime.datetime.fromtimestamp(data.ctime) * metadata.modification_time = datetime.datetime.fromtimestamp(data.mtime) */ __pyx_t_2 = __pyx_v_data->variable_measure; __Pyx_INCREF(__pyx_t_2); if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_variable_measure, __pyx_t_2) < 0) __PYX_ERR(0, 1031, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1032 * metadata.variable_alignment = data.variable_alignment * metadata.variable_measure = data.variable_measure * metadata.creation_time = datetime.datetime.fromtimestamp(data.ctime) # <<<<<<<<<<<<<< * metadata.modification_time = datetime.datetime.fromtimestamp(data.mtime) * */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1032, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1032, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_fromtimestamp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1032, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_data->ctime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1032, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1032, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_creation_time, __pyx_t_2) < 0) __PYX_ERR(0, 1032, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1033 * metadata.variable_measure = data.variable_measure * metadata.creation_time = datetime.datetime.fromtimestamp(data.ctime) * metadata.modification_time = datetime.datetime.fromtimestamp(data.mtime) # <<<<<<<<<<<<<< * * return metadata */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_fromtimestamp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_data->mtime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_modification_time, __pyx_t_2) < 0) __PYX_ERR(0, 1033, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":1035 * metadata.modification_time = datetime.datetime.fromtimestamp(data.mtime) * * return metadata # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_metadata); __pyx_r = __pyx_v_metadata; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":948 * * * cdef object data_container_extract_metadata(data_container data): # <<<<<<<<<<<<<< * """ * Extracts metadata from a data container and puts it into a metadata */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("pyreadstat._readstat_parser.data_container_extract_metadata", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_label_to_var_name); __Pyx_XDECREF(__pyx_v_labels_raw); __Pyx_XDECREF(__pyx_v_var_name); __Pyx_XDECREF(__pyx_v_var_label); __Pyx_XDECREF(__pyx_v_current_labels); __Pyx_XDECREF(__pyx_v_original_types); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XDECREF(__pyx_v_variable_value_labels); __Pyx_XDECREF(__pyx_v_readstat_types); __Pyx_XDECREF(__pyx_v_indx); __Pyx_XDECREF(__pyx_v_cur_col); __Pyx_XDECREF(__pyx_v_cur_type); __Pyx_XDECREF(__pyx_v_curset); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_parser.pyx":1038 * * * cdef object run_conversion(object filename_path, py_file_format file_format, py_file_extension file_extension, # <<<<<<<<<<<<<< * str encoding, bint metaonly, bint dates_as_pandas, list usecols, bint usernan, * bint no_datetime_conversion, long row_limit, long row_offset, str output_format, */ static PyObject *__pyx_f_10pyreadstat_16_readstat_parser_run_conversion(PyObject *__pyx_v_filename_path, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format, __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_v_file_extension, PyObject *__pyx_v_encoding, int __pyx_v_metaonly, int __pyx_v_dates_as_pandas, PyObject *__pyx_v_usecols, int __pyx_v_usernan, int __pyx_v_no_datetime_conversion, long __pyx_v_row_limit, long __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats) { PyObject *__pyx_v_filename_bytes = 0; char *__pyx_v_filename; struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *__pyx_v_data = 0; PyObject *__pyx_v_origin = 0; PyObject *__pyx_v_allowed_formats = 0; PyObject *__pyx_v_data_dict = 0; PyObject *__pyx_v_data_frame = 0; CYTHON_UNUSED void *__pyx_v_ctx; PyObject *__pyx_v_metadata = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; int __pyx_t_14; int __pyx_t_15; char *__pyx_t_16; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("run_conversion", 0); __Pyx_INCREF(__pyx_v_output_format); /* "pyreadstat/_readstat_parser.pyx":1055 * cdef object data_frame * * if hasattr(os, 'fsencode'): # <<<<<<<<<<<<<< * try: * filename_bytes = os.fsencode(filename_path) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1055, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_HasAttr(__pyx_t_1, __pyx_n_s_fsencode); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 1055, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1056 * * if hasattr(os, 'fsencode'): * try: # <<<<<<<<<<<<<< * filename_bytes = os.fsencode(filename_path) * except UnicodeError: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); /*try:*/ { /* "pyreadstat/_readstat_parser.pyx":1057 * if hasattr(os, 'fsencode'): * try: * filename_bytes = os.fsencode(filename_path) # <<<<<<<<<<<<<< * except UnicodeError: * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) */ __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1057, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_fsencode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1057, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_filename_path}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1057, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_1))) __PYX_ERR(0, 1057, __pyx_L4_error) __pyx_v_filename_bytes = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_parser.pyx":1056 * * if hasattr(os, 'fsencode'): * try: # <<<<<<<<<<<<<< * filename_bytes = os.fsencode(filename_path) * except UnicodeError: */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* "pyreadstat/_readstat_parser.pyx":1058 * try: * filename_bytes = os.fsencode(filename_path) * except UnicodeError: # <<<<<<<<<<<<<< * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") */ __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeError); if (__pyx_t_8) { __Pyx_AddTraceback("pyreadstat._readstat_parser.run_conversion", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 1058, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_6); /* "pyreadstat/_readstat_parser.pyx":1059 * filename_bytes = os.fsencode(filename_path) * except UnicodeError: * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) # <<<<<<<<<<<<<< * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") * else: */ __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_warnings); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_warn); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_sys); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_getfilesystemencoding); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_t_13 = __Pyx_PyString_FormatSafe(__pyx_kp_s_file_path_could_not_be_encoded_w, __pyx_t_10); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_13}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1059, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/_readstat_parser.pyx":1060 * except UnicodeError: * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") # <<<<<<<<<<<<<< * else: * if type(filename_path) == str: */ __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_os); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_fsdecode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_v_filename_path}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_encode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (!(likely(PyBytes_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_9))) __PYX_ERR(0, 1060, __pyx_L6_except_error) __Pyx_XDECREF_SET(__pyx_v_filename_bytes, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L5_exception_handled; } goto __pyx_L6_except_error; /* "pyreadstat/_readstat_parser.pyx":1056 * * if hasattr(os, 'fsencode'): * try: # <<<<<<<<<<<<<< * filename_bytes = os.fsencode(filename_path) * except UnicodeError: */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L1_error; __pyx_L5_exception_handled:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); __pyx_L9_try_end:; } /* "pyreadstat/_readstat_parser.pyx":1055 * cdef object data_frame * * if hasattr(os, 'fsencode'): # <<<<<<<<<<<<<< * try: * filename_bytes = os.fsencode(filename_path) */ goto __pyx_L3; } /* "pyreadstat/_readstat_parser.pyx":1062 * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") * else: * if type(filename_path) == str: # <<<<<<<<<<<<<< * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: */ /*else*/ { __pyx_t_6 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_filename_path)), ((PyObject *)(&PyString_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1062, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1062, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1063 * else: * if type(filename_path) == str: * filename_bytes = filename_path.encode('utf-8') # <<<<<<<<<<<<<< * elif type(filename_path) == bytes: * filename_bytes = filename_path */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename_path, __pyx_n_s_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_s_utf_8}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1063, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (!(likely(PyBytes_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_6))) __PYX_ERR(0, 1063, __pyx_L1_error) __pyx_v_filename_bytes = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":1062 * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") * else: * if type(filename_path) == str: # <<<<<<<<<<<<<< * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: */ goto __pyx_L12; } /* "pyreadstat/_readstat_parser.pyx":1064 * if type(filename_path) == str: * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: # <<<<<<<<<<<<<< * filename_bytes = filename_path * else: */ __pyx_t_6 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_filename_path)), ((PyObject *)(&PyBytes_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1064, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1064, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (likely(__pyx_t_2)) { /* "pyreadstat/_readstat_parser.pyx":1065 * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: * filename_bytes = filename_path # <<<<<<<<<<<<<< * else: * raise PyreadstatError("path must be either str or bytes") */ if (!(likely(PyBytes_CheckExact(__pyx_v_filename_path))||((__pyx_v_filename_path) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_v_filename_path))) __PYX_ERR(0, 1065, __pyx_L1_error) __pyx_t_6 = __pyx_v_filename_path; __Pyx_INCREF(__pyx_t_6); __pyx_v_filename_bytes = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":1064 * if type(filename_path) == str: * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: # <<<<<<<<<<<<<< * filename_bytes = filename_path * else: */ goto __pyx_L12; } /* "pyreadstat/_readstat_parser.pyx":1067 * filename_bytes = filename_path * else: * raise PyreadstatError("path must be either str or bytes") # <<<<<<<<<<<<<< * if type(filename_path) not in (str, bytes, unicode): * raise PyreadstatError("path must be str, bytes or unicode") */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_s_path_must_be_either_str_or_bytes}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1067, __pyx_L1_error) } __pyx_L12:; /* "pyreadstat/_readstat_parser.pyx":1068 * else: * raise PyreadstatError("path must be either str or bytes") * if type(filename_path) not in (str, bytes, unicode): # <<<<<<<<<<<<<< * raise PyreadstatError("path must be str, bytes or unicode") * filename_bytes = filename_path.encode('utf-8') */ __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_filename_path))); __pyx_t_6 = ((PyObject *)Py_TYPE(__pyx_v_filename_path)); __pyx_t_7 = PyObject_RichCompare(((PyObject *)__pyx_t_6), ((PyObject *)(&PyString_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1068, __pyx_L1_error) __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_14 < 0))) __PYX_ERR(0, 1068, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L14_bool_binop_done; } __pyx_t_7 = PyObject_RichCompare(((PyObject *)__pyx_t_6), ((PyObject *)(&PyBytes_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1068, __pyx_L1_error) __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_14 < 0))) __PYX_ERR(0, 1068, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L14_bool_binop_done; } __pyx_t_7 = PyObject_RichCompare(((PyObject *)__pyx_t_6), ((PyObject *)(&PyUnicode_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1068, __pyx_L1_error) __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_14 < 0))) __PYX_ERR(0, 1068, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_2 = __pyx_t_14; __pyx_L14_bool_binop_done:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_14 = __pyx_t_2; if (unlikely(__pyx_t_14)) { /* "pyreadstat/_readstat_parser.pyx":1069 * raise PyreadstatError("path must be either str or bytes") * if type(filename_path) not in (str, bytes, unicode): * raise PyreadstatError("path must be str, bytes or unicode") # <<<<<<<<<<<<<< * filename_bytes = filename_path.encode('utf-8') * */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_s_path_must_be_str_bytes_or_unicod}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1069, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1068 * else: * raise PyreadstatError("path must be either str or bytes") * if type(filename_path) not in (str, bytes, unicode): # <<<<<<<<<<<<<< * raise PyreadstatError("path must be str, bytes or unicode") * filename_bytes = filename_path.encode('utf-8') */ } /* "pyreadstat/_readstat_parser.pyx":1070 * if type(filename_path) not in (str, bytes, unicode): * raise PyreadstatError("path must be str, bytes or unicode") * filename_bytes = filename_path.encode('utf-8') # <<<<<<<<<<<<<< * * */ __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename_path, __pyx_n_s_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_s_utf_8}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1070, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (!(likely(PyBytes_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_6))) __PYX_ERR(0, 1070, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_filename_bytes, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0; } __pyx_L3:; /* "pyreadstat/_readstat_parser.pyx":1073 * * * filename_bytes = os.path.expanduser(filename_bytes) # <<<<<<<<<<<<<< * if not os.path.isfile(filename_bytes): * raise PyreadstatError("File {0} does not exist!".format(filename_path)) */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_expanduser); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_filename_bytes}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (!(likely(PyBytes_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_6))) __PYX_ERR(0, 1073, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_filename_bytes, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":1074 * * filename_bytes = os.path.expanduser(filename_bytes) * if not os.path.isfile(filename_bytes): # <<<<<<<<<<<<<< * raise PyreadstatError("File {0} does not exist!".format(filename_path)) * */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isfile); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_filename_bytes}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_14 < 0))) __PYX_ERR(0, 1074, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = (!__pyx_t_14); if (unlikely(__pyx_t_2)) { /* "pyreadstat/_readstat_parser.pyx":1075 * filename_bytes = os.path.expanduser(filename_bytes) * if not os.path.isfile(filename_bytes): * raise PyreadstatError("File {0} does not exist!".format(filename_path)) # <<<<<<<<<<<<<< * * if output_format is None: */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_File_0_does_not_exist, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_13 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_v_filename_path}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_1}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1075, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1074 * * filename_bytes = os.path.expanduser(filename_bytes) * if not os.path.isfile(filename_bytes): # <<<<<<<<<<<<<< * raise PyreadstatError("File {0} does not exist!".format(filename_path)) * */ } /* "pyreadstat/_readstat_parser.pyx":1077 * raise PyreadstatError("File {0} does not exist!".format(filename_path)) * * if output_format is None: # <<<<<<<<<<<<<< * output_format = 'pandas' * allowed_formats = {'pandas', 'dict'} */ __pyx_t_2 = (__pyx_v_output_format == ((PyObject*)Py_None)); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1078 * * if output_format is None: * output_format = 'pandas' # <<<<<<<<<<<<<< * allowed_formats = {'pandas', 'dict'} * if output_format not in allowed_formats: */ __Pyx_INCREF(__pyx_n_s_pandas); __Pyx_DECREF_SET(__pyx_v_output_format, __pyx_n_s_pandas); /* "pyreadstat/_readstat_parser.pyx":1077 * raise PyreadstatError("File {0} does not exist!".format(filename_path)) * * if output_format is None: # <<<<<<<<<<<<<< * output_format = 'pandas' * allowed_formats = {'pandas', 'dict'} */ } /* "pyreadstat/_readstat_parser.pyx":1079 * if output_format is None: * output_format = 'pandas' * allowed_formats = {'pandas', 'dict'} # <<<<<<<<<<<<<< * if output_format not in allowed_formats: * raise PyreadstatError("output format must be one of {allowed_formats}, '{output_format}' was given".format(allowed_formats=allowed_formats, output_format=output_format)) */ __pyx_t_6 = PySet_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PySet_Add(__pyx_t_6, __pyx_n_s_pandas) < 0) __PYX_ERR(0, 1079, __pyx_L1_error) if (PySet_Add(__pyx_t_6, __pyx_n_s_dict) < 0) __PYX_ERR(0, 1079, __pyx_L1_error) __pyx_v_allowed_formats = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":1080 * output_format = 'pandas' * allowed_formats = {'pandas', 'dict'} * if output_format not in allowed_formats: # <<<<<<<<<<<<<< * raise PyreadstatError("output format must be one of {allowed_formats}, '{output_format}' was given".format(allowed_formats=allowed_formats, output_format=output_format)) * */ __pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_v_output_format, __pyx_v_allowed_formats, Py_NE)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1080, __pyx_L1_error) if (unlikely(__pyx_t_2)) { /* "pyreadstat/_readstat_parser.pyx":1081 * allowed_formats = {'pandas', 'dict'} * if output_format not in allowed_formats: * raise PyreadstatError("output format must be one of {allowed_formats}, '{output_format}' was given".format(allowed_formats=allowed_formats, output_format=output_format)) # <<<<<<<<<<<<<< * * if extra_date_formats is not None: */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_output_format_must_be_one_of_all, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_allowed_formats, __pyx_v_allowed_formats) < 0) __PYX_ERR(0, 1081, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_output_format, __pyx_v_output_format) < 0) __PYX_ERR(0, 1081, __pyx_L1_error) __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_13}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1081, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1080 * output_format = 'pandas' * allowed_formats = {'pandas', 'dict'} * if output_format not in allowed_formats: # <<<<<<<<<<<<<< * raise PyreadstatError("output format must be one of {allowed_formats}, '{output_format}' was given".format(allowed_formats=allowed_formats, output_format=output_format)) * */ } /* "pyreadstat/_readstat_parser.pyx":1083 * raise PyreadstatError("output format must be one of {allowed_formats}, '{output_format}' was given".format(allowed_formats=allowed_formats, output_format=output_format)) * * if extra_date_formats is not None: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SAS: * sas_date_formats.extend(extra_date_formats) */ __pyx_t_2 = (__pyx_v_extra_date_formats != ((PyObject*)Py_None)); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1084 * * if extra_date_formats is not None: * if file_format == FILE_FORMAT_SAS: # <<<<<<<<<<<<<< * sas_date_formats.extend(extra_date_formats) * elif file_format == FILE_FORMAT_SPSS: */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS: /* "pyreadstat/_readstat_parser.pyx":1085 * if extra_date_formats is not None: * if file_format == FILE_FORMAT_SAS: * sas_date_formats.extend(extra_date_formats) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_SPSS: * spss_date_formats.extend(extra_date_formats) */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend"); __PYX_ERR(0, 1085, __pyx_L1_error) } __pyx_t_15 = __Pyx_PyList_Extend(__pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats, __pyx_v_extra_date_formats); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1085, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1084 * * if extra_date_formats is not None: * if file_format == FILE_FORMAT_SAS: # <<<<<<<<<<<<<< * sas_date_formats.extend(extra_date_formats) * elif file_format == FILE_FORMAT_SPSS: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS: /* "pyreadstat/_readstat_parser.pyx":1087 * sas_date_formats.extend(extra_date_formats) * elif file_format == FILE_FORMAT_SPSS: * spss_date_formats.extend(extra_date_formats) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_STATA: * stata_date_formats.extend(extra_date_formats) */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend"); __PYX_ERR(0, 1087, __pyx_L1_error) } __pyx_t_15 = __Pyx_PyList_Extend(__pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats, __pyx_v_extra_date_formats); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1087, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1086 * if file_format == FILE_FORMAT_SAS: * sas_date_formats.extend(extra_date_formats) * elif file_format == FILE_FORMAT_SPSS: # <<<<<<<<<<<<<< * spss_date_formats.extend(extra_date_formats) * elif file_format == FILE_FORMAT_STATA: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA: /* "pyreadstat/_readstat_parser.pyx":1089 * spss_date_formats.extend(extra_date_formats) * elif file_format == FILE_FORMAT_STATA: * stata_date_formats.extend(extra_date_formats) # <<<<<<<<<<<<<< * else: * raise PyreadstatError("Unknown file format") */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend"); __PYX_ERR(0, 1089, __pyx_L1_error) } __pyx_t_15 = __Pyx_PyList_Extend(__pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats, __pyx_v_extra_date_formats); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1089, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1088 * elif file_format == FILE_FORMAT_SPSS: * spss_date_formats.extend(extra_date_formats) * elif file_format == FILE_FORMAT_STATA: # <<<<<<<<<<<<<< * stata_date_formats.extend(extra_date_formats) * else: */ break; default: /* "pyreadstat/_readstat_parser.pyx":1091 * stata_date_formats.extend(extra_date_formats) * else: * raise PyreadstatError("Unknown file format") # <<<<<<<<<<<<<< * if extra_datetime_formats is not None: * if file_format == FILE_FORMAT_SAS: */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_13 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_kp_s_Unknown_file_format}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1091, __pyx_L1_error) break; } /* "pyreadstat/_readstat_parser.pyx":1083 * raise PyreadstatError("output format must be one of {allowed_formats}, '{output_format}' was given".format(allowed_formats=allowed_formats, output_format=output_format)) * * if extra_date_formats is not None: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SAS: * sas_date_formats.extend(extra_date_formats) */ } /* "pyreadstat/_readstat_parser.pyx":1092 * else: * raise PyreadstatError("Unknown file format") * if extra_datetime_formats is not None: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SAS: * sas_datetime_formats.extend(extra_datetime_formats) */ __pyx_t_2 = (__pyx_v_extra_datetime_formats != ((PyObject*)Py_None)); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1093 * raise PyreadstatError("Unknown file format") * if extra_datetime_formats is not None: * if file_format == FILE_FORMAT_SAS: # <<<<<<<<<<<<<< * sas_datetime_formats.extend(extra_datetime_formats) * elif file_format == FILE_FORMAT_SPSS: */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS: /* "pyreadstat/_readstat_parser.pyx":1094 * if extra_datetime_formats is not None: * if file_format == FILE_FORMAT_SAS: * sas_datetime_formats.extend(extra_datetime_formats) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_SPSS: * spss_datetime_formats.extend(extra_datetime_formats) */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend"); __PYX_ERR(0, 1094, __pyx_L1_error) } __pyx_t_15 = __Pyx_PyList_Extend(__pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats, __pyx_v_extra_datetime_formats); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1094, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1093 * raise PyreadstatError("Unknown file format") * if extra_datetime_formats is not None: * if file_format == FILE_FORMAT_SAS: # <<<<<<<<<<<<<< * sas_datetime_formats.extend(extra_datetime_formats) * elif file_format == FILE_FORMAT_SPSS: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS: /* "pyreadstat/_readstat_parser.pyx":1096 * sas_datetime_formats.extend(extra_datetime_formats) * elif file_format == FILE_FORMAT_SPSS: * spss_datetime_formats.extend(extra_datetime_formats) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_STATA: * stata_datetime_formats.extend(extra_datetime_formats) */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend"); __PYX_ERR(0, 1096, __pyx_L1_error) } __pyx_t_15 = __Pyx_PyList_Extend(__pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats, __pyx_v_extra_datetime_formats); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1096, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1095 * if file_format == FILE_FORMAT_SAS: * sas_datetime_formats.extend(extra_datetime_formats) * elif file_format == FILE_FORMAT_SPSS: # <<<<<<<<<<<<<< * spss_datetime_formats.extend(extra_datetime_formats) * elif file_format == FILE_FORMAT_STATA: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA: /* "pyreadstat/_readstat_parser.pyx":1098 * spss_datetime_formats.extend(extra_datetime_formats) * elif file_format == FILE_FORMAT_STATA: * stata_datetime_formats.extend(extra_datetime_formats) # <<<<<<<<<<<<<< * else: * raise PyreadstatError("Unknown file format") */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "extend"); __PYX_ERR(0, 1098, __pyx_L1_error) } __pyx_t_15 = __Pyx_PyList_Extend(__pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats, __pyx_v_extra_datetime_formats); if (unlikely(__pyx_t_15 == ((int)-1))) __PYX_ERR(0, 1098, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1097 * elif file_format == FILE_FORMAT_SPSS: * spss_datetime_formats.extend(extra_datetime_formats) * elif file_format == FILE_FORMAT_STATA: # <<<<<<<<<<<<<< * stata_datetime_formats.extend(extra_datetime_formats) * else: */ break; default: /* "pyreadstat/_readstat_parser.pyx":1100 * stata_datetime_formats.extend(extra_datetime_formats) * else: * raise PyreadstatError("Unknown file format") # <<<<<<<<<<<<<< * global sas_all_formats, spss_all_formats, stata_all_formats * sas_all_formats = sas_date_formats + sas_datetime_formats + sas_time_formats */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_13 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_kp_s_Unknown_file_format}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 1100, __pyx_L1_error) break; } /* "pyreadstat/_readstat_parser.pyx":1092 * else: * raise PyreadstatError("Unknown file format") * if extra_datetime_formats is not None: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SAS: * sas_datetime_formats.extend(extra_datetime_formats) */ } /* "pyreadstat/_readstat_parser.pyx":1102 * raise PyreadstatError("Unknown file format") * global sas_all_formats, spss_all_formats, stata_all_formats * sas_all_formats = sas_date_formats + sas_datetime_formats + sas_time_formats # <<<<<<<<<<<<<< * stata_all_formats = stata_date_formats + stata_datetime_formats + stata_time_formats * spss_all_formats = spss_date_formats + spss_datetime_formats + spss_time_formats */ __pyx_t_6 = PyNumber_Add(__pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats, __pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyNumber_Add(__pyx_t_6, __pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_sas_all_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_sas_all_formats, ((PyObject*)__pyx_t_7)); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; /* "pyreadstat/_readstat_parser.pyx":1103 * global sas_all_formats, spss_all_formats, stata_all_formats * sas_all_formats = sas_date_formats + sas_datetime_formats + sas_time_formats * stata_all_formats = stata_date_formats + stata_datetime_formats + stata_time_formats # <<<<<<<<<<<<<< * spss_all_formats = spss_date_formats + spss_datetime_formats + spss_time_formats * */ __pyx_t_7 = PyNumber_Add(__pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats, __pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = PyNumber_Add(__pyx_t_7, __pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_stata_all_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_stata_all_formats, ((PyObject*)__pyx_t_6)); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; /* "pyreadstat/_readstat_parser.pyx":1104 * sas_all_formats = sas_date_formats + sas_datetime_formats + sas_time_formats * stata_all_formats = stata_date_formats + stata_datetime_formats + stata_time_formats * spss_all_formats = spss_date_formats + spss_datetime_formats + spss_time_formats # <<<<<<<<<<<<<< * * filename = filename_bytes */ __pyx_t_6 = PyNumber_Add(__pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats, __pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = PyNumber_Add(__pyx_t_6, __pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_spss_all_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_spss_all_formats, ((PyObject*)__pyx_t_7)); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; /* "pyreadstat/_readstat_parser.pyx":1106 * spss_all_formats = spss_date_formats + spss_datetime_formats + spss_time_formats * * filename = filename_bytes # <<<<<<<<<<<<<< * * data = data_container() */ if (unlikely(__pyx_v_filename_bytes == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 1106, __pyx_L1_error) } __pyx_t_16 = __Pyx_PyBytes_AsWritableString(__pyx_v_filename_bytes); if (unlikely((!__pyx_t_16) && PyErr_Occurred())) __PYX_ERR(0, 1106, __pyx_L1_error) __pyx_v_filename = ((char *)__pyx_t_16); /* "pyreadstat/_readstat_parser.pyx":1108 * filename = filename_bytes * * data = data_container() # <<<<<<<<<<<<<< * ctx = data * */ __pyx_t_7 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_10pyreadstat_16_readstat_parser_data_container)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_data = ((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)__pyx_t_7); __pyx_t_7 = 0; /* "pyreadstat/_readstat_parser.pyx":1109 * * data = data_container() * ctx = data # <<<<<<<<<<<<<< * * data.file_format = file_format */ __pyx_v_ctx = ((void *)__pyx_v_data); /* "pyreadstat/_readstat_parser.pyx":1111 * ctx = data * * data.file_format = file_format # <<<<<<<<<<<<<< * data.metaonly = metaonly * data.dates_as_pandas = dates_as_pandas */ __pyx_v_data->file_format = __pyx_v_file_format; /* "pyreadstat/_readstat_parser.pyx":1112 * * data.file_format = file_format * data.metaonly = metaonly # <<<<<<<<<<<<<< * data.dates_as_pandas = dates_as_pandas * */ __pyx_v_data->metaonly = __pyx_v_metaonly; /* "pyreadstat/_readstat_parser.pyx":1113 * data.file_format = file_format * data.metaonly = metaonly * data.dates_as_pandas = dates_as_pandas # <<<<<<<<<<<<<< * * if encoding: */ __pyx_v_data->dates_as_pandas = __pyx_v_dates_as_pandas; /* "pyreadstat/_readstat_parser.pyx":1115 * data.dates_as_pandas = dates_as_pandas * * if encoding: # <<<<<<<<<<<<<< * data.user_encoding = encoding * */ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_encoding); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1115, __pyx_L1_error) if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1116 * * if encoding: * data.user_encoding = encoding # <<<<<<<<<<<<<< * * if file_format == FILE_FORMAT_SAS: */ __Pyx_INCREF(__pyx_v_encoding); __Pyx_GIVEREF(__pyx_v_encoding); __Pyx_GOTREF(__pyx_v_data->user_encoding); __Pyx_DECREF(__pyx_v_data->user_encoding); __pyx_v_data->user_encoding = __pyx_v_encoding; /* "pyreadstat/_readstat_parser.pyx":1115 * data.dates_as_pandas = dates_as_pandas * * if encoding: # <<<<<<<<<<<<<< * data.user_encoding = encoding * */ } /* "pyreadstat/_readstat_parser.pyx":1118 * data.user_encoding = encoding * * if file_format == FILE_FORMAT_SAS: # <<<<<<<<<<<<<< * origin = sas_origin * elif file_format == FILE_FORMAT_SPSS: */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS: /* "pyreadstat/_readstat_parser.pyx":1119 * * if file_format == FILE_FORMAT_SAS: * origin = sas_origin # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_SPSS: * origin = spss_origin */ __Pyx_INCREF(__pyx_v_10pyreadstat_16_readstat_parser_sas_origin); __pyx_v_origin = __pyx_v_10pyreadstat_16_readstat_parser_sas_origin; /* "pyreadstat/_readstat_parser.pyx":1118 * data.user_encoding = encoding * * if file_format == FILE_FORMAT_SAS: # <<<<<<<<<<<<<< * origin = sas_origin * elif file_format == FILE_FORMAT_SPSS: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS: /* "pyreadstat/_readstat_parser.pyx":1121 * origin = sas_origin * elif file_format == FILE_FORMAT_SPSS: * origin = spss_origin # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_STATA: * origin = stata_origin */ __Pyx_INCREF(__pyx_v_10pyreadstat_16_readstat_parser_spss_origin); __pyx_v_origin = __pyx_v_10pyreadstat_16_readstat_parser_spss_origin; /* "pyreadstat/_readstat_parser.pyx":1120 * if file_format == FILE_FORMAT_SAS: * origin = sas_origin * elif file_format == FILE_FORMAT_SPSS: # <<<<<<<<<<<<<< * origin = spss_origin * elif file_format == FILE_FORMAT_STATA: */ break; case __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA: /* "pyreadstat/_readstat_parser.pyx":1123 * origin = spss_origin * elif file_format == FILE_FORMAT_STATA: * origin = stata_origin # <<<<<<<<<<<<<< * else: * raise PyreadstatError("Unknown file format") */ __Pyx_INCREF(__pyx_v_10pyreadstat_16_readstat_parser_stata_origin); __pyx_v_origin = __pyx_v_10pyreadstat_16_readstat_parser_stata_origin; /* "pyreadstat/_readstat_parser.pyx":1122 * elif file_format == FILE_FORMAT_SPSS: * origin = spss_origin * elif file_format == FILE_FORMAT_STATA: # <<<<<<<<<<<<<< * origin = stata_origin * else: */ break; default: /* "pyreadstat/_readstat_parser.pyx":1125 * origin = stata_origin * else: * raise PyreadstatError("Unknown file format") # <<<<<<<<<<<<<< * * data.origin = origin */ __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_13 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_kp_s_Unknown_file_format}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 1125, __pyx_L1_error) break; } /* "pyreadstat/_readstat_parser.pyx":1127 * raise PyreadstatError("Unknown file format") * * data.origin = origin # <<<<<<<<<<<<<< * * if usecols is not None: */ __Pyx_INCREF(__pyx_v_origin); __Pyx_GIVEREF(__pyx_v_origin); __Pyx_GOTREF(__pyx_v_data->origin); __Pyx_DECREF(__pyx_v_data->origin); __pyx_v_data->origin = __pyx_v_origin; /* "pyreadstat/_readstat_parser.pyx":1129 * data.origin = origin * * if usecols is not None: # <<<<<<<<<<<<<< * data.filter_cols = 1 * data.use_cols = usecols */ __pyx_t_2 = (__pyx_v_usecols != ((PyObject*)Py_None)); if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1130 * * if usecols is not None: * data.filter_cols = 1 # <<<<<<<<<<<<<< * data.use_cols = usecols * */ __pyx_v_data->filter_cols = 1; /* "pyreadstat/_readstat_parser.pyx":1131 * if usecols is not None: * data.filter_cols = 1 * data.use_cols = usecols # <<<<<<<<<<<<<< * * data.usernan = usernan */ __Pyx_INCREF(__pyx_v_usecols); __Pyx_GIVEREF(__pyx_v_usecols); __Pyx_GOTREF(__pyx_v_data->use_cols); __Pyx_DECREF(__pyx_v_data->use_cols); __pyx_v_data->use_cols = __pyx_v_usecols; /* "pyreadstat/_readstat_parser.pyx":1129 * data.origin = origin * * if usecols is not None: # <<<<<<<<<<<<<< * data.filter_cols = 1 * data.use_cols = usecols */ } /* "pyreadstat/_readstat_parser.pyx":1133 * data.use_cols = usecols * * data.usernan = usernan # <<<<<<<<<<<<<< * data.no_datetime_conversion = no_datetime_conversion * */ __pyx_v_data->usernan = __pyx_v_usernan; /* "pyreadstat/_readstat_parser.pyx":1134 * * data.usernan = usernan * data.no_datetime_conversion = no_datetime_conversion # <<<<<<<<<<<<<< * * # go! */ __pyx_v_data->no_datetime_conversion = __pyx_v_no_datetime_conversion; /* "pyreadstat/_readstat_parser.pyx":1137 * * # go! * run_readstat_parser(filename, data, file_extension, row_limit, row_offset) # <<<<<<<<<<<<<< * data_dict = data_container_to_dict(data) * if output_format == 'dict': */ __pyx_f_10pyreadstat_16_readstat_parser_run_readstat_parser(__pyx_v_filename, __pyx_v_data, __pyx_v_file_extension, __pyx_v_row_limit, __pyx_v_row_offset); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1137, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":1138 * # go! * run_readstat_parser(filename, data, file_extension, row_limit, row_offset) * data_dict = data_container_to_dict(data) # <<<<<<<<<<<<<< * if output_format == 'dict': * data_frame = data_dict */ __pyx_t_7 = __pyx_f_10pyreadstat_16_readstat_parser_data_container_to_dict(__pyx_v_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_data_dict = __pyx_t_7; __pyx_t_7 = 0; /* "pyreadstat/_readstat_parser.pyx":1139 * run_readstat_parser(filename, data, file_extension, row_limit, row_offset) * data_dict = data_container_to_dict(data) * if output_format == 'dict': # <<<<<<<<<<<<<< * data_frame = data_dict * elif output_format == 'pandas': */ __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_output_format, __pyx_n_s_dict, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1139, __pyx_L1_error) if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1140 * data_dict = data_container_to_dict(data) * if output_format == 'dict': * data_frame = data_dict # <<<<<<<<<<<<<< * elif output_format == 'pandas': * data_frame = dict_to_pandas_dataframe(data_dict, data) */ __Pyx_INCREF(__pyx_v_data_dict); __pyx_v_data_frame = __pyx_v_data_dict; /* "pyreadstat/_readstat_parser.pyx":1139 * run_readstat_parser(filename, data, file_extension, row_limit, row_offset) * data_dict = data_container_to_dict(data) * if output_format == 'dict': # <<<<<<<<<<<<<< * data_frame = data_dict * elif output_format == 'pandas': */ goto __pyx_L24; } /* "pyreadstat/_readstat_parser.pyx":1141 * if output_format == 'dict': * data_frame = data_dict * elif output_format == 'pandas': # <<<<<<<<<<<<<< * data_frame = dict_to_pandas_dataframe(data_dict, data) * metadata = data_container_extract_metadata(data) */ __pyx_t_2 = (__Pyx_PyString_Equals(__pyx_v_output_format, __pyx_n_s_pandas, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1141, __pyx_L1_error) if (__pyx_t_2) { /* "pyreadstat/_readstat_parser.pyx":1142 * data_frame = data_dict * elif output_format == 'pandas': * data_frame = dict_to_pandas_dataframe(data_dict, data) # <<<<<<<<<<<<<< * metadata = data_container_extract_metadata(data) * */ __pyx_t_7 = __pyx_f_10pyreadstat_16_readstat_parser_dict_to_pandas_dataframe(__pyx_v_data_dict, __pyx_v_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_data_frame = __pyx_t_7; __pyx_t_7 = 0; /* "pyreadstat/_readstat_parser.pyx":1141 * if output_format == 'dict': * data_frame = data_dict * elif output_format == 'pandas': # <<<<<<<<<<<<<< * data_frame = dict_to_pandas_dataframe(data_dict, data) * metadata = data_container_extract_metadata(data) */ } __pyx_L24:; /* "pyreadstat/_readstat_parser.pyx":1143 * elif output_format == 'pandas': * data_frame = dict_to_pandas_dataframe(data_dict, data) * metadata = data_container_extract_metadata(data) # <<<<<<<<<<<<<< * * return data_frame, metadata */ __pyx_t_7 = __pyx_f_10pyreadstat_16_readstat_parser_data_container_extract_metadata(__pyx_v_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_metadata = __pyx_t_7; __pyx_t_7 = 0; /* "pyreadstat/_readstat_parser.pyx":1145 * metadata = data_container_extract_metadata(data) * * return data_frame, metadata # <<<<<<<<<<<<<< * */ __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_data_frame)) { __Pyx_RaiseUnboundLocalError("data_frame"); __PYX_ERR(0, 1145, __pyx_L1_error) } __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_data_frame)) __PYX_ERR(0, 1145, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_metadata)) __PYX_ERR(0, 1145, __pyx_L1_error); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0; /* "pyreadstat/_readstat_parser.pyx":1038 * * * cdef object run_conversion(object filename_path, py_file_format file_format, py_file_extension file_extension, # <<<<<<<<<<<<<< * str encoding, bint metaonly, bint dates_as_pandas, list usecols, bint usernan, * bint no_datetime_conversion, long row_limit, long row_offset, str output_format, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("pyreadstat._readstat_parser.run_conversion", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_filename_bytes); __Pyx_XDECREF((PyObject *)__pyx_v_data); __Pyx_XDECREF(__pyx_v_origin); __Pyx_XDECREF(__pyx_v_allowed_formats); __Pyx_XDECREF(__pyx_v_data_dict); __Pyx_XDECREF(__pyx_v_data_frame); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XDECREF(__pyx_v_output_format); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_tp_new_10pyreadstat_16_readstat_parser_data_container(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *p; PyObject *o; #if CYTHON_COMPILING_IN_LIMITED_API allocfunc alloc_func = (allocfunc)PyType_GetSlot(t, Py_tp_alloc); o = alloc_func(t, 0); #else if (likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) { o = (*t->tp_alloc)(t, 0); } else { o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); } if (unlikely(!o)) return 0; #endif p = ((struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)o); p->col_data = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_data_len = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_names = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_labels = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_dtypes = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_numpy_dtypes = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_dtypes_isobject = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_dytpes_isfloat = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); p->col_formats_original = ((PyObject*)Py_None); Py_INCREF(Py_None); p->origin = Py_None; Py_INCREF(Py_None); p->file_label = ((PyObject*)Py_None); Py_INCREF(Py_None); p->file_encoding = ((PyObject*)Py_None); Py_INCREF(Py_None); p->label_to_var_name = Py_None; Py_INCREF(Py_None); p->labels_raw = Py_None; Py_INCREF(Py_None); p->notes = Py_None; Py_INCREF(Py_None); p->user_encoding = ((PyObject*)Py_None); Py_INCREF(Py_None); p->table_name = ((PyObject*)Py_None); Py_INCREF(Py_None); p->use_cols = ((PyObject*)Py_None); Py_INCREF(Py_None); p->missing_ranges = ((PyObject*)Py_None); Py_INCREF(Py_None); p->missing_user_values = ((PyObject*)Py_None); Py_INCREF(Py_None); p->variable_storage_width = ((PyObject*)Py_None); Py_INCREF(Py_None); p->variable_display_width = Py_None; Py_INCREF(Py_None); p->variable_alignment = Py_None; Py_INCREF(Py_None); p->variable_measure = Py_None; Py_INCREF(Py_None); if (unlikely(__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad; return o; bad: Py_DECREF(o); o = 0; return NULL; } static void __pyx_tp_dealloc_10pyreadstat_16_readstat_parser_data_container(PyObject *o) { struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *p = (struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely((PY_VERSION_HEX >= 0x03080000 || __Pyx_PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE)) && __Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) { if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10pyreadstat_16_readstat_parser_data_container) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->col_data); Py_CLEAR(p->col_data_len); Py_CLEAR(p->col_names); Py_CLEAR(p->col_labels); Py_CLEAR(p->col_dtypes); Py_CLEAR(p->col_numpy_dtypes); Py_CLEAR(p->col_dtypes_isobject); Py_CLEAR(p->col_dytpes_isfloat); Py_CLEAR(p->col_formats); Py_CLEAR(p->col_formats_original); Py_CLEAR(p->origin); Py_CLEAR(p->file_label); Py_CLEAR(p->file_encoding); Py_CLEAR(p->label_to_var_name); Py_CLEAR(p->labels_raw); Py_CLEAR(p->notes); Py_CLEAR(p->user_encoding); Py_CLEAR(p->table_name); Py_CLEAR(p->use_cols); Py_CLEAR(p->missing_ranges); Py_CLEAR(p->missing_user_values); Py_CLEAR(p->variable_storage_width); Py_CLEAR(p->variable_display_width); Py_CLEAR(p->variable_alignment); Py_CLEAR(p->variable_measure); #if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY (*Py_TYPE(o)->tp_free)(o); #else { freefunc tp_free = (freefunc)PyType_GetSlot(Py_TYPE(o), Py_tp_free); if (tp_free) tp_free(o); } #endif } static int __pyx_tp_traverse_10pyreadstat_16_readstat_parser_data_container(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *p = (struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)o; if (p->col_data) { e = (*v)(p->col_data, a); if (e) return e; } if (p->col_data_len) { e = (*v)(p->col_data_len, a); if (e) return e; } if (p->col_names) { e = (*v)(p->col_names, a); if (e) return e; } if (p->col_labels) { e = (*v)(p->col_labels, a); if (e) return e; } if (p->col_dtypes) { e = (*v)(p->col_dtypes, a); if (e) return e; } if (p->col_numpy_dtypes) { e = (*v)(p->col_numpy_dtypes, a); if (e) return e; } if (p->col_dtypes_isobject) { e = (*v)(p->col_dtypes_isobject, a); if (e) return e; } if (p->col_dytpes_isfloat) { e = (*v)(p->col_dytpes_isfloat, a); if (e) return e; } if (p->col_formats) { e = (*v)(p->col_formats, a); if (e) return e; } if (p->col_formats_original) { e = (*v)(p->col_formats_original, a); if (e) return e; } if (p->origin) { e = (*v)(p->origin, a); if (e) return e; } if (p->label_to_var_name) { e = (*v)(p->label_to_var_name, a); if (e) return e; } if (p->labels_raw) { e = (*v)(p->labels_raw, a); if (e) return e; } if (p->notes) { e = (*v)(p->notes, a); if (e) return e; } if (p->use_cols) { e = (*v)(p->use_cols, a); if (e) return e; } if (p->missing_ranges) { e = (*v)(p->missing_ranges, a); if (e) return e; } if (p->missing_user_values) { e = (*v)(p->missing_user_values, a); if (e) return e; } if (p->variable_storage_width) { e = (*v)(p->variable_storage_width, a); if (e) return e; } if (p->variable_display_width) { e = (*v)(p->variable_display_width, a); if (e) return e; } if (p->variable_alignment) { e = (*v)(p->variable_alignment, a); if (e) return e; } if (p->variable_measure) { e = (*v)(p->variable_measure, a); if (e) return e; } return 0; } static int __pyx_tp_clear_10pyreadstat_16_readstat_parser_data_container(PyObject *o) { PyObject* tmp; struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *p = (struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)o; tmp = ((PyObject*)p->col_data); p->col_data = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_data_len); p->col_data_len = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_names); p->col_names = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_labels); p->col_labels = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_dtypes); p->col_dtypes = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_numpy_dtypes); p->col_numpy_dtypes = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_dtypes_isobject); p->col_dtypes_isobject = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_dytpes_isfloat); p->col_dytpes_isfloat = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_formats); p->col_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->col_formats_original); p->col_formats_original = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->origin); p->origin = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->label_to_var_name); p->label_to_var_name = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->labels_raw); p->labels_raw = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->notes); p->notes = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->use_cols); p->use_cols = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->missing_ranges); p->missing_ranges = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->missing_user_values); p->missing_user_values = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->variable_storage_width); p->variable_storage_width = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->variable_display_width); p->variable_display_width = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->variable_alignment); p->variable_alignment = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->variable_measure); p->variable_measure = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } static PyMethodDef __pyx_methods_10pyreadstat_16_readstat_parser_data_container[] = { {"__reduce_cython__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_3__reduce_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {"__setstate_cython__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_16_readstat_parser_14data_container_5__setstate_cython__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}, {0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_type_10pyreadstat_16_readstat_parser_data_container_slots[] = { {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10pyreadstat_16_readstat_parser_data_container}, {Py_tp_doc, (void *)PyDoc_STR("\n This extension type holds all the data we need to get from our file from \n the readstat parser and will be used later to compose our pandas data frame\n ")}, {Py_tp_traverse, (void *)__pyx_tp_traverse_10pyreadstat_16_readstat_parser_data_container}, {Py_tp_clear, (void *)__pyx_tp_clear_10pyreadstat_16_readstat_parser_data_container}, {Py_tp_methods, (void *)__pyx_methods_10pyreadstat_16_readstat_parser_data_container}, {Py_tp_new, (void *)__pyx_tp_new_10pyreadstat_16_readstat_parser_data_container}, {0, 0}, }; static PyType_Spec __pyx_type_10pyreadstat_16_readstat_parser_data_container_spec = { "pyreadstat._readstat_parser.data_container", sizeof(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, __pyx_type_10pyreadstat_16_readstat_parser_data_container_slots, }; #else static PyTypeObject __pyx_type_10pyreadstat_16_readstat_parser_data_container = { PyVarObject_HEAD_INIT(0, 0) "pyreadstat._readstat_parser.""data_container", /*tp_name*/ sizeof(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_10pyreadstat_16_readstat_parser_data_container, /*tp_dealloc*/ #if PY_VERSION_HEX < 0x030800b4 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030800b4 0, /*tp_vectorcall_offset*/ #endif 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ PyDoc_STR("\n This extension type holds all the data we need to get from our file from \n the readstat parser and will be used later to compose our pandas data frame\n "), /*tp_doc*/ __pyx_tp_traverse_10pyreadstat_16_readstat_parser_data_container, /*tp_traverse*/ __pyx_tp_clear_10pyreadstat_16_readstat_parser_data_container, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_10pyreadstat_16_readstat_parser_data_container, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_10pyreadstat_16_readstat_parser_data_container, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 #if CYTHON_USE_TP_FINALIZE 0, /*tp_finalize*/ #else NULL, /*tp_finalize*/ #endif #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, /*tp_vectorcall*/ #endif #if __PYX_NEED_TP_PRINT_SLOT == 1 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030C0000 0, /*tp_watched*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, /*tp_pypy_flags*/ #endif }; #endif static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif /* #### Code section: pystring_table ### */ static int __Pyx_CreateStringTabAndInitStrings(void) { __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_ADATE, __pyx_k_ADATE, sizeof(__pyx_k_ADATE), 0, 0, 1, 1}, {&__pyx_n_s_ADATE10, __pyx_k_ADATE10, sizeof(__pyx_k_ADATE10), 0, 0, 1, 1}, {&__pyx_n_s_ADATE8, __pyx_k_ADATE8, sizeof(__pyx_k_ADATE8), 0, 0, 1, 1}, {&__pyx_n_s_B8601DA, __pyx_k_B8601DA, sizeof(__pyx_k_B8601DA), 0, 0, 1, 1}, {&__pyx_n_s_B8601DN, __pyx_k_B8601DN, sizeof(__pyx_k_B8601DN), 0, 0, 1, 1}, {&__pyx_n_s_B8601DT, __pyx_k_B8601DT, sizeof(__pyx_k_B8601DT), 0, 0, 1, 1}, {&__pyx_n_s_B8601TM, __pyx_k_B8601TM, sizeof(__pyx_k_B8601TM), 0, 0, 1, 1}, {&__pyx_n_s_DATE, __pyx_k_DATE, sizeof(__pyx_k_DATE), 0, 0, 1, 1}, {&__pyx_n_s_DATE11, __pyx_k_DATE11, sizeof(__pyx_k_DATE11), 0, 0, 1, 1}, {&__pyx_n_s_DATE12, __pyx_k_DATE12, sizeof(__pyx_k_DATE12), 0, 0, 1, 1}, {&__pyx_n_s_DATE8, __pyx_k_DATE8, sizeof(__pyx_k_DATE8), 0, 0, 1, 1}, {&__pyx_n_s_DATE9, __pyx_k_DATE9, sizeof(__pyx_k_DATE9), 0, 0, 1, 1}, {&__pyx_n_s_DATEAMPM, __pyx_k_DATEAMPM, sizeof(__pyx_k_DATEAMPM), 0, 0, 1, 1}, {&__pyx_n_s_DATETIME, __pyx_k_DATETIME, sizeof(__pyx_k_DATETIME), 0, 0, 1, 1}, {&__pyx_n_s_DATETIME17, __pyx_k_DATETIME17, sizeof(__pyx_k_DATETIME17), 0, 0, 1, 1}, {&__pyx_n_s_DATETIME18, __pyx_k_DATETIME18, sizeof(__pyx_k_DATETIME18), 0, 0, 1, 1}, {&__pyx_n_s_DATETIME19, __pyx_k_DATETIME19, sizeof(__pyx_k_DATETIME19), 0, 0, 1, 1}, {&__pyx_n_s_DATETIME20, __pyx_k_DATETIME20, sizeof(__pyx_k_DATETIME20), 0, 0, 1, 1}, {&__pyx_n_s_DATETIME21, __pyx_k_DATETIME21, sizeof(__pyx_k_DATETIME21), 0, 0, 1, 1}, {&__pyx_n_s_DATETIME22, __pyx_k_DATETIME22, sizeof(__pyx_k_DATETIME22), 0, 0, 1, 1}, {&__pyx_kp_s_DATETIME23_2, __pyx_k_DATETIME23_2, sizeof(__pyx_k_DATETIME23_2), 0, 0, 1, 0}, {&__pyx_n_s_DATETIME8, __pyx_k_DATETIME8, sizeof(__pyx_k_DATETIME8), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYY, __pyx_k_DDMMYY, sizeof(__pyx_k_DDMMYY), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYB, __pyx_k_DDMMYYB, sizeof(__pyx_k_DDMMYYB), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYB10, __pyx_k_DDMMYYB10, sizeof(__pyx_k_DDMMYYB10), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYC, __pyx_k_DDMMYYC, sizeof(__pyx_k_DDMMYYC), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYC10, __pyx_k_DDMMYYC10, sizeof(__pyx_k_DDMMYYC10), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYD, __pyx_k_DDMMYYD, sizeof(__pyx_k_DDMMYYD), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYD10, __pyx_k_DDMMYYD10, sizeof(__pyx_k_DDMMYYD10), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYN6, __pyx_k_DDMMYYN6, sizeof(__pyx_k_DDMMYYN6), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYN8, __pyx_k_DDMMYYN8, sizeof(__pyx_k_DDMMYYN8), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYP, __pyx_k_DDMMYYP, sizeof(__pyx_k_DDMMYYP), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYP10, __pyx_k_DDMMYYP10, sizeof(__pyx_k_DDMMYYP10), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYS, __pyx_k_DDMMYYS, sizeof(__pyx_k_DDMMYYS), 0, 0, 1, 1}, {&__pyx_n_s_DDMMYYS10, __pyx_k_DDMMYYS10, sizeof(__pyx_k_DDMMYYS10), 0, 0, 1, 1}, {&__pyx_n_s_DTDATE, __pyx_k_DTDATE, sizeof(__pyx_k_DTDATE), 0, 0, 1, 1}, {&__pyx_n_s_DTIME, __pyx_k_DTIME, sizeof(__pyx_k_DTIME), 0, 0, 1, 1}, {&__pyx_n_s_DataFrame, __pyx_k_DataFrame, sizeof(__pyx_k_DataFrame), 0, 0, 1, 1}, {&__pyx_n_s_E8601DA, __pyx_k_E8601DA, sizeof(__pyx_k_E8601DA), 0, 0, 1, 1}, {&__pyx_n_s_E8601DT, __pyx_k_E8601DT, sizeof(__pyx_k_E8601DT), 0, 0, 1, 1}, {&__pyx_n_s_E8601TM, __pyx_k_E8601TM, sizeof(__pyx_k_E8601TM), 0, 0, 1, 1}, {&__pyx_n_s_EDATE, __pyx_k_EDATE, sizeof(__pyx_k_EDATE), 0, 0, 1, 1}, {&__pyx_n_s_EDATE10, __pyx_k_EDATE10, sizeof(__pyx_k_EDATE10), 0, 0, 1, 1}, {&__pyx_n_s_EDATE8, __pyx_k_EDATE8, sizeof(__pyx_k_EDATE8), 0, 0, 1, 1}, {&__pyx_kp_s_Failed_convert_C_to_python_value, __pyx_k_Failed_convert_C_to_python_value, sizeof(__pyx_k_Failed_convert_C_to_python_value), 0, 0, 1, 0}, {&__pyx_kp_s_Failed_to_read_number_of_variabl, __pyx_k_Failed_to_read_number_of_variabl, sizeof(__pyx_k_Failed_to_read_number_of_variabl), 0, 0, 1, 0}, {&__pyx_kp_s_File_0_does_not_exist, __pyx_k_File_0_does_not_exist, sizeof(__pyx_k_File_0_does_not_exist), 0, 0, 1, 0}, {&__pyx_n_s_HHMM, __pyx_k_HHMM, sizeof(__pyx_k_HHMM), 0, 0, 1, 1}, {&__pyx_n_s_IS8601DA, __pyx_k_IS8601DA, sizeof(__pyx_k_IS8601DA), 0, 0, 1, 1}, {&__pyx_n_s_IS8601DT, __pyx_k_IS8601DT, sizeof(__pyx_k_IS8601DT), 0, 0, 1, 1}, {&__pyx_n_s_IS8601TM, __pyx_k_IS8601TM, sizeof(__pyx_k_IS8601TM), 0, 0, 1, 1}, {&__pyx_n_s_JDATE, __pyx_k_JDATE, sizeof(__pyx_k_JDATE), 0, 0, 1, 1}, {&__pyx_n_s_JDATE5, __pyx_k_JDATE5, sizeof(__pyx_k_JDATE5), 0, 0, 1, 1}, {&__pyx_n_s_JDATE7, __pyx_k_JDATE7, sizeof(__pyx_k_JDATE7), 0, 0, 1, 1}, {&__pyx_kp_s_Just_defining_a_custom_exceptio, __pyx_k_Just_defining_a_custom_exceptio, sizeof(__pyx_k_Just_defining_a_custom_exceptio), 0, 0, 1, 0}, {&__pyx_kp_s_Just_defining_a_custom_exceptio_2, __pyx_k_Just_defining_a_custom_exceptio_2, sizeof(__pyx_k_Just_defining_a_custom_exceptio_2), 0, 0, 1, 0}, {&__pyx_kp_s_M8_ns, __pyx_k_M8_ns, sizeof(__pyx_k_M8_ns), 0, 0, 1, 0}, {&__pyx_n_s_MDYAMPM, __pyx_k_MDYAMPM, sizeof(__pyx_k_MDYAMPM), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYY, __pyx_k_MMDDYY, sizeof(__pyx_k_MMDDYY), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYB, __pyx_k_MMDDYYB, sizeof(__pyx_k_MMDDYYB), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYB10, __pyx_k_MMDDYYB10, sizeof(__pyx_k_MMDDYYB10), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYC, __pyx_k_MMDDYYC, sizeof(__pyx_k_MMDDYYC), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYC10, __pyx_k_MMDDYYC10, sizeof(__pyx_k_MMDDYYC10), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYD, __pyx_k_MMDDYYD, sizeof(__pyx_k_MMDDYYD), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYD10, __pyx_k_MMDDYYD10, sizeof(__pyx_k_MMDDYYD10), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYN6, __pyx_k_MMDDYYN6, sizeof(__pyx_k_MMDDYYN6), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYN8, __pyx_k_MMDDYYN8, sizeof(__pyx_k_MMDDYYN8), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYP, __pyx_k_MMDDYYP, sizeof(__pyx_k_MMDDYYP), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYP10, __pyx_k_MMDDYYP10, sizeof(__pyx_k_MMDDYYP10), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYS, __pyx_k_MMDDYYS, sizeof(__pyx_k_MMDDYYS), 0, 0, 1, 1}, {&__pyx_n_s_MMDDYYS10, __pyx_k_MMDDYYS10, sizeof(__pyx_k_MMDDYYS10), 0, 0, 1, 1}, {&__pyx_n_s_NULL, __pyx_k_NULL, sizeof(__pyx_k_NULL), 0, 0, 1, 1}, {&__pyx_n_s_OrderedDict, __pyx_k_OrderedDict, sizeof(__pyx_k_OrderedDict), 0, 0, 1, 1}, {&__pyx_n_s_PyreadstatError, __pyx_k_PyreadstatError, sizeof(__pyx_k_PyreadstatError), 0, 0, 1, 1}, {&__pyx_n_s_ReadstatError, __pyx_k_ReadstatError, sizeof(__pyx_k_ReadstatError), 0, 0, 1, 1}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s_SDATE, __pyx_k_SDATE, sizeof(__pyx_k_SDATE), 0, 0, 1, 1}, {&__pyx_n_s_SDATE10, __pyx_k_SDATE10, sizeof(__pyx_k_SDATE10), 0, 0, 1, 1}, {&__pyx_n_s_SDATE8, __pyx_k_SDATE8, sizeof(__pyx_k_SDATE8), 0, 0, 1, 1}, {&__pyx_kp_s_STRING_type_with_value_s_with_da, __pyx_k_STRING_type_with_value_s_with_da, sizeof(__pyx_k_STRING_type_with_value_s_with_da), 0, 0, 1, 0}, {&__pyx_n_s_TIME, __pyx_k_TIME, sizeof(__pyx_k_TIME), 0, 0, 1, 1}, {&__pyx_kp_s_TIME11_2, __pyx_k_TIME11_2, sizeof(__pyx_k_TIME11_2), 0, 0, 1, 0}, {&__pyx_n_s_TIME20, __pyx_k_TIME20, sizeof(__pyx_k_TIME20), 0, 0, 1, 1}, {&__pyx_kp_s_TIME20_3, __pyx_k_TIME20_3, sizeof(__pyx_k_TIME20_3), 0, 0, 1, 0}, {&__pyx_n_s_TIME5, __pyx_k_TIME5, sizeof(__pyx_k_TIME5), 0, 0, 1, 1}, {&__pyx_n_s_TIME8, __pyx_k_TIME8, sizeof(__pyx_k_TIME8), 0, 0, 1, 1}, {&__pyx_n_s_TIMEAMPM, __pyx_k_TIMEAMPM, sizeof(__pyx_k_TIMEAMPM), 0, 0, 1, 1}, {&__pyx_n_s_TOD, __pyx_k_TOD, sizeof(__pyx_k_TOD), 0, 0, 1, 1}, {&__pyx_kp_s_This_class_holds_metadata_we_wa, __pyx_k_This_class_holds_metadata_we_wa, sizeof(__pyx_k_This_class_holds_metadata_we_wa), 0, 0, 1, 0}, {&__pyx_kp_s_Time_zones_are_not_available_fro, __pyx_k_Time_zones_are_not_available_fro, sizeof(__pyx_k_Time_zones_are_not_available_fro), 0, 0, 1, 0}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_n_s_UnicodeError, __pyx_k_UnicodeError, sizeof(__pyx_k_UnicodeError), 0, 0, 1, 1}, {&__pyx_kp_s_Unknown_file_format, __pyx_k_Unknown_file_format, sizeof(__pyx_k_Unknown_file_format), 0, 0, 1, 0}, {&__pyx_kp_s_Unkown_data_type, __pyx_k_Unkown_data_type, sizeof(__pyx_k_Unkown_data_type), 0, 0, 1, 0}, {&__pyx_n_s_WEEKDATE, __pyx_k_WEEKDATE, sizeof(__pyx_k_WEEKDATE), 0, 0, 1, 1}, {&__pyx_n_s_WEEKDATX, __pyx_k_WEEKDATX, sizeof(__pyx_k_WEEKDATX), 0, 0, 1, 1}, {&__pyx_n_s_YMDHMS16, __pyx_k_YMDHMS16, sizeof(__pyx_k_YMDHMS16), 0, 0, 1, 1}, {&__pyx_n_s_YMDHMS19, __pyx_k_YMDHMS19, sizeof(__pyx_k_YMDHMS19), 0, 0, 1, 1}, {&__pyx_kp_s_YMDHMS19_2, __pyx_k_YMDHMS19_2, sizeof(__pyx_k_YMDHMS19_2), 0, 0, 1, 0}, {&__pyx_n_s_YMDHMS20, __pyx_k_YMDHMS20, sizeof(__pyx_k_YMDHMS20), 0, 0, 1, 1}, {&__pyx_n_s_YYMMDD, __pyx_k_YYMMDD, sizeof(__pyx_k_YYMMDD), 0, 0, 1, 1}, {&__pyx_n_s_YYMMDD10, __pyx_k_YYMMDD10, sizeof(__pyx_k_YYMMDD10), 0, 0, 1, 1}, {&__pyx_n_s_YYMMDDB, __pyx_k_YYMMDDB, sizeof(__pyx_k_YYMMDDB), 0, 0, 1, 1}, {&__pyx_n_s_YYMMDDD, __pyx_k_YYMMDDD, sizeof(__pyx_k_YYMMDDD), 0, 0, 1, 1}, {&__pyx_n_s_YYMMDDN, __pyx_k_YYMMDDN, sizeof(__pyx_k_YYMMDDN), 0, 0, 1, 1}, {&__pyx_n_s_YYMMDDP, __pyx_k_YYMMDDP, sizeof(__pyx_k_YYMMDDP), 0, 0, 1, 1}, {&__pyx_n_s_YYMMDDS, __pyx_k_YYMMDDS, sizeof(__pyx_k_YYMMDDS), 0, 0, 1, 1}, {&__pyx_n_s__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 0, 1, 1}, {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, {&__pyx_kp_u__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 1, 0, 0}, {&__pyx_n_s__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 0, 1, 1}, {&__pyx_n_s_allowed_formats, __pyx_k_allowed_formats, sizeof(__pyx_k_allowed_formats), 0, 0, 1, 1}, {&__pyx_n_s_append, __pyx_k_append, sizeof(__pyx_k_append), 0, 0, 1, 1}, {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1}, {&__pyx_n_s_asyncio_coroutines, __pyx_k_asyncio_coroutines, sizeof(__pyx_k_asyncio_coroutines), 0, 0, 1, 1}, {&__pyx_n_s_center, __pyx_k_center, sizeof(__pyx_k_center), 0, 0, 1, 1}, {&__pyx_n_s_chr, __pyx_k_chr, sizeof(__pyx_k_chr), 0, 0, 1, 1}, {&__pyx_n_s_class_getitem, __pyx_k_class_getitem, sizeof(__pyx_k_class_getitem), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_collections, __pyx_k_collections, sizeof(__pyx_k_collections), 0, 0, 1, 1}, {&__pyx_kp_s_column_0_is_duplicated_renamed_t, __pyx_k_column_0_is_duplicated_renamed_t, sizeof(__pyx_k_column_0_is_duplicated_renamed_t), 0, 0, 1, 0}, {&__pyx_n_s_column_labels, __pyx_k_column_labels, sizeof(__pyx_k_column_labels), 0, 0, 1, 1}, {&__pyx_n_s_column_names, __pyx_k_column_names, sizeof(__pyx_k_column_names), 0, 0, 1, 1}, {&__pyx_n_s_column_names_to_labels, __pyx_k_column_names_to_labels, sizeof(__pyx_k_column_names_to_labels), 0, 0, 1, 1}, {&__pyx_n_s_columns, __pyx_k_columns, sizeof(__pyx_k_columns), 0, 0, 1, 1}, {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1}, {&__pyx_n_s_creation_time, __pyx_k_creation_time, sizeof(__pyx_k_creation_time), 0, 0, 1, 1}, {&__pyx_kp_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 0}, {&__pyx_n_s_data_container, __pyx_k_data_container, sizeof(__pyx_k_data_container), 0, 0, 1, 1}, {&__pyx_n_s_data_container___reduce_cython, __pyx_k_data_container___reduce_cython, sizeof(__pyx_k_data_container___reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_data_container___setstate_cython, __pyx_k_data_container___setstate_cython, sizeof(__pyx_k_data_container___setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_date, __pyx_k_date, sizeof(__pyx_k_date), 0, 0, 1, 1}, {&__pyx_n_s_datetime, __pyx_k_datetime, sizeof(__pyx_k_datetime), 0, 0, 1, 1}, {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, {&__pyx_n_s_dict_2, __pyx_k_dict_2, sizeof(__pyx_k_dict_2), 0, 0, 1, 1}, {&__pyx_kp_u_disable, __pyx_k_disable, sizeof(__pyx_k_disable), 0, 1, 0, 0}, {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_n_s_double, __pyx_k_double, sizeof(__pyx_k_double), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dtypes, __pyx_k_dtypes, sizeof(__pyx_k_dtypes), 0, 0, 1, 1}, {&__pyx_n_s_duplicated, __pyx_k_duplicated, sizeof(__pyx_k_duplicated), 0, 0, 1, 1}, {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, {&__pyx_kp_u_enable, __pyx_k_enable, sizeof(__pyx_k_enable), 0, 1, 0, 0}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_expanduser, __pyx_k_expanduser, sizeof(__pyx_k_expanduser), 0, 0, 1, 1}, {&__pyx_n_s_file_encoding, __pyx_k_file_encoding, sizeof(__pyx_k_file_encoding), 0, 0, 1, 1}, {&__pyx_n_s_file_label, __pyx_k_file_label, sizeof(__pyx_k_file_label), 0, 0, 1, 1}, {&__pyx_kp_s_file_path_could_not_be_encoded_w, __pyx_k_file_path_could_not_be_encoded_w, sizeof(__pyx_k_file_path_could_not_be_encoded_w), 0, 0, 1, 0}, {&__pyx_n_s_fill, __pyx_k_fill, sizeof(__pyx_k_fill), 0, 0, 1, 1}, {&__pyx_n_s_float, __pyx_k_float, sizeof(__pyx_k_float), 0, 0, 1, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, {&__pyx_n_s_from_dict, __pyx_k_from_dict, sizeof(__pyx_k_from_dict), 0, 0, 1, 1}, {&__pyx_n_s_fromtimestamp, __pyx_k_fromtimestamp, sizeof(__pyx_k_fromtimestamp), 0, 0, 1, 1}, {&__pyx_n_s_fsdecode, __pyx_k_fsdecode, sizeof(__pyx_k_fsdecode), 0, 0, 1, 1}, {&__pyx_n_s_fsencode, __pyx_k_fsencode, sizeof(__pyx_k_fsencode), 0, 0, 1, 1}, {&__pyx_kp_u_gc, __pyx_k_gc, sizeof(__pyx_k_gc), 0, 1, 0, 0}, {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, {&__pyx_n_s_getfilesystemencoding, __pyx_k_getfilesystemencoding, sizeof(__pyx_k_getfilesystemencoding), 0, 0, 1, 1}, {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, {&__pyx_n_s_hi, __pyx_k_hi, sizeof(__pyx_k_hi), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, {&__pyx_n_s_init_subclass, __pyx_k_init_subclass, sizeof(__pyx_k_init_subclass), 0, 0, 1, 1}, {&__pyx_n_s_initializing, __pyx_k_initializing, sizeof(__pyx_k_initializing), 0, 0, 1, 1}, {&__pyx_n_s_int16, __pyx_k_int16, sizeof(__pyx_k_int16), 0, 0, 1, 1}, {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1}, {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1}, {&__pyx_n_s_int8, __pyx_k_int8, sizeof(__pyx_k_int8), 0, 0, 1, 1}, {&__pyx_n_s_is_coroutine, __pyx_k_is_coroutine, sizeof(__pyx_k_is_coroutine), 0, 0, 1, 1}, {&__pyx_kp_u_isenabled, __pyx_k_isenabled, sizeof(__pyx_k_isenabled), 0, 1, 0, 0}, {&__pyx_n_s_isfile, __pyx_k_isfile, sizeof(__pyx_k_isfile), 0, 0, 1, 1}, {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1}, {&__pyx_n_s_left, __pyx_k_left, sizeof(__pyx_k_left), 0, 0, 1, 1}, {&__pyx_n_s_lo, __pyx_k_lo, sizeof(__pyx_k_lo), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1}, {&__pyx_n_s_metadata_container, __pyx_k_metadata_container, sizeof(__pyx_k_metadata_container), 0, 0, 1, 1}, {&__pyx_n_s_metadata_container___init, __pyx_k_metadata_container___init, sizeof(__pyx_k_metadata_container___init), 0, 0, 1, 1}, {&__pyx_n_s_missing_ranges, __pyx_k_missing_ranges, sizeof(__pyx_k_missing_ranges), 0, 0, 1, 1}, {&__pyx_n_s_missing_user_values, __pyx_k_missing_user_values, sizeof(__pyx_k_missing_user_values), 0, 0, 1, 1}, {&__pyx_n_s_modification_time, __pyx_k_modification_time, sizeof(__pyx_k_modification_time), 0, 0, 1, 1}, {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1}, {&__pyx_n_s_mro_entries, __pyx_k_mro_entries, sizeof(__pyx_k_mro_entries), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, {&__pyx_n_s_nan, __pyx_k_nan, sizeof(__pyx_k_nan), 0, 0, 1, 1}, {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, {&__pyx_n_s_nominal, __pyx_k_nominal, sizeof(__pyx_k_nominal), 0, 0, 1, 1}, {&__pyx_n_s_notes, __pyx_k_notes, sizeof(__pyx_k_notes), 0, 0, 1, 1}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_nt, __pyx_k_nt, sizeof(__pyx_k_nt), 0, 0, 1, 1}, {&__pyx_n_s_number_columns, __pyx_k_number_columns, sizeof(__pyx_k_number_columns), 0, 0, 1, 1}, {&__pyx_n_s_number_rows, __pyx_k_number_rows, sizeof(__pyx_k_number_rows), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1}, {&__pyx_n_s_ordinal, __pyx_k_ordinal, sizeof(__pyx_k_ordinal), 0, 0, 1, 1}, {&__pyx_n_s_original_variable_types, __pyx_k_original_variable_types, sizeof(__pyx_k_original_variable_types), 0, 0, 1, 1}, {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, {&__pyx_n_s_output_format, __pyx_k_output_format, sizeof(__pyx_k_output_format), 0, 0, 1, 1}, {&__pyx_kp_s_output_format_must_be_one_of_all, __pyx_k_output_format_must_be_one_of_all, sizeof(__pyx_k_output_format_must_be_one_of_all), 0, 0, 1, 0}, {&__pyx_n_s_pandas, __pyx_k_pandas, sizeof(__pyx_k_pandas), 0, 0, 1, 1}, {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1}, {&__pyx_kp_s_path_must_be_either_str_or_bytes, __pyx_k_path_must_be_either_str_or_bytes, sizeof(__pyx_k_path_must_be_either_str_or_bytes), 0, 0, 1, 0}, {&__pyx_kp_s_path_must_be_str_bytes_or_unicod, __pyx_k_path_must_be_str_bytes_or_unicod, sizeof(__pyx_k_path_must_be_str_bytes_or_unicod), 0, 0, 1, 0}, {&__pyx_n_s_pd, __pyx_k_pd, sizeof(__pyx_k_pd), 0, 0, 1, 1}, {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1}, {&__pyx_n_s_pyreadstat__readstat_parser, __pyx_k_pyreadstat__readstat_parser, sizeof(__pyx_k_pyreadstat__readstat_parser), 0, 0, 1, 1}, {&__pyx_kp_s_pyreadstat__readstat_parser_pyx, __pyx_k_pyreadstat__readstat_parser_pyx, sizeof(__pyx_k_pyreadstat__readstat_parser_pyx), 0, 0, 1, 0}, {&__pyx_n_s_pyx_capi, __pyx_k_pyx_capi, sizeof(__pyx_k_pyx_capi), 0, 0, 1, 1}, {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1}, {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_readstat_to_numpy_types, __pyx_k_readstat_to_numpy_types, sizeof(__pyx_k_readstat_to_numpy_types), 0, 0, 1, 1}, {&__pyx_n_s_readstat_variable_types, __pyx_k_readstat_variable_types, sizeof(__pyx_k_readstat_variable_types), 0, 0, 1, 1}, {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, {&__pyx_n_s_right, __pyx_k_right, sizeof(__pyx_k_right), 0, 0, 1, 1}, {&__pyx_n_s_sas_all_formats, __pyx_k_sas_all_formats, sizeof(__pyx_k_sas_all_formats), 0, 0, 1, 1}, {&__pyx_n_s_sas_date_formats, __pyx_k_sas_date_formats, sizeof(__pyx_k_sas_date_formats), 0, 0, 1, 1}, {&__pyx_n_s_sas_datetime_formats, __pyx_k_sas_datetime_formats, sizeof(__pyx_k_sas_datetime_formats), 0, 0, 1, 1}, {&__pyx_n_s_sas_origin, __pyx_k_sas_origin, sizeof(__pyx_k_sas_origin), 0, 0, 1, 1}, {&__pyx_n_s_sas_time_formats, __pyx_k_sas_time_formats, sizeof(__pyx_k_sas_time_formats), 0, 0, 1, 1}, {&__pyx_n_s_scale, __pyx_k_scale, sizeof(__pyx_k_scale), 0, 0, 1, 1}, {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1}, {&__pyx_n_s_set_name, __pyx_k_set_name, sizeof(__pyx_k_set_name), 0, 0, 1, 1}, {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, {&__pyx_n_s_spec, __pyx_k_spec, sizeof(__pyx_k_spec), 0, 0, 1, 1}, {&__pyx_n_s_spss_all_formats, __pyx_k_spss_all_formats, sizeof(__pyx_k_spss_all_formats), 0, 0, 1, 1}, {&__pyx_n_s_spss_date_formats, __pyx_k_spss_date_formats, sizeof(__pyx_k_spss_date_formats), 0, 0, 1, 1}, {&__pyx_n_s_spss_datetime_formats, __pyx_k_spss_datetime_formats, sizeof(__pyx_k_spss_datetime_formats), 0, 0, 1, 1}, {&__pyx_n_s_spss_origin, __pyx_k_spss_origin, sizeof(__pyx_k_spss_origin), 0, 0, 1, 1}, {&__pyx_n_s_spss_time_formats, __pyx_k_spss_time_formats, sizeof(__pyx_k_spss_time_formats), 0, 0, 1, 1}, {&__pyx_n_s_stata_all_formats, __pyx_k_stata_all_formats, sizeof(__pyx_k_stata_all_formats), 0, 0, 1, 1}, {&__pyx_n_s_stata_date_formats, __pyx_k_stata_date_formats, sizeof(__pyx_k_stata_date_formats), 0, 0, 1, 1}, {&__pyx_n_s_stata_datetime_formats, __pyx_k_stata_datetime_formats, sizeof(__pyx_k_stata_datetime_formats), 0, 0, 1, 1}, {&__pyx_n_s_stata_origin, __pyx_k_stata_origin, sizeof(__pyx_k_stata_origin), 0, 0, 1, 1}, {&__pyx_n_s_stata_time_formats, __pyx_k_stata_time_formats, sizeof(__pyx_k_stata_time_formats), 0, 0, 1, 1}, {&__pyx_n_s_string, __pyx_k_string, sizeof(__pyx_k_string), 0, 0, 1, 1}, {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0}, {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1}, {&__pyx_n_s_surrogateescape, __pyx_k_surrogateescape, sizeof(__pyx_k_surrogateescape), 0, 0, 1, 1}, {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, {&__pyx_kp_s_tC, __pyx_k_tC, sizeof(__pyx_k_tC), 0, 0, 1, 0}, {&__pyx_n_s_table_name, __pyx_k_table_name, sizeof(__pyx_k_table_name), 0, 0, 1, 1}, {&__pyx_kp_s_tc, __pyx_k_tc, sizeof(__pyx_k_tc), 0, 0, 1, 0}, {&__pyx_kp_s_tcHH_MM, __pyx_k_tcHH_MM, sizeof(__pyx_k_tcHH_MM), 0, 0, 1, 0}, {&__pyx_kp_s_tcHH_MM_SS, __pyx_k_tcHH_MM_SS, sizeof(__pyx_k_tcHH_MM_SS), 0, 0, 1, 0}, {&__pyx_kp_s_td, __pyx_k_td, sizeof(__pyx_k_td), 0, 0, 1, 0}, {&__pyx_kp_s_tdCCYY_NN_DD, __pyx_k_tdCCYY_NN_DD, sizeof(__pyx_k_tdCCYY_NN_DD), 0, 0, 1, 0}, {&__pyx_kp_s_tdD_m_Y, __pyx_k_tdD_m_Y, sizeof(__pyx_k_tdD_m_Y), 0, 0, 1, 0}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1}, {&__pyx_n_s_to_datetime, __pyx_k_to_datetime, sizeof(__pyx_k_to_datetime), 0, 0, 1, 1}, {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1}, {&__pyx_n_s_undetermined, __pyx_k_undetermined, sizeof(__pyx_k_undetermined), 0, 0, 1, 1}, {&__pyx_n_s_unknown, __pyx_k_unknown, sizeof(__pyx_k_unknown), 0, 0, 1, 1}, {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0}, {&__pyx_n_s_value_labels, __pyx_k_value_labels, sizeof(__pyx_k_value_labels), 0, 0, 1, 1}, {&__pyx_n_s_variable_alignment, __pyx_k_variable_alignment, sizeof(__pyx_k_variable_alignment), 0, 0, 1, 1}, {&__pyx_n_s_variable_display_width, __pyx_k_variable_display_width, sizeof(__pyx_k_variable_display_width), 0, 0, 1, 1}, {&__pyx_n_s_variable_measure, __pyx_k_variable_measure, sizeof(__pyx_k_variable_measure), 0, 0, 1, 1}, {&__pyx_n_s_variable_storage_width, __pyx_k_variable_storage_width, sizeof(__pyx_k_variable_storage_width), 0, 0, 1, 1}, {&__pyx_n_s_variable_to_label, __pyx_k_variable_to_label, sizeof(__pyx_k_variable_to_label), 0, 0, 1, 1}, {&__pyx_n_s_variable_value_labels, __pyx_k_variable_value_labels, sizeof(__pyx_k_variable_value_labels), 0, 0, 1, 1}, {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1}, {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1}, {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; return __Pyx_InitStrings(__pyx_string_tab); } /* #### Code section: cached_builtins ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 71, __pyx_L1_error) __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 536, __pyx_L1_error) __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(0, 656, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 938, __pyx_L1_error) __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 1018, __pyx_L1_error) __pyx_builtin_UnicodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeError); if (!__pyx_builtin_UnicodeError) __PYX_ERR(0, 1058, __pyx_L1_error) __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(2, 308, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: cached_constants ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "cpython/datetime.pxd":308 * cdef inline object timezone_new(object offset, object name=None): * if PY_VERSION_HEX < 0x030700b1: * raise RuntimeError('Time zones are not available from the C-API.') # <<<<<<<<<<<<<< * return __Pyx_TimeZone_FromOffsetAndName(offset, name if name is not None else NULL) * */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Time_zones_are_not_available_fro); if (unlikely(!__pyx_tuple_)) __PYX_ERR(2, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); /* "pyreadstat/_readstat_parser.pyx":523 * # pre-allocate data * if metaonly: * row = np.empty(1, dtype=curnptype) # <<<<<<<<<<<<<< * else: * obs_count = dc.n_obs */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_int_1); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 523, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "pyreadstat/_readstat_parser.pyx":622 * if var_max_rows <= obs_index: * curnptype = dc.col_numpy_dtypes[index] * buf_list = np.empty(100000, dtype=curnptype) # <<<<<<<<<<<<<< * if iscurnptypeobject or iscurnptypefloat: * buf_list.fill(np.nan) */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_int_100000); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "pyreadstat/_readstat_parser.pyx":642 * dc.col_dtypes_isobject[index] = 1 * iscurnptypeobject = 1 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) # <<<<<<<<<<<<<< * dc.col_data[index][obs_index:] = np.nan * #dc.col_data[index][obs_index] = NAN */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "pyreadstat/_readstat_parser.pyx":662 * dc.col_dytpes_isfloat[index] = 0 * iscurnptypeobject = 1 * dc.col_data[index] = dc.col_data[index].astype(object, copy=False) # <<<<<<<<<<<<<< * dc.col_data[index][obs_index] = chr(missing_tag) * curset = dc.missing_user_values.get(index) */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 662, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); /* "pyreadstat/_readstat_parser.pyx":1060 * except UnicodeError: * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") # <<<<<<<<<<<<<< * else: * if type(filename_path) == str: */ __pyx_tuple__7 = PyTuple_Pack(2, __pyx_kp_s_utf_8, __pyx_n_s_surrogateescape); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 1060, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): */ __pyx_tuple__10 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_reduce_cython, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(1, 1, __pyx_L1_error) /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" */ __pyx_tuple__12 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_pyx_state); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_setstate_cython, 3, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) __PYX_ERR(1, 3, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":123 * This class holds metadata we want to give back to python * """ * def __init__(self): # <<<<<<<<<<<<<< * self.column_names = list() * self.column_labels = list() */ __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat__readstat_parser_pyx, __pyx_n_s_init, 123, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } /* #### Code section: init_constants ### */ static CYTHON_SMALL_CODE int __Pyx_InitConstants(void) { __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_get.method_name = &__pyx_n_s_get; __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_items.method_name = &__pyx_n_s_items; if (__Pyx_CreateStringTabAndInitStrings() < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_100000 = PyInt_FromLong(100000L); if (unlikely(!__pyx_int_100000)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: init_globals ### */ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { return 0; } /* #### Code section: init_module ### */ static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ static int __Pyx_modinit_global_init_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_sas_all_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_sas_origin = Py_None; Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_spss_all_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_spss_origin = Py_None; Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_stata_all_formats = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_parser_stata_origin = Py_None; Py_INCREF(Py_None); __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(void) { __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ if (__Pyx_ExportVoidPtr(__pyx_n_s_readstat_to_numpy_types, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_sas_date_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_sas_datetime_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_sas_time_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_sas_all_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_sas_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_sas_origin, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_sas_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_spss_datetime_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_spss_date_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_spss_time_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_spss_all_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_spss_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_spss_origin, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_spss_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_stata_datetime_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_stata_date_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_stata_time_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_stata_all_formats, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_stata_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportVoidPtr(__pyx_n_s_stata_origin, (void *)&__pyx_v_10pyreadstat_16_readstat_parser_stata_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_function_export_code(void) { __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ if (__Pyx_ExportFunction("transform_variable_format", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_transform_variable_format, "__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format (PyObject *, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("transform_datetime", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_transform_datetime, "PyObject *(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, double, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format, PyObject *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("handle_metadata", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_handle_metadata, "int (readstat_metadata_t *, void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("handle_variable", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_handle_variable, "int (int, readstat_variable_t *, char *, void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("handle_value", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_handle_value, "int (int, readstat_variable_t *, readstat_value_t, void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("handle_value_label", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_handle_value_label, "int (char *, readstat_value_t, char *, void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("handle_note", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_handle_note, "int (int, char *, void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("check_exit_status", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_check_exit_status, "void (readstat_error_t)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("run_readstat_parser", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_run_readstat_parser, "void (char *, struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *, __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension, long, long)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("data_container_to_dict", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_data_container_to_dict, "PyObject *(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("dict_to_pandas_dataframe", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_dict_to_pandas_dataframe, "PyObject *(PyObject *, struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("data_container_extract_metadata", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_data_container_extract_metadata, "PyObject *(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("run_conversion", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_parser_run_conversion, "PyObject *(PyObject *, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format, __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension, PyObject *, int, int, PyObject *, int, int, long, long, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_type_init_code(void) { __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ #if CYTHON_USE_TYPE_SPECS __pyx_ptype_10pyreadstat_16_readstat_parser_data_container = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10pyreadstat_16_readstat_parser_data_container_spec, NULL); if (unlikely(!__pyx_ptype_10pyreadstat_16_readstat_parser_data_container)) __PYX_ERR(0, 75, __pyx_L1_error) if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10pyreadstat_16_readstat_parser_data_container_spec, __pyx_ptype_10pyreadstat_16_readstat_parser_data_container) < 0) __PYX_ERR(0, 75, __pyx_L1_error) #else __pyx_ptype_10pyreadstat_16_readstat_parser_data_container = &__pyx_type_10pyreadstat_16_readstat_parser_data_container; #endif #if !CYTHON_COMPILING_IN_LIMITED_API #endif #if !CYTHON_USE_TYPE_SPECS if (__Pyx_PyType_Ready(__pyx_ptype_10pyreadstat_16_readstat_parser_data_container) < 0) __PYX_ERR(0, 75, __pyx_L1_error) #endif #if PY_MAJOR_VERSION < 3 __pyx_ptype_10pyreadstat_16_readstat_parser_data_container->tp_print = 0; #endif #if !CYTHON_COMPILING_IN_LIMITED_API if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_ptype_10pyreadstat_16_readstat_parser_data_container->tp_dictoffset && __pyx_ptype_10pyreadstat_16_readstat_parser_data_container->tp_getattro == PyObject_GenericGetAttr)) { __pyx_ptype_10pyreadstat_16_readstat_parser_data_container->tp_getattro = __Pyx_PyObject_GenericGetAttr; } #endif if (PyObject_SetAttr(__pyx_m, __pyx_n_s_data_container, (PyObject *) __pyx_ptype_10pyreadstat_16_readstat_parser_data_container) < 0) __PYX_ERR(0, 75, __pyx_L1_error) #if !CYTHON_COMPILING_IN_LIMITED_API if (__Pyx_setup_reduce((PyObject *) __pyx_ptype_10pyreadstat_16_readstat_parser_data_container) < 0) __PYX_ERR(0, 75, __pyx_L1_error) #endif __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_type_import_code(void) { __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 9, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_ptype_7cpython_4type_type = __Pyx_ImportType_3_0_9(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type", #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000 sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(PyTypeObject), #elif CYTHON_COMPILING_IN_LIMITED_API sizeof(PyTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(PyTypeObject), #else sizeof(PyHeapTypeObject), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(PyHeapTypeObject), #endif __Pyx_ImportType_CheckSize_Warn_3_0_9); if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(3, 9, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule("datetime"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_ptype_7cpython_8datetime_date = __Pyx_ImportType_3_0_9(__pyx_t_1, "datetime", "date", sizeof(PyDateTime_Date), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(PyDateTime_Date),__Pyx_ImportType_CheckSize_Warn_3_0_9); if (!__pyx_ptype_7cpython_8datetime_date) __PYX_ERR(2, 70, __pyx_L1_error) __pyx_ptype_7cpython_8datetime_time = __Pyx_ImportType_3_0_9(__pyx_t_1, "datetime", "time", sizeof(PyDateTime_Time), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(PyDateTime_Time),__Pyx_ImportType_CheckSize_Warn_3_0_9); if (!__pyx_ptype_7cpython_8datetime_time) __PYX_ERR(2, 83, __pyx_L1_error) __pyx_ptype_7cpython_8datetime_datetime = __Pyx_ImportType_3_0_9(__pyx_t_1, "datetime", "datetime", sizeof(PyDateTime_DateTime), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(PyDateTime_DateTime),__Pyx_ImportType_CheckSize_Warn_3_0_9); if (!__pyx_ptype_7cpython_8datetime_datetime) __PYX_ERR(2, 109, __pyx_L1_error) __pyx_ptype_7cpython_8datetime_timedelta = __Pyx_ImportType_3_0_9(__pyx_t_1, "datetime", "timedelta", sizeof(PyDateTime_Delta), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(PyDateTime_Delta),__Pyx_ImportType_CheckSize_Warn_3_0_9); if (!__pyx_ptype_7cpython_8datetime_timedelta) __PYX_ERR(2, 147, __pyx_L1_error) __pyx_ptype_7cpython_8datetime_tzinfo = __Pyx_ImportType_3_0_9(__pyx_t_1, "datetime", "tzinfo", sizeof(PyDateTime_TZInfo), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(PyDateTime_TZInfo),__Pyx_ImportType_CheckSize_Warn_3_0_9); if (!__pyx_ptype_7cpython_8datetime_tzinfo) __PYX_ERR(2, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_variable_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_import_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __Pyx_RefNannyFinishContext(); return 0; } #if PY_MAJOR_VERSION >= 3 #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec__readstat_parser(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec__readstat_parser}, {0, NULL} }; #endif #ifdef __cplusplus namespace { struct PyModuleDef __pyx_moduledef = #else static struct PyModuleDef __pyx_moduledef = #endif { PyModuleDef_HEAD_INIT, "_readstat_parser", 0, /* m_doc */ #if CYTHON_PEP489_MULTI_PHASE_INIT 0, /* m_size */ #elif CYTHON_USE_MODULE_STATE sizeof(__pyx_mstate), /* m_size */ #else -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif #if CYTHON_USE_MODULE_STATE __pyx_m_traverse, /* m_traverse */ __pyx_m_clear, /* m_clear */ NULL /* m_free */ #else NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ #endif }; #ifdef __cplusplus } /* anonymous namespace */ #endif #endif #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #elif PY_MAJOR_VERSION < 3 #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" void #else #define __Pyx_PyMODINIT_FUNC void #endif #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif #if PY_MAJOR_VERSION < 3 __Pyx_PyMODINIT_FUNC init_readstat_parser(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC init_readstat_parser(void) #else __Pyx_PyMODINIT_FUNC PyInit__readstat_parser(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit__readstat_parser(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { #if PY_VERSION_HEX >= 0x030700A1 static PY_INT64_T main_interpreter_id = -1; PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); if (main_interpreter_id == -1) { main_interpreter_id = current_id; return (unlikely(current_id == -1)) ? -1 : 0; } else if (unlikely(main_interpreter_id != current_id)) #else static PyInterpreterState *main_interpreter = NULL; PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; if (!main_interpreter) { main_interpreter = current_interpreter; } else if (unlikely(main_interpreter != current_interpreter)) #endif { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *module, const char* from_name, const char* to_name, int allow_none) #else static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) #endif { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { #if CYTHON_COMPILING_IN_LIMITED_API result = PyModule_AddObject(module, to_name, value); #else result = PyDict_SetItemString(moddict, to_name, value); #endif } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; CYTHON_UNUSED_VAR(def); if (__Pyx_check_single_interpreter()) return NULL; if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; #if CYTHON_COMPILING_IN_LIMITED_API moddict = module; #else moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; #endif if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec__readstat_parser(PyObject *__pyx_pyinit_module) #endif #endif { int stringtab_initialized = 0; #if CYTHON_USE_MODULE_STATE int pystate_addmodule_run = 0; #endif PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module '_readstat_parser' has already been imported. Re-initialisation is not supported."); return -1; } #elif PY_MAJOR_VERSION >= 3 if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_m = __pyx_pyinit_module; Py_INCREF(__pyx_m); #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("_readstat_parser", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #elif CYTHON_USE_MODULE_STATE __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) { int add_module_result = PyState_AddModule(__pyx_t_1, &__pyx_moduledef); __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "_readstat_parser" pseudovariable */ if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) pystate_addmodule_run = 1; } #else __pyx_m = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #endif #endif CYTHON_UNUSED_VAR(__pyx_t_1); __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_cython_runtime = __Pyx_PyImport_AddModuleRef((const char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__readstat_parser(void)", 0); if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pxy_PyFrame_Initialize_Offsets __Pxy_PyFrame_Initialize_Offsets(); #endif __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_AsyncGen_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS PyEval_InitThreads(); #endif /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) stringtab_initialized = 1; if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_pyreadstat___readstat_parser) { if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "pyreadstat._readstat_parser")) { if (unlikely((PyDict_SetItemString(modules, "pyreadstat._readstat_parser", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(); if (unlikely((__Pyx_modinit_variable_export_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_function_export_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_type_init_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_type_import_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) (void)__Pyx_modinit_variable_import_code(); (void)__Pyx_modinit_function_import_code(); /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "pyreadstat/_readstat_parser.pyx":25 * * #from datetime import timedelta, datetime * from collections import OrderedDict # <<<<<<<<<<<<<< * import datetime * import os */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_OrderedDict); __Pyx_GIVEREF(__pyx_n_s_OrderedDict); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_OrderedDict)) __PYX_ERR(0, 25, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_OrderedDict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_OrderedDict, __pyx_t_2) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":26 * #from datetime import timedelta, datetime * from collections import OrderedDict * import datetime # <<<<<<<<<<<<<< * import os * import warnings */ __pyx_t_3 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_datetime, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_datetime, __pyx_t_3) < 0) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":27 * from collections import OrderedDict * import datetime * import os # <<<<<<<<<<<<<< * import warnings * import sys */ __pyx_t_3 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_os, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_3) < 0) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":28 * import datetime * import os * import warnings # <<<<<<<<<<<<<< * import sys * */ __pyx_t_3 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_warnings, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_3) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":29 * import os * import warnings * import sys # <<<<<<<<<<<<<< * * import pandas as pd */ __pyx_t_3 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_sys, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_3) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":31 * import sys * * import pandas as pd # <<<<<<<<<<<<<< * import numpy as np * #from pandas._libs import Timestamp */ __pyx_t_3 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_pandas, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pd, __pyx_t_3) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":32 * * import pandas as pd * import numpy as np # <<<<<<<<<<<<<< * #from pandas._libs import Timestamp * */ __pyx_t_3 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_3) < 0) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":38 * * # necessary to work with the datetime C API * import_datetime() # <<<<<<<<<<<<<< * * cdef list sas_date_formats = ["WEEKDATE", "MMDDYY", "DDMMYY", "YYMMDD", "DATE", "DATE9", "YYMMDD10", */ __pyx_f_7cpython_8datetime_import_datetime(); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 38, __pyx_L1_error) /* "pyreadstat/_readstat_parser.pyx":40 * import_datetime() * * cdef list sas_date_formats = ["WEEKDATE", "MMDDYY", "DDMMYY", "YYMMDD", "DATE", "DATE9", "YYMMDD10", # <<<<<<<<<<<<<< * "DDMMYYB", "DDMMYYB10", "DDMMYYC", "DDMMYYC10", "DDMMYYD", "DDMMYYD10", * "DDMMYYN6", "DDMMYYN8", "DDMMYYP", "DDMMYYP10", "DDMMYYS", "DDMMYYS10", */ __pyx_t_3 = PyList_New(41); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_WEEKDATE); __Pyx_GIVEREF(__pyx_n_s_WEEKDATE); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_WEEKDATE)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYY); __Pyx_GIVEREF(__pyx_n_s_MMDDYY); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_MMDDYY)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYY); __Pyx_GIVEREF(__pyx_n_s_DDMMYY); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_DDMMYY)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YYMMDD); __Pyx_GIVEREF(__pyx_n_s_YYMMDD); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_YYMMDD)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATE); __Pyx_GIVEREF(__pyx_n_s_DATE); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_s_DATE)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATE9); __Pyx_GIVEREF(__pyx_n_s_DATE9); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_DATE9)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YYMMDD10); __Pyx_GIVEREF(__pyx_n_s_YYMMDD10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 6, __pyx_n_s_YYMMDD10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYB); __Pyx_GIVEREF(__pyx_n_s_DDMMYYB); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 7, __pyx_n_s_DDMMYYB)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYB10); __Pyx_GIVEREF(__pyx_n_s_DDMMYYB10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 8, __pyx_n_s_DDMMYYB10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYC); __Pyx_GIVEREF(__pyx_n_s_DDMMYYC); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 9, __pyx_n_s_DDMMYYC)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYC10); __Pyx_GIVEREF(__pyx_n_s_DDMMYYC10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 10, __pyx_n_s_DDMMYYC10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYD); __Pyx_GIVEREF(__pyx_n_s_DDMMYYD); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 11, __pyx_n_s_DDMMYYD)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYD10); __Pyx_GIVEREF(__pyx_n_s_DDMMYYD10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 12, __pyx_n_s_DDMMYYD10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYN6); __Pyx_GIVEREF(__pyx_n_s_DDMMYYN6); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 13, __pyx_n_s_DDMMYYN6)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYN8); __Pyx_GIVEREF(__pyx_n_s_DDMMYYN8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 14, __pyx_n_s_DDMMYYN8)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYP); __Pyx_GIVEREF(__pyx_n_s_DDMMYYP); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 15, __pyx_n_s_DDMMYYP)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYP10); __Pyx_GIVEREF(__pyx_n_s_DDMMYYP10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 16, __pyx_n_s_DDMMYYP10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYS); __Pyx_GIVEREF(__pyx_n_s_DDMMYYS); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 17, __pyx_n_s_DDMMYYS)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DDMMYYS10); __Pyx_GIVEREF(__pyx_n_s_DDMMYYS10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 18, __pyx_n_s_DDMMYYS10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYB); __Pyx_GIVEREF(__pyx_n_s_MMDDYYB); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 19, __pyx_n_s_MMDDYYB)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYB10); __Pyx_GIVEREF(__pyx_n_s_MMDDYYB10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 20, __pyx_n_s_MMDDYYB10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYC); __Pyx_GIVEREF(__pyx_n_s_MMDDYYC); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 21, __pyx_n_s_MMDDYYC)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYC10); __Pyx_GIVEREF(__pyx_n_s_MMDDYYC10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 22, __pyx_n_s_MMDDYYC10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYD); __Pyx_GIVEREF(__pyx_n_s_MMDDYYD); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 23, __pyx_n_s_MMDDYYD)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYD10); __Pyx_GIVEREF(__pyx_n_s_MMDDYYD10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 24, __pyx_n_s_MMDDYYD10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYN6); __Pyx_GIVEREF(__pyx_n_s_MMDDYYN6); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 25, __pyx_n_s_MMDDYYN6)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYN8); __Pyx_GIVEREF(__pyx_n_s_MMDDYYN8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 26, __pyx_n_s_MMDDYYN8)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYP); __Pyx_GIVEREF(__pyx_n_s_MMDDYYP); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 27, __pyx_n_s_MMDDYYP)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYP10); __Pyx_GIVEREF(__pyx_n_s_MMDDYYP10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 28, __pyx_n_s_MMDDYYP10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYS); __Pyx_GIVEREF(__pyx_n_s_MMDDYYS); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 29, __pyx_n_s_MMDDYYS)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MMDDYYS10); __Pyx_GIVEREF(__pyx_n_s_MMDDYYS10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 30, __pyx_n_s_MMDDYYS10)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_WEEKDATX); __Pyx_GIVEREF(__pyx_n_s_WEEKDATX); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 31, __pyx_n_s_WEEKDATX)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DTDATE); __Pyx_GIVEREF(__pyx_n_s_DTDATE); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 32, __pyx_n_s_DTDATE)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_IS8601DA); __Pyx_GIVEREF(__pyx_n_s_IS8601DA); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 33, __pyx_n_s_IS8601DA)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_E8601DA); __Pyx_GIVEREF(__pyx_n_s_E8601DA); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 34, __pyx_n_s_E8601DA)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_B8601DA); __Pyx_GIVEREF(__pyx_n_s_B8601DA); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 35, __pyx_n_s_B8601DA)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YYMMDDB); __Pyx_GIVEREF(__pyx_n_s_YYMMDDB); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 36, __pyx_n_s_YYMMDDB)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YYMMDDD); __Pyx_GIVEREF(__pyx_n_s_YYMMDDD); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 37, __pyx_n_s_YYMMDDD)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YYMMDDN); __Pyx_GIVEREF(__pyx_n_s_YYMMDDN); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 38, __pyx_n_s_YYMMDDN)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YYMMDDP); __Pyx_GIVEREF(__pyx_n_s_YYMMDDP); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 39, __pyx_n_s_YYMMDDP)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YYMMDDS); __Pyx_GIVEREF(__pyx_n_s_YYMMDDS); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 40, __pyx_n_s_YYMMDDS)) __PYX_ERR(0, 40, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":49 * "IS8601DA", "E8601DA", "B8601DA", * "YYMMDDB", "YYMMDDD", "YYMMDDN", "YYMMDDP", "YYMMDDS",] * cdef list sas_datetime_formats = ["DATETIME", "DATETIME18", "DATETIME19", "DATETIME20", "DATETIME21", "DATETIME22", # <<<<<<<<<<<<<< * "E8601DT", "DATEAMPM", "MDYAMPM", "IS8601DT", "B8601DT", "B8601DN"] * cdef list sas_time_formats = ["TIME", "HHMM", "TIME20.3", "TIME20", "TIME5", "TOD", "TIMEAMPM", "IS8601TM", "E8601TM", "B8601TM", ] */ __pyx_t_3 = PyList_New(12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_DATETIME); __Pyx_GIVEREF(__pyx_n_s_DATETIME); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_DATETIME)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATETIME18); __Pyx_GIVEREF(__pyx_n_s_DATETIME18); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_DATETIME18)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATETIME19); __Pyx_GIVEREF(__pyx_n_s_DATETIME19); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_DATETIME19)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATETIME20); __Pyx_GIVEREF(__pyx_n_s_DATETIME20); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_DATETIME20)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATETIME21); __Pyx_GIVEREF(__pyx_n_s_DATETIME21); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_s_DATETIME21)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATETIME22); __Pyx_GIVEREF(__pyx_n_s_DATETIME22); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_DATETIME22)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_E8601DT); __Pyx_GIVEREF(__pyx_n_s_E8601DT); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 6, __pyx_n_s_E8601DT)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATEAMPM); __Pyx_GIVEREF(__pyx_n_s_DATEAMPM); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 7, __pyx_n_s_DATEAMPM)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_MDYAMPM); __Pyx_GIVEREF(__pyx_n_s_MDYAMPM); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 8, __pyx_n_s_MDYAMPM)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_IS8601DT); __Pyx_GIVEREF(__pyx_n_s_IS8601DT); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 9, __pyx_n_s_IS8601DT)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_B8601DT); __Pyx_GIVEREF(__pyx_n_s_B8601DT); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 10, __pyx_n_s_B8601DT)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_B8601DN); __Pyx_GIVEREF(__pyx_n_s_B8601DN); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 11, __pyx_n_s_B8601DN)) __PYX_ERR(0, 49, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":51 * cdef list sas_datetime_formats = ["DATETIME", "DATETIME18", "DATETIME19", "DATETIME20", "DATETIME21", "DATETIME22", * "E8601DT", "DATEAMPM", "MDYAMPM", "IS8601DT", "B8601DT", "B8601DN"] * cdef list sas_time_formats = ["TIME", "HHMM", "TIME20.3", "TIME20", "TIME5", "TOD", "TIMEAMPM", "IS8601TM", "E8601TM", "B8601TM", ] # <<<<<<<<<<<<<< * # "HOUR" # these do not print as full time formats in sas * #cdef list sas_all_formats = sas_date_formats + sas_datetime_formats + sas_time_formats */ __pyx_t_3 = PyList_New(10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_TIME); __Pyx_GIVEREF(__pyx_n_s_TIME); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_TIME)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_HHMM); __Pyx_GIVEREF(__pyx_n_s_HHMM); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_HHMM)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_TIME20_3); __Pyx_GIVEREF(__pyx_kp_s_TIME20_3); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_kp_s_TIME20_3)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_TIME20); __Pyx_GIVEREF(__pyx_n_s_TIME20); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_TIME20)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_TIME5); __Pyx_GIVEREF(__pyx_n_s_TIME5); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_s_TIME5)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_TOD); __Pyx_GIVEREF(__pyx_n_s_TOD); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_TOD)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_TIMEAMPM); __Pyx_GIVEREF(__pyx_n_s_TIMEAMPM); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 6, __pyx_n_s_TIMEAMPM)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_IS8601TM); __Pyx_GIVEREF(__pyx_n_s_IS8601TM); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 7, __pyx_n_s_IS8601TM)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_E8601TM); __Pyx_GIVEREF(__pyx_n_s_E8601TM); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 8, __pyx_n_s_E8601TM)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_B8601TM); __Pyx_GIVEREF(__pyx_n_s_B8601TM); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 9, __pyx_n_s_B8601TM)) __PYX_ERR(0, 51, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":55 * #cdef list sas_all_formats = sas_date_formats + sas_datetime_formats + sas_time_formats * cdef list sas_all_formats * cdef object sas_origin = datetime_new(1960, 1, 1, 0, 0, 0, 0, None) # <<<<<<<<<<<<<< * * cdef list spss_datetime_formats = ["DATETIME", "DATETIME8", 'DATETIME17', 'DATETIME20', 'DATETIME23.2',"YMDHMS16","YMDHMS19","YMDHMS19.2", "YMDHMS20"] */ __pyx_t_3 = ((PyObject *)__pyx_f_7cpython_8datetime_datetime_new(0x7A8, 1, 1, 0, 0, 0, 0, Py_None, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_sas_origin); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_sas_origin, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":57 * cdef object sas_origin = datetime_new(1960, 1, 1, 0, 0, 0, 0, None) * * cdef list spss_datetime_formats = ["DATETIME", "DATETIME8", 'DATETIME17', 'DATETIME20', 'DATETIME23.2',"YMDHMS16","YMDHMS19","YMDHMS19.2", "YMDHMS20"] # <<<<<<<<<<<<<< * cdef list spss_date_formats = ["DATE",'DATE8','DATE11', 'DATE12', "ADATE","ADATE8", "ADATE10", "EDATE", 'EDATE8','EDATE10', "JDATE", "JDATE5", "JDATE7", "SDATE", "SDATE8", "SDATE10",] * cdef list spss_time_formats = ["TIME", "DTIME", 'TIME8', 'TIME5', 'TIME11.2'] */ __pyx_t_3 = PyList_New(9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_DATETIME); __Pyx_GIVEREF(__pyx_n_s_DATETIME); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_DATETIME)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATETIME8); __Pyx_GIVEREF(__pyx_n_s_DATETIME8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_DATETIME8)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATETIME17); __Pyx_GIVEREF(__pyx_n_s_DATETIME17); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_DATETIME17)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATETIME20); __Pyx_GIVEREF(__pyx_n_s_DATETIME20); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_DATETIME20)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_DATETIME23_2); __Pyx_GIVEREF(__pyx_kp_s_DATETIME23_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_kp_s_DATETIME23_2)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YMDHMS16); __Pyx_GIVEREF(__pyx_n_s_YMDHMS16); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_YMDHMS16)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YMDHMS19); __Pyx_GIVEREF(__pyx_n_s_YMDHMS19); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 6, __pyx_n_s_YMDHMS19)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_YMDHMS19_2); __Pyx_GIVEREF(__pyx_kp_s_YMDHMS19_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 7, __pyx_kp_s_YMDHMS19_2)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_YMDHMS20); __Pyx_GIVEREF(__pyx_n_s_YMDHMS20); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 8, __pyx_n_s_YMDHMS20)) __PYX_ERR(0, 57, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":58 * * cdef list spss_datetime_formats = ["DATETIME", "DATETIME8", 'DATETIME17', 'DATETIME20', 'DATETIME23.2',"YMDHMS16","YMDHMS19","YMDHMS19.2", "YMDHMS20"] * cdef list spss_date_formats = ["DATE",'DATE8','DATE11', 'DATE12', "ADATE","ADATE8", "ADATE10", "EDATE", 'EDATE8','EDATE10', "JDATE", "JDATE5", "JDATE7", "SDATE", "SDATE8", "SDATE10",] # <<<<<<<<<<<<<< * cdef list spss_time_formats = ["TIME", "DTIME", 'TIME8', 'TIME5', 'TIME11.2'] * #cdef list spss_all_formats = spss_date_formats + spss_datetime_formats + spss_time_formats */ __pyx_t_3 = PyList_New(16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_DATE); __Pyx_GIVEREF(__pyx_n_s_DATE); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_DATE)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATE8); __Pyx_GIVEREF(__pyx_n_s_DATE8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_DATE8)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATE11); __Pyx_GIVEREF(__pyx_n_s_DATE11); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_DATE11)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DATE12); __Pyx_GIVEREF(__pyx_n_s_DATE12); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_DATE12)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_ADATE); __Pyx_GIVEREF(__pyx_n_s_ADATE); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_s_ADATE)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_ADATE8); __Pyx_GIVEREF(__pyx_n_s_ADATE8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_ADATE8)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_ADATE10); __Pyx_GIVEREF(__pyx_n_s_ADATE10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 6, __pyx_n_s_ADATE10)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_EDATE); __Pyx_GIVEREF(__pyx_n_s_EDATE); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 7, __pyx_n_s_EDATE)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_EDATE8); __Pyx_GIVEREF(__pyx_n_s_EDATE8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 8, __pyx_n_s_EDATE8)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_EDATE10); __Pyx_GIVEREF(__pyx_n_s_EDATE10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 9, __pyx_n_s_EDATE10)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_JDATE); __Pyx_GIVEREF(__pyx_n_s_JDATE); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 10, __pyx_n_s_JDATE)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_JDATE5); __Pyx_GIVEREF(__pyx_n_s_JDATE5); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 11, __pyx_n_s_JDATE5)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_JDATE7); __Pyx_GIVEREF(__pyx_n_s_JDATE7); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 12, __pyx_n_s_JDATE7)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_SDATE); __Pyx_GIVEREF(__pyx_n_s_SDATE); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 13, __pyx_n_s_SDATE)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_SDATE8); __Pyx_GIVEREF(__pyx_n_s_SDATE8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 14, __pyx_n_s_SDATE8)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_SDATE10); __Pyx_GIVEREF(__pyx_n_s_SDATE10); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 15, __pyx_n_s_SDATE10)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":59 * cdef list spss_datetime_formats = ["DATETIME", "DATETIME8", 'DATETIME17', 'DATETIME20', 'DATETIME23.2',"YMDHMS16","YMDHMS19","YMDHMS19.2", "YMDHMS20"] * cdef list spss_date_formats = ["DATE",'DATE8','DATE11', 'DATE12', "ADATE","ADATE8", "ADATE10", "EDATE", 'EDATE8','EDATE10', "JDATE", "JDATE5", "JDATE7", "SDATE", "SDATE8", "SDATE10",] * cdef list spss_time_formats = ["TIME", "DTIME", 'TIME8', 'TIME5', 'TIME11.2'] # <<<<<<<<<<<<<< * #cdef list spss_all_formats = spss_date_formats + spss_datetime_formats + spss_time_formats * cdef list spss_all_formats */ __pyx_t_3 = PyList_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_TIME); __Pyx_GIVEREF(__pyx_n_s_TIME); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_TIME)) __PYX_ERR(0, 59, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DTIME); __Pyx_GIVEREF(__pyx_n_s_DTIME); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_DTIME)) __PYX_ERR(0, 59, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_TIME8); __Pyx_GIVEREF(__pyx_n_s_TIME8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_TIME8)) __PYX_ERR(0, 59, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_TIME5); __Pyx_GIVEREF(__pyx_n_s_TIME5); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_TIME5)) __PYX_ERR(0, 59, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_TIME11_2); __Pyx_GIVEREF(__pyx_kp_s_TIME11_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_kp_s_TIME11_2)) __PYX_ERR(0, 59, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":62 * #cdef list spss_all_formats = spss_date_formats + spss_datetime_formats + spss_time_formats * cdef list spss_all_formats * cdef object spss_origin = datetime_new(1582, 10, 14, 0, 0, 0, 0, None) # <<<<<<<<<<<<<< * * cdef list stata_datetime_formats = ["%tC", "%tc"] */ __pyx_t_3 = ((PyObject *)__pyx_f_7cpython_8datetime_datetime_new(0x62E, 10, 14, 0, 0, 0, 0, Py_None, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_spss_origin); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_spss_origin, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":64 * cdef object spss_origin = datetime_new(1582, 10, 14, 0, 0, 0, 0, None) * * cdef list stata_datetime_formats = ["%tC", "%tc"] # <<<<<<<<<<<<<< * cdef list stata_date_formats = ["%td", "%d", "%tdD_m_Y", "%tdCCYY-NN-DD"] * cdef list stata_time_formats = ["%tcHH:MM:SS", "%tcHH:MM"] */ __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_kp_s_tC); __Pyx_GIVEREF(__pyx_kp_s_tC); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_tC)) __PYX_ERR(0, 64, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_tc); __Pyx_GIVEREF(__pyx_kp_s_tc); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_kp_s_tc)) __PYX_ERR(0, 64, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":65 * * cdef list stata_datetime_formats = ["%tC", "%tc"] * cdef list stata_date_formats = ["%td", "%d", "%tdD_m_Y", "%tdCCYY-NN-DD"] # <<<<<<<<<<<<<< * cdef list stata_time_formats = ["%tcHH:MM:SS", "%tcHH:MM"] * #cdef list stata_all_formats = stata_datetime_formats + stata_date_formats + stata_time_formats */ __pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_kp_s_td); __Pyx_GIVEREF(__pyx_kp_s_td); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_td)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_d); __Pyx_GIVEREF(__pyx_kp_s_d); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_kp_s_d)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_tdD_m_Y); __Pyx_GIVEREF(__pyx_kp_s_tdD_m_Y); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_kp_s_tdD_m_Y)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_tdCCYY_NN_DD); __Pyx_GIVEREF(__pyx_kp_s_tdCCYY_NN_DD); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_kp_s_tdCCYY_NN_DD)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":66 * cdef list stata_datetime_formats = ["%tC", "%tc"] * cdef list stata_date_formats = ["%td", "%d", "%tdD_m_Y", "%tdCCYY-NN-DD"] * cdef list stata_time_formats = ["%tcHH:MM:SS", "%tcHH:MM"] # <<<<<<<<<<<<<< * #cdef list stata_all_formats = stata_datetime_formats + stata_date_formats + stata_time_formats * cdef list stata_all_formats */ __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_kp_s_tcHH_MM_SS); __Pyx_GIVEREF(__pyx_kp_s_tcHH_MM_SS); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_kp_s_tcHH_MM_SS)) __PYX_ERR(0, 66, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_s_tcHH_MM); __Pyx_GIVEREF(__pyx_kp_s_tcHH_MM); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_kp_s_tcHH_MM)) __PYX_ERR(0, 66, __pyx_L1_error); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":69 * #cdef list stata_all_formats = stata_datetime_formats + stata_date_formats + stata_time_formats * cdef list stata_all_formats * cdef object stata_origin = datetime_new(1960, 1, 1, 0, 0, 0, 0, None) # <<<<<<<<<<<<<< * * cdef dict readstat_to_numpy_types = {READSTAT_TYPE_STRING: object, READSTAT_TYPE_STRING_REF: object, */ __pyx_t_3 = ((PyObject *)__pyx_f_7cpython_8datetime_datetime_new(0x7A8, 1, 1, 0, 0, 0, 0, Py_None, NULL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_stata_origin); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_stata_origin, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":71 * cdef object stata_origin = datetime_new(1960, 1, 1, 0, 0, 0, 0, None) * * cdef dict readstat_to_numpy_types = {READSTAT_TYPE_STRING: object, READSTAT_TYPE_STRING_REF: object, # <<<<<<<<<<<<<< * READSTAT_TYPE_INT8: np.int64, READSTAT_TYPE_INT16: np.int64, READSTAT_TYPE_INT32:np.int64, * READSTAT_TYPE_FLOAT: np.float64, READSTAT_TYPE_DOUBLE: np.float64} */ __pyx_t_3 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_STRING); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_builtin_object) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_STRING_REF); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_builtin_object) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":72 * * cdef dict readstat_to_numpy_types = {READSTAT_TYPE_STRING: object, READSTAT_TYPE_STRING_REF: object, * READSTAT_TYPE_INT8: np.int64, READSTAT_TYPE_INT16: np.int64, READSTAT_TYPE_INT32:np.int64, # <<<<<<<<<<<<<< * READSTAT_TYPE_FLOAT: np.float64, READSTAT_TYPE_DOUBLE: np.float64} * */ __pyx_t_2 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_INT8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_5) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_INT16); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_t_5, __pyx_t_4) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_INT32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_int64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_t_4, __pyx_t_2) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_parser.pyx":73 * cdef dict readstat_to_numpy_types = {READSTAT_TYPE_STRING: object, READSTAT_TYPE_STRING_REF: object, * READSTAT_TYPE_INT8: np.int64, READSTAT_TYPE_INT16: np.int64, READSTAT_TYPE_INT32:np.int64, * READSTAT_TYPE_FLOAT: np.float64, READSTAT_TYPE_DOUBLE: np.float64} # <<<<<<<<<<<<<< * * cdef class data_container: */ __pyx_t_2 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_FLOAT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_float64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_t_2, __pyx_t_5) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_DOUBLE); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_float64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_t_5, __pyx_t_4) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "(tree fragment)":1 * def __reduce_cython__(self): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): */ __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_16_readstat_parser_14data_container_3__reduce_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_data_container___reduce_cython, NULL, __pyx_n_s_pyreadstat__readstat_parser, __pyx_d, ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reduce_cython, __pyx_t_3) < 0) __PYX_ERR(1, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "(tree fragment)":3 * def __reduce_cython__(self): * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< * raise TypeError, "no default __reduce__ due to non-trivial __cinit__" */ __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_16_readstat_parser_14data_container_5__setstate_cython__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_data_container___setstate_cython, NULL, __pyx_n_s_pyreadstat__readstat_parser, __pyx_d, ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 3, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_setstate_cython, __pyx_t_3) < 0) __PYX_ERR(1, 3, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":119 * self.mtime = 0 * * class metadata_container: # <<<<<<<<<<<<<< * """ * This class holds metadata we want to give back to python */ __pyx_t_3 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_empty_tuple, __pyx_n_s_metadata_container, __pyx_n_s_metadata_container, (PyObject *) NULL, __pyx_n_s_pyreadstat__readstat_parser, __pyx_kp_s_This_class_holds_metadata_we_wa); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "pyreadstat/_readstat_parser.pyx":123 * This class holds metadata we want to give back to python * """ * def __init__(self): # <<<<<<<<<<<<<< * self.column_names = list() * self.column_labels = list() */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_16_readstat_parser_18metadata_container_1__init__, 0, __pyx_n_s_metadata_container___init, NULL, __pyx_n_s_pyreadstat__readstat_parser, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_parser.pyx":119 * self.mtime = 0 * * class metadata_container: # <<<<<<<<<<<<<< * """ * This class holds metadata we want to give back to python */ __pyx_t_4 = __Pyx_Py3ClassCreate(((PyObject*)&__Pyx_DefaultClassType), __pyx_n_s_metadata_container, __pyx_empty_tuple, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_metadata_container, __pyx_t_4) < 0) __PYX_ERR(0, 119, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_parser.pyx":147 * * * class ReadstatError(Exception): # <<<<<<<<<<<<<< * """ * Just defining a custom exception to raise when readstat gives an error return code. */ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])); __Pyx_GIVEREF((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])))) __PYX_ERR(0, 147, __pyx_L1_error); __pyx_t_4 = __Pyx_PEP560_update_bases(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_CalculateMetaclass(NULL, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_5, __pyx_t_4, __pyx_n_s_ReadstatError, __pyx_n_s_ReadstatError, (PyObject *) NULL, __pyx_n_s_pyreadstat__readstat_parser, __pyx_kp_s_Just_defining_a_custom_exceptio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__pyx_t_4 != __pyx_t_3) { if (unlikely((PyDict_SetItemString(__pyx_t_2, "__orig_bases__", __pyx_t_3) < 0))) __PYX_ERR(0, 147, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_Py3ClassCreate(__pyx_t_5, __pyx_n_s_ReadstatError, __pyx_t_4, __pyx_t_2, NULL, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReadstatError, __pyx_t_3) < 0) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_parser.pyx":153 * pass * * class PyreadstatError(Exception): # <<<<<<<<<<<<<< * """ * Just defining a custom exception to raise when pyreadstat raises an exception. */ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])); __Pyx_GIVEREF((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])))) __PYX_ERR(0, 153, __pyx_L1_error); __pyx_t_5 = __Pyx_PEP560_update_bases(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_5, __pyx_n_s_PyreadstatError, __pyx_n_s_PyreadstatError, (PyObject *) NULL, __pyx_n_s_pyreadstat__readstat_parser, __pyx_kp_s_Just_defining_a_custom_exceptio_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (__pyx_t_5 != __pyx_t_4) { if (unlikely((PyDict_SetItemString(__pyx_t_3, "__orig_bases__", __pyx_t_4) < 0))) __PYX_ERR(0, 153, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_PyreadstatError, __pyx_t_5, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_PyreadstatError, __pyx_t_4) < 0) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/_readstat_parser.pyx":1 * # cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # <<<<<<<<<<<<<< * * # ############################################################################# */ __pyx_t_5 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_5) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); if (__pyx_m) { if (__pyx_d && stringtab_initialized) { __Pyx_AddTraceback("init pyreadstat._readstat_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); } #if !CYTHON_USE_MODULE_STATE Py_CLEAR(__pyx_m); #else Py_DECREF(__pyx_m); if (pystate_addmodule_run) { PyObject *tp, *value, *tb; PyErr_Fetch(&tp, &value, &tb); PyState_RemoveModule(&__pyx_moduledef); PyErr_Restore(tp, value, tb); } #endif } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init pyreadstat._readstat_parser"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #elif PY_MAJOR_VERSION >= 3 return __pyx_m; #else return; #endif } /* #### Code section: cleanup_globals ### */ /* #### Code section: cleanup_module ### */ /* #### Code section: main_method ### */ /* #### Code section: utility_code_pragmas ### */ #ifdef _MSC_VER #pragma warning( push ) /* Warning 4127: conditional expression is constant * Cython uses constant conditional expressions to allow in inline functions to be optimized at * compile-time, so this warning is not useful */ #pragma warning( disable : 4127 ) #endif /* #### Code section: utility_code_def ### */ /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i= 0x030C00A6 PyObject *current_exception = tstate->current_exception; if (unlikely(!current_exception)) return 0; exc_type = (PyObject*) Py_TYPE(current_exception); if (exc_type == err) return 1; #else exc_type = tstate->curexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(exc_type); #endif if (unlikely(PyTuple_Check(err))) { result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); } else { result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(exc_type); #endif return result; } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject *tmp_value; assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); if (value) { #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) #endif PyException_SetTraceback(value, tb); } tmp_value = tstate->current_exception; tstate->current_exception = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject* exc_value; exc_value = tstate->current_exception; tstate->current_exception = 0; *value = exc_value; *type = NULL; *tb = NULL; if (exc_value) { *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); #if CYTHON_COMPILING_IN_CPYTHON *tb = ((PyBaseExceptionObject*) exc_value)->traceback; Py_XINCREF(*tb); #else *tb = PyException_GetTraceback(exc_value); #endif } #else *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif } #endif /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #endif /* PyObjectGetAttrStrNoError */ #if __PYX_LIMITED_VERSION_HEX < 0x030d00A1 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 (void) PyObject_GetOptionalAttr(obj, attr_name, &result); return result; #else #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); } #endif result = __Pyx_PyObject_GetAttrStr(obj, attr_name); if (unlikely(!result)) { __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; #endif } /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_b, name); if (unlikely(!result) && !PyErr_Occurred()) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } /* ExtTypeTest */ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { __Pyx_TypeName obj_type_name; __Pyx_TypeName type_name; if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } if (likely(__Pyx_TypeCheck(obj, type))) return 1; obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); type_name = __Pyx_PyType_GetName(type); PyErr_Format(PyExc_TypeError, "Cannot convert " __Pyx_FMT_TYPENAME " to " __Pyx_FMT_TYPENAME, obj_type_name, type_name); __Pyx_DECREF_TypeName(obj_type_name); __Pyx_DECREF_TypeName(type_name); return 0; } /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = Py_TYPE(func)->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; #endif result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { __Pyx_PyThreadState_declare CYTHON_UNUSED_VAR(cause); Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyException_SetTraceback(value, tb); #elif CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #else PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* TupleAndListFromArray */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { PyObject *v; Py_ssize_t i; for (i = 0; i < length; i++) { v = dest[i] = src[i]; Py_INCREF(v); } } static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { Py_INCREF(__pyx_empty_tuple); return __pyx_empty_tuple; } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n); return res; } static CYTHON_INLINE PyObject * __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return PyList_New(0); } res = PyList_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n); return res; } #endif /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API return PyObject_RichCompareBool(s1, s2, equals); #else #if PY_MAJOR_VERSION < 3 PyObject* owned_ref = NULL; #endif int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); #if PY_MAJOR_VERSION < 3 if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { owned_ref = PyUnicode_FromObject(s2); if (unlikely(!owned_ref)) return -1; s2 = owned_ref; s2_is_unicode = 1; } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { owned_ref = PyUnicode_FromObject(s1); if (unlikely(!owned_ref)) return -1; s1 = owned_ref; s1_is_unicode = 1; } else if (((!s2_is_unicode) & (!s1_is_unicode))) { return __Pyx_PyBytes_Equals(s1, s2, equals); } #endif if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length; int kind; void *data1, *data2; if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; length = __Pyx_PyUnicode_GET_LENGTH(s1); if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; #if CYTHON_PEP393_ENABLED hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; #else hash1 = ((PyUnicodeObject*)s1)->hash; hash2 = ((PyUnicodeObject*)s2)->hash; #endif if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ); return_ne: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_NE); #endif } /* fastcall */ #if CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s) { Py_ssize_t i, n = PyTuple_GET_SIZE(kwnames); for (i = 0; i < n; i++) { if (s == PyTuple_GET_ITEM(kwnames, i)) return kwvalues[i]; } for (i = 0; i < n; i++) { int eq = __Pyx_PyUnicode_Equals(s, PyTuple_GET_ITEM(kwnames, i), Py_EQ); if (unlikely(eq != 0)) { if (unlikely(eq < 0)) return NULL; return kwvalues[i]; } } return NULL; } #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) { Py_ssize_t i, nkwargs = PyTuple_GET_SIZE(kwnames); PyObject *dict; dict = PyDict_New(); if (unlikely(!dict)) return NULL; for (i=0; i= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } /* ParseKeywords */ static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject *const *kwvalues, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; int kwds_is_tuple = CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds)); while (1) { Py_XDECREF(key); key = NULL; Py_XDECREF(value); value = NULL; if (kwds_is_tuple) { Py_ssize_t size; #if CYTHON_ASSUME_SAFE_MACROS size = PyTuple_GET_SIZE(kwds); #else size = PyTuple_Size(kwds); if (size < 0) goto bad; #endif if (pos >= size) break; #if CYTHON_AVOID_BORROWED_REFS key = __Pyx_PySequence_ITEM(kwds, pos); if (!key) goto bad; #elif CYTHON_ASSUME_SAFE_MACROS key = PyTuple_GET_ITEM(kwds, pos); #else key = PyTuple_GetItem(kwds, pos); if (!key) goto bad; #endif value = kwvalues[pos]; pos++; } else { if (!PyDict_Next(kwds, &pos, &key, &value)) break; #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(key); #endif } name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(value); Py_DECREF(key); #endif key = NULL; value = NULL; continue; } #if !CYTHON_AVOID_BORROWED_REFS Py_INCREF(key); #endif Py_INCREF(value); name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; #if CYTHON_AVOID_BORROWED_REFS value = NULL; #endif break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = ( #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif PyUnicode_Compare(**name, key) ); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; #if CYTHON_AVOID_BORROWED_REFS value = NULL; #endif break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } Py_XDECREF(key); Py_XDECREF(value); return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: #if PY_MAJOR_VERSION < 3 PyErr_Format(PyExc_TypeError, "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: Py_XDECREF(key); Py_XDECREF(value); return -1; } /* PyObjectSetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_setattro)) return tp->tp_setattro(obj, attr_name, value); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_setattr)) return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); #endif return PyObject_SetAttr(obj, attr_name, value); } #endif /* ModFloat[double] */ static CYTHON_INLINE double __Pyx_mod_double(double a, double b) { double r = fmod(a, b); r += ((r != 0) & ((r < 0) ^ (b < 0))) * b; return r; } /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL && !CYTHON_VECTORCALL static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; assert(globals != NULL); /* XXX Perhaps we should create a specialized PyFrame_New() that doesn't take locals, but does take builtins without sanity checking them. */ assert(tstate != NULL); f = PyFrame_New(tstate, co, globals, NULL); if (f == NULL) { return NULL; } fastlocals = __Pyx_PyFrame_GetLocalsplus(f); for (i = 0; i < na; i++) { Py_INCREF(*args); fastlocals[i] = *args++; } result = PyEval_EvalFrameEx(f,0); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; return result; } static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); PyObject *closure; #if PY_MAJOR_VERSION >= 3 PyObject *kwdefs; #endif PyObject *kwtuple, **k; PyObject **d; Py_ssize_t nd; Py_ssize_t nk; PyObject *result; assert(kwargs == NULL || PyDict_Check(kwargs)); nk = kwargs ? PyDict_Size(kwargs) : 0; #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) { return NULL; } #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) { return NULL; } #endif if ( #if PY_MAJOR_VERSION >= 3 co->co_kwonlyargcount == 0 && #endif likely(kwargs == NULL || nk == 0) && co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { if (argdefs == NULL && co->co_argcount == nargs) { result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); goto done; } else if (nargs == 0 && argdefs != NULL && co->co_argcount == Py_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ args = &PyTuple_GET_ITEM(argdefs, 0); result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); goto done; } } if (kwargs != NULL) { Py_ssize_t pos, i; kwtuple = PyTuple_New(2 * nk); if (kwtuple == NULL) { result = NULL; goto done; } k = &PyTuple_GET_ITEM(kwtuple, 0); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { Py_INCREF(k[i]); Py_INCREF(k[i+1]); i += 2; } nk = i / 2; } else { kwtuple = NULL; k = NULL; } closure = PyFunction_GET_CLOSURE(func); #if PY_MAJOR_VERSION >= 3 kwdefs = PyFunction_GET_KW_DEFAULTS(func); #endif if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); nd = Py_SIZE(argdefs); } else { d = NULL; nd = 0; } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, closure); #endif Py_XDECREF(kwtuple); done: Py_LeaveRecursiveCall(); return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); self = __Pyx_CyOrPyCFunction_GET_SELF(func); #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; #endif result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectFastCall */ #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs) { PyObject *argstuple; PyObject *result = 0; size_t i; argstuple = PyTuple_New((Py_ssize_t)nargs); if (unlikely(!argstuple)) return NULL; for (i = 0; i < nargs; i++) { Py_INCREF(args[i]); if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) < 0) goto bad; } result = __Pyx_PyObject_Call(func, argstuple, kwargs); bad: Py_DECREF(argstuple); return result; } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t _nargs, PyObject *kwargs) { Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); #if CYTHON_COMPILING_IN_CPYTHON if (nargs == 0 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) return __Pyx_PyObject_CallMethO(func, NULL); } else if (nargs == 1 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) return __Pyx_PyObject_CallMethO(func, args[0]); } #endif #if PY_VERSION_HEX < 0x030800B1 #if CYTHON_FAST_PYCCALL if (PyCFunction_Check(func)) { if (kwargs) { return _PyCFunction_FastCallDict(func, args, nargs, kwargs); } else { return _PyCFunction_FastCallKeywords(func, args, nargs, NULL); } } #if PY_VERSION_HEX >= 0x030700A1 if (!kwargs && __Pyx_IS_TYPE(func, &PyMethodDescr_Type)) { return _PyMethodDescr_FastCallKeywords(func, args, nargs, NULL); } #endif #endif #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs); } #endif #endif if (kwargs == NULL) { #if CYTHON_VECTORCALL #if PY_VERSION_HEX < 0x03090000 vectorcallfunc f = _PyVectorcall_Function(func); #else vectorcallfunc f = PyVectorcall_Function(func); #endif if (f) { return f(func, args, (size_t)nargs, NULL); } #elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL if (__Pyx_CyFunction_CheckExact(func)) { __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func); if (f) return f(func, args, (size_t)nargs, NULL); } #endif } if (nargs == 0) { return __Pyx_PyObject_Call(func, __pyx_empty_tuple, kwargs); } #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); #else return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); #endif } /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (unlikely(!j)) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; if (mm && mm->mp_subscript) { PyObject *r, *key = PyInt_FromSsize_t(i); if (unlikely(!key)) return NULL; r = mm->mp_subscript(o, key); Py_DECREF(key); return r; } if (likely(sm && sm->sq_item)) { if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { Py_ssize_t l = sm->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return sm->sq_item(o, i); } } #else if (is_list || !PyMapping_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } else if (unlikely(PyErr_Occurred())) { return NULL; } #elif CYTHON_COMPILING_IN_LIMITED_API if (unlikely(!__pyx_m)) { return NULL; } result = PyObject_GetAttr(__pyx_m, name); if (likely(result)) { return result; } #else result = PyDict_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } #endif #else result = PyObject_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* RaiseUnboundLocalError */ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } /* UnicodeConcatInPlace */ # if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 static int __Pyx_unicode_modifiable(PyObject *unicode) { if (Py_REFCNT(unicode) != 1) return 0; if (!PyUnicode_CheckExact(unicode)) return 0; if (PyUnicode_CHECK_INTERNED(unicode)) return 0; return 1; } static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_left, PyObject *right #if CYTHON_REFNANNY , void* __pyx_refnanny #endif ) { PyObject *left = *p_left; Py_ssize_t left_len, right_len, new_len; if (unlikely(__Pyx_PyUnicode_READY(left) == -1)) return NULL; if (unlikely(__Pyx_PyUnicode_READY(right) == -1)) return NULL; left_len = PyUnicode_GET_LENGTH(left); if (left_len == 0) { Py_INCREF(right); return right; } right_len = PyUnicode_GET_LENGTH(right); if (right_len == 0) { Py_INCREF(left); return left; } if (unlikely(left_len > PY_SSIZE_T_MAX - right_len)) { PyErr_SetString(PyExc_OverflowError, "strings are too large to concat"); return NULL; } new_len = left_len + right_len; if (__Pyx_unicode_modifiable(left) && PyUnicode_CheckExact(right) && PyUnicode_KIND(right) <= PyUnicode_KIND(left) && !(PyUnicode_IS_ASCII(left) && !PyUnicode_IS_ASCII(right))) { int ret; __Pyx_GIVEREF(*p_left); ret = PyUnicode_Resize(p_left, new_len); __Pyx_GOTREF(*p_left); if (unlikely(ret != 0)) return NULL; #if PY_VERSION_HEX >= 0x030d0000 if (unlikely(PyUnicode_CopyCharacters(*p_left, left_len, right, 0, right_len) < 0)) return NULL; #else _PyUnicode_FastCopyCharacters(*p_left, left_len, right, 0, right_len); #endif __Pyx_INCREF(*p_left); __Pyx_GIVEREF(*p_left); return *p_left; } else { return __Pyx_PyUnicode_Concat(left, right); } } #endif /* RaiseUnexpectedTypeError */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj) { __Pyx_TypeName obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME, expected, obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); return 0; } /* DictGetItem */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { if (unlikely(PyTuple_Check(key))) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) { PyErr_SetObject(PyExc_KeyError, args); Py_DECREF(args); } } else { PyErr_SetObject(PyExc_KeyError, key); } } return NULL; } Py_INCREF(value); return value; } #endif /* SetItemInt */ static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { int r; if (unlikely(!j)) return -1; r = PyObject_SetItem(o, j, v); Py_DECREF(j); return r; } static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) { PyObject* old = PyList_GET_ITEM(o, n); Py_INCREF(v); PyList_SET_ITEM(o, n, v); Py_DECREF(old); return 1; } } else { PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; if (mm && mm->mp_ass_subscript) { int r; PyObject *key = PyInt_FromSsize_t(i); if (unlikely(!key)) return -1; r = mm->mp_ass_subscript(o, key, v); Py_DECREF(key); return r; } if (likely(sm && sm->sq_ass_item)) { if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { Py_ssize_t l = sm->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return -1; PyErr_Clear(); } } return sm->sq_ass_item(o, i, v); } } #else if (is_list || !PyMapping_Check(o)) { return PySequence_SetItem(o, i, v); } #endif return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); } /* SliceObject */ static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, int has_cstart, int has_cstop, int wraparound) { __Pyx_TypeName obj_type_name; #if CYTHON_USE_TYPE_SLOTS PyMappingMethods* mp; #if PY_MAJOR_VERSION < 3 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; if (likely(ms && ms->sq_ass_slice)) { if (!has_cstart) { if (_py_start && (*_py_start != Py_None)) { cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstart = 0; } if (!has_cstop) { if (_py_stop && (*_py_stop != Py_None)) { cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstop = PY_SSIZE_T_MAX; } if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { Py_ssize_t l = ms->sq_length(obj); if (likely(l >= 0)) { if (cstop < 0) { cstop += l; if (cstop < 0) cstop = 0; } if (cstart < 0) { cstart += l; if (cstart < 0) cstart = 0; } } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) goto bad; PyErr_Clear(); } } return ms->sq_ass_slice(obj, cstart, cstop, value); } #else CYTHON_UNUSED_VAR(wraparound); #endif mp = Py_TYPE(obj)->tp_as_mapping; if (likely(mp && mp->mp_ass_subscript)) #else CYTHON_UNUSED_VAR(wraparound); #endif { int result; PyObject *py_slice, *py_start, *py_stop; if (_py_slice) { py_slice = *_py_slice; } else { PyObject* owned_start = NULL; PyObject* owned_stop = NULL; if (_py_start) { py_start = *_py_start; } else { if (has_cstart) { owned_start = py_start = PyInt_FromSsize_t(cstart); if (unlikely(!py_start)) goto bad; } else py_start = Py_None; } if (_py_stop) { py_stop = *_py_stop; } else { if (has_cstop) { owned_stop = py_stop = PyInt_FromSsize_t(cstop); if (unlikely(!py_stop)) { Py_XDECREF(owned_start); goto bad; } } else py_stop = Py_None; } py_slice = PySlice_New(py_start, py_stop, Py_None); Py_XDECREF(owned_start); Py_XDECREF(owned_stop); if (unlikely(!py_slice)) goto bad; } #if CYTHON_USE_TYPE_SLOTS result = mp->mp_ass_subscript(obj, py_slice, value); #else result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice); #endif if (!_py_slice) { Py_DECREF(py_slice); } return result; } obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "'" __Pyx_FMT_TYPENAME "' object does not support slice %.10s", obj_type_name, value ? "assignment" : "deletion"); __Pyx_DECREF_TypeName(obj_type_name); bad: return -1; } /* PyObjectCallOneArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *args[2] = {NULL, arg}; return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* UnpackUnboundCMethod */ static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) { PyObject *result; PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args)); if (unlikely(!selfless_args)) return NULL; result = PyObject_Call(method, selfless_args, kwargs); Py_DECREF(selfless_args); return result; } static PyMethodDef __Pyx_UnboundCMethod_Def = { "CythonUnboundCMethod", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall), METH_VARARGS | METH_KEYWORDS, NULL }; static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { PyObject *method; method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); if (unlikely(!method)) return -1; target->method = method; #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) #else if (likely(!__Pyx_CyOrPyCFunction_Check(method))) #endif { PyMethodDescrObject *descr = (PyMethodDescrObject*) method; target->func = descr->d_method->ml_meth; target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); } else #endif #if CYTHON_COMPILING_IN_PYPY #else if (PyCFunction_Check(method)) #endif { PyObject *self; int self_found; #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY self = PyObject_GetAttrString(method, "__self__"); if (!self) { PyErr_Clear(); } #else self = PyCFunction_GET_SELF(method); #endif self_found = (self && self != Py_None); #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY Py_XDECREF(self); #endif if (self_found) { PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); if (unlikely(!unbound_method)) return -1; Py_DECREF(method); target->method = unbound_method; } } return 0; } /* CallUnboundCMethod1 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) { if (likely(cfunc->func)) { int flag = cfunc->flag; if (flag == METH_O) { return (*(cfunc->func))(self, arg); } else if ((PY_VERSION_HEX >= 0x030600B1) && flag == METH_FASTCALL) { #if PY_VERSION_HEX >= 0x030700A0 return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1); #else return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); #endif } else if ((PY_VERSION_HEX >= 0x030700A0) && flag == (METH_FASTCALL | METH_KEYWORDS)) { return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); } } return __Pyx__CallUnboundCMethod1(cfunc, self, arg); } #endif static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){ PyObject *args, *result = NULL; if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { args = PyTuple_New(1); if (unlikely(!args)) goto bad; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); if (cfunc->flag & METH_KEYWORDS) result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL); else result = (*cfunc->func)(self, args); } else { args = PyTuple_New(2); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg); PyTuple_SET_ITEM(args, 1, arg); result = __Pyx_PyObject_Call(cfunc->method, args, NULL); } #else args = PyTuple_Pack(2, self, arg); if (unlikely(!args)) goto bad; result = __Pyx_PyObject_Call(cfunc->method, args, NULL); #endif bad: Py_XDECREF(args); return result; } /* CallUnboundCMethod2 */ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1 static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) { if (likely(cfunc->func)) { PyObject *args[2] = {arg1, arg2}; if (cfunc->flag == METH_FASTCALL) { #if PY_VERSION_HEX >= 0x030700A0 return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2); #else return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL); #endif } #if PY_VERSION_HEX >= 0x030700A0 if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL); #endif } return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2); } #endif static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){ PyObject *args, *result = NULL; if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { args = PyTuple_New(2); if (unlikely(!args)) goto bad; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); if (cfunc->flag & METH_KEYWORDS) result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL); else result = (*cfunc->func)(self, args); } else { args = PyTuple_New(3); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg1); PyTuple_SET_ITEM(args, 1, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 2, arg2); result = __Pyx_PyObject_Call(cfunc->method, args, NULL); } #else args = PyTuple_Pack(3, self, arg1, arg2); if (unlikely(!args)) goto bad; result = __Pyx_PyObject_Call(cfunc->method, args, NULL); #endif bad: Py_XDECREF(args); return result; } /* dict_getitem_default */ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { PyObject* value; #if PY_MAJOR_VERSION >= 3 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000) value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (unlikely(PyErr_Occurred())) return NULL; value = default_value; } Py_INCREF(value); if ((1)); #else if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) { value = PyDict_GetItem(d, key); if (unlikely(!value)) { value = default_value; } Py_INCREF(value); } #endif else { if (default_value == Py_None) value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key); else value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value); } return value; } /* PyObjectCall2Args */ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { PyObject *args[3] = {NULL, arg1, arg2}; return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectGetMethod */ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { PyObject *attr; #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP __Pyx_TypeName type_name; PyTypeObject *tp = Py_TYPE(obj); PyObject *descr; descrgetfunc f = NULL; PyObject **dictptr, *dict; int meth_found = 0; assert (*method == NULL); if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; } if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { return 0; } descr = _PyType_Lookup(tp, name); if (likely(descr != NULL)) { Py_INCREF(descr); #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) #elif PY_MAJOR_VERSION >= 3 #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type))) #endif #else #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr))) #endif #endif { meth_found = 1; } else { f = Py_TYPE(descr)->tp_descr_get; if (f != NULL && PyDescr_IsData(descr)) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } } } dictptr = _PyObject_GetDictPtr(obj); if (dictptr != NULL && (dict = *dictptr) != NULL) { Py_INCREF(dict); attr = __Pyx_PyDict_GetItemStr(dict, name); if (attr != NULL) { Py_INCREF(attr); Py_DECREF(dict); Py_XDECREF(descr); goto try_unpack; } Py_DECREF(dict); } if (meth_found) { *method = descr; return 1; } if (f != NULL) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } if (likely(descr != NULL)) { *method = descr; return 0; } type_name = __Pyx_PyType_GetName(tp); PyErr_Format(PyExc_AttributeError, #if PY_MAJOR_VERSION >= 3 "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", type_name, name); #else "'" __Pyx_FMT_TYPENAME "' object has no attribute '%.400s'", type_name, PyString_AS_STRING(name)); #endif __Pyx_DECREF_TypeName(type_name); return 0; #else attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; #endif try_unpack: #if CYTHON_UNPACK_METHODS if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { PyObject *function = PyMethod_GET_FUNCTION(attr); Py_INCREF(function); Py_DECREF(attr); *method = function; return 1; } #endif *method = attr; return 0; } /* PyObjectCallMethod1 */ #if !(CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2) static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); Py_DECREF(method); return result; } #endif static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { #if CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2 PyObject *args[2] = {obj, arg}; (void) __Pyx_PyObject_GetMethod; (void) __Pyx_PyObject_CallOneArg; (void) __Pyx_PyObject_Call2Args; return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #else PyObject *method = NULL, *result; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_Call2Args(method, obj, arg); Py_DECREF(method); return result; } if (unlikely(!method)) return NULL; return __Pyx__PyObject_CallMethod1(method, arg); #endif } /* append */ static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) { if (likely(PyList_CheckExact(L))) { if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1; } else { PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_n_s_append, x); if (unlikely(!retval)) return -1; Py_DECREF(retval); } return 0; } /* SliceObject */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, int has_cstart, int has_cstop, int wraparound) { __Pyx_TypeName obj_type_name; #if CYTHON_USE_TYPE_SLOTS PyMappingMethods* mp; #if PY_MAJOR_VERSION < 3 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; if (likely(ms && ms->sq_slice)) { if (!has_cstart) { if (_py_start && (*_py_start != Py_None)) { cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstart = 0; } if (!has_cstop) { if (_py_stop && (*_py_stop != Py_None)) { cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; } else cstop = PY_SSIZE_T_MAX; } if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { Py_ssize_t l = ms->sq_length(obj); if (likely(l >= 0)) { if (cstop < 0) { cstop += l; if (cstop < 0) cstop = 0; } if (cstart < 0) { cstart += l; if (cstart < 0) cstart = 0; } } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) goto bad; PyErr_Clear(); } } return ms->sq_slice(obj, cstart, cstop); } #else CYTHON_UNUSED_VAR(wraparound); #endif mp = Py_TYPE(obj)->tp_as_mapping; if (likely(mp && mp->mp_subscript)) #else CYTHON_UNUSED_VAR(wraparound); #endif { PyObject* result; PyObject *py_slice, *py_start, *py_stop; if (_py_slice) { py_slice = *_py_slice; } else { PyObject* owned_start = NULL; PyObject* owned_stop = NULL; if (_py_start) { py_start = *_py_start; } else { if (has_cstart) { owned_start = py_start = PyInt_FromSsize_t(cstart); if (unlikely(!py_start)) goto bad; } else py_start = Py_None; } if (_py_stop) { py_stop = *_py_stop; } else { if (has_cstop) { owned_stop = py_stop = PyInt_FromSsize_t(cstop); if (unlikely(!py_stop)) { Py_XDECREF(owned_start); goto bad; } } else py_stop = Py_None; } py_slice = PySlice_New(py_start, py_stop, Py_None); Py_XDECREF(owned_start); Py_XDECREF(owned_stop); if (unlikely(!py_slice)) goto bad; } #if CYTHON_USE_TYPE_SLOTS result = mp->mp_subscript(obj, py_slice); #else result = PyObject_GetItem(obj, py_slice); #endif if (!_py_slice) { Py_DECREF(py_slice); } return result; } obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "'" __Pyx_FMT_TYPENAME "' object is unsliceable", obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); bad: return NULL; } /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* IterFinish */ static CYTHON_INLINE int __Pyx_IterFinish(void) { PyObject* exc_type; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign exc_type = __Pyx_PyErr_CurrentExceptionType(); if (unlikely(exc_type)) { if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) return -1; __Pyx_PyErr_Clear(); return 0; } return 0; } /* UnpackItemEndCheck */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } return __Pyx_IterFinish(); } /* ObjectGetItem */ #if CYTHON_USE_TYPE_SLOTS static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) { PyObject *runerr = NULL; Py_ssize_t key_value; key_value = __Pyx_PyIndex_AsSsize_t(index); if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); } if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { __Pyx_TypeName index_type_name = __Pyx_PyType_GetName(Py_TYPE(index)); PyErr_Clear(); PyErr_Format(PyExc_IndexError, "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name); __Pyx_DECREF_TypeName(index_type_name); } return NULL; } static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) { __Pyx_TypeName obj_type_name; if (likely(PyType_Check(obj))) { PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, __pyx_n_s_class_getitem); if (!meth) { PyErr_Clear(); } else { PyObject *result = __Pyx_PyObject_CallOneArg(meth, key); Py_DECREF(meth); return result; } } obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); return NULL; } static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) { PyTypeObject *tp = Py_TYPE(obj); PyMappingMethods *mm = tp->tp_as_mapping; PySequenceMethods *sm = tp->tp_as_sequence; if (likely(mm && mm->mp_subscript)) { return mm->mp_subscript(obj, key); } if (likely(sm && sm->sq_item)) { return __Pyx_PyObject_GetIndex(obj, key); } return __Pyx_PyObject_GetItem_Slow(obj, key); } #endif /* CallUnboundCMethod0 */ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { PyObject *args, *result = NULL; if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_ASSUME_SAFE_MACROS args = PyTuple_New(1); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); #else args = PyTuple_Pack(1, self); if (unlikely(!args)) goto bad; #endif result = __Pyx_PyObject_Call(cfunc->method, args, NULL); Py_DECREF(args); bad: return result; } /* py_dict_items */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d); else return PyDict_Items(d); } /* GetAttr */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_USE_TYPE_SLOTS #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) #else if (likely(PyString_Check(n))) #endif return __Pyx_PyObject_GetAttrStr(o, n); #endif return PyObject_GetAttr(o, n); } /* HasAttr */ #if __PYX_LIMITED_VERSION_HEX < 0x030d00A1 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { PyObject *r; if (unlikely(!__Pyx_PyBaseString_Check(n))) { PyErr_SetString(PyExc_TypeError, "hasattr(): attribute name must be string"); return -1; } r = __Pyx_GetAttr(o, n); if (!r) { PyErr_Clear(); return 0; } else { Py_DECREF(r); return 1; } } #endif /* GetTopmostException */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate) { _PyErr_StackItem *exc_info = tstate->exc_info; while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) && exc_info->previous_item != NULL) { exc_info = exc_info->previous_item; } return exc_info; } #endif /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); PyObject *exc_value = exc_info->exc_value; if (exc_value == NULL || exc_value == Py_None) { *value = NULL; *type = NULL; *tb = NULL; } else { *value = exc_value; Py_INCREF(*value); *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); *tb = PyException_GetTraceback(exc_value); } #elif CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); *type = exc_info->exc_type; *value = exc_info->exc_value; *tb = exc_info->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #endif } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = tstate->exc_info; PyObject *tmp_value = exc_info->exc_value; exc_info->exc_value = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = type; exc_info->exc_value = value; exc_info->exc_traceback = tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } #endif /* GetException */ #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif { PyObject *local_type = NULL, *local_value, *local_tb = NULL; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; #if PY_VERSION_HEX >= 0x030C00A6 local_value = tstate->current_exception; tstate->current_exception = 0; if (likely(local_value)) { local_type = (PyObject*) Py_TYPE(local_value); Py_INCREF(local_type); local_tb = PyException_GetTraceback(local_value); } #else local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_FAST_THREAD_STATE && PY_VERSION_HEX >= 0x030C00A6 if (unlikely(tstate->current_exception)) #elif CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE #if CYTHON_USE_EXC_INFO_STACK { _PyErr_StackItem *exc_info = tstate->exc_info; #if PY_VERSION_HEX >= 0x030B00a4 tmp_value = exc_info->exc_value; exc_info->exc_value = local_value; tmp_type = NULL; tmp_tb = NULL; Py_XDECREF(local_type); Py_XDECREF(local_tb); #else tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = local_type; exc_info->exc_value = local_value; exc_info->exc_traceback = local_tb; #endif } #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } /* pyfrozenset_new */ static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) { if (it) { PyObject* result; #if CYTHON_COMPILING_IN_PYPY PyObject* args; args = PyTuple_Pack(1, it); if (unlikely(!args)) return NULL; result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL); Py_DECREF(args); return result; #else if (PyFrozenSet_CheckExact(it)) { Py_INCREF(it); return it; } result = PyFrozenSet_New(it); if (unlikely(!result)) return NULL; if ((PY_VERSION_HEX >= 0x031000A1) || likely(PySet_GET_SIZE(result))) return result; Py_DECREF(result); #endif } #if CYTHON_USE_TYPE_SLOTS return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL); #else return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL); #endif } /* PySetContains */ static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) { int result = -1; if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) { PyObject *tmpkey; PyErr_Clear(); tmpkey = __Pyx_PyFrozenSet_New(key); if (tmpkey != NULL) { result = PySet_Contains(set, tmpkey); Py_DECREF(tmpkey); } } return result; } static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) { int result = PySet_Contains(set, key); if (unlikely(result < 0)) { result = __Pyx_PySet_ContainsUnhashable(set, key); } return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* PyObjectCallNoArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { PyObject *arg[2] = {NULL, NULL}; return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* FixUpExtensionType */ #if CYTHON_USE_TYPE_SPECS static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) { #if PY_VERSION_HEX > 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED_VAR(spec); CYTHON_UNUSED_VAR(type); #else const PyType_Slot *slot = spec->slots; while (slot && slot->slot && slot->slot != Py_tp_members) slot++; if (slot && slot->slot == Py_tp_members) { int changed = 0; #if !(PY_VERSION_HEX <= 0x030900b1 && CYTHON_COMPILING_IN_CPYTHON) const #endif PyMemberDef *memb = (PyMemberDef*) slot->pfunc; while (memb && memb->name) { if (memb->name[0] == '_' && memb->name[1] == '_') { #if PY_VERSION_HEX < 0x030900b1 if (strcmp(memb->name, "__weaklistoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_weaklistoffset = memb->offset; changed = 1; } else if (strcmp(memb->name, "__dictoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_dictoffset = memb->offset; changed = 1; } #if CYTHON_METH_FASTCALL else if (strcmp(memb->name, "__vectorcalloffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); #if PY_VERSION_HEX >= 0x030800b4 type->tp_vectorcall_offset = memb->offset; #else type->tp_print = (printfunc) memb->offset; #endif changed = 1; } #endif #else if ((0)); #endif #if PY_VERSION_HEX <= 0x030900b1 && CYTHON_COMPILING_IN_CPYTHON else if (strcmp(memb->name, "__module__") == 0) { PyObject *descr; assert(memb->type == T_OBJECT); assert(memb->flags == 0 || memb->flags == READONLY); descr = PyDescr_NewMember(type, memb); if (unlikely(!descr)) return -1; if (unlikely(PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr) < 0)) { Py_DECREF(descr); return -1; } Py_DECREF(descr); changed = 1; } #endif } memb++; } if (changed) PyType_Modified(type); } #endif return 0; } #endif /* PyObjectCallMethod0 */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { PyObject *method = NULL, *result = NULL; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_CallOneArg(method, obj); Py_DECREF(method); return result; } if (unlikely(!method)) goto bad; result = __Pyx_PyObject_CallNoArg(method); Py_DECREF(method); bad: return result; } /* ValidateBasesTuple */ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) { Py_ssize_t i, n; #if CYTHON_ASSUME_SAFE_MACROS n = PyTuple_GET_SIZE(bases); #else n = PyTuple_Size(bases); if (n < 0) return -1; #endif for (i = 1; i < n; i++) { #if CYTHON_AVOID_BORROWED_REFS PyObject *b0 = PySequence_GetItem(bases, i); if (!b0) return -1; #elif CYTHON_ASSUME_SAFE_MACROS PyObject *b0 = PyTuple_GET_ITEM(bases, i); #else PyObject *b0 = PyTuple_GetItem(bases, i); if (!b0) return -1; #endif PyTypeObject *b; #if PY_MAJOR_VERSION < 3 if (PyClass_Check(b0)) { PyErr_Format(PyExc_TypeError, "base class '%.200s' is an old-style class", PyString_AS_STRING(((PyClassObject*)b0)->cl_name)); #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } #endif b = (PyTypeObject*) b0; if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE)) { __Pyx_TypeName b_name = __Pyx_PyType_GetName(b); PyErr_Format(PyExc_TypeError, "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name); __Pyx_DECREF_TypeName(b_name); #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } if (dictoffset == 0) { Py_ssize_t b_dictoffset = 0; #if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY b_dictoffset = b->tp_dictoffset; #else PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__"); if (!py_b_dictoffset) goto dictoffset_return; b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset); Py_DECREF(py_b_dictoffset); if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return; #endif if (b_dictoffset) { { __Pyx_TypeName b_name = __Pyx_PyType_GetName(b); PyErr_Format(PyExc_TypeError, "extension type '%.200s' has no __dict__ slot, " "but base type '" __Pyx_FMT_TYPENAME "' has: " "either add 'cdef dict __dict__' to the extension type " "or add '__slots__ = [...]' to the base type", type_name, b_name); __Pyx_DECREF_TypeName(b_name); } #if !(CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY) dictoffset_return: #endif #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif } return 0; } #endif /* PyType_Ready */ static int __Pyx_PyType_Ready(PyTypeObject *t) { #if CYTHON_USE_TYPE_SPECS || !(CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API) || defined(PYSTON_MAJOR_VERSION) (void)__Pyx_PyObject_CallMethod0; #if CYTHON_USE_TYPE_SPECS (void)__Pyx_validate_bases_tuple; #endif return PyType_Ready(t); #else int r; PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*); if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1)) return -1; #if PY_VERSION_HEX >= 0x03050000 && !defined(PYSTON_MAJOR_VERSION) { int gc_was_enabled; #if PY_VERSION_HEX >= 0x030A00b1 gc_was_enabled = PyGC_Disable(); (void)__Pyx_PyObject_CallMethod0; #else PyObject *ret, *py_status; PyObject *gc = NULL; #if PY_VERSION_HEX >= 0x030700a1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) gc = PyImport_GetModule(__pyx_kp_u_gc); #endif if (unlikely(!gc)) gc = PyImport_Import(__pyx_kp_u_gc); if (unlikely(!gc)) return -1; py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_isenabled); if (unlikely(!py_status)) { Py_DECREF(gc); return -1; } gc_was_enabled = __Pyx_PyObject_IsTrue(py_status); Py_DECREF(py_status); if (gc_was_enabled > 0) { ret = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_disable); if (unlikely(!ret)) { Py_DECREF(gc); return -1; } Py_DECREF(ret); } else if (unlikely(gc_was_enabled == -1)) { Py_DECREF(gc); return -1; } #endif t->tp_flags |= Py_TPFLAGS_HEAPTYPE; #if PY_VERSION_HEX >= 0x030A0000 t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE; #endif #else (void)__Pyx_PyObject_CallMethod0; #endif r = PyType_Ready(t); #if PY_VERSION_HEX >= 0x03050000 && !defined(PYSTON_MAJOR_VERSION) t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE; #if PY_VERSION_HEX >= 0x030A00b1 if (gc_was_enabled) PyGC_Enable(); #else if (gc_was_enabled) { PyObject *tp, *v, *tb; PyErr_Fetch(&tp, &v, &tb); ret = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_enable); if (likely(ret || r == -1)) { Py_XDECREF(ret); PyErr_Restore(tp, v, tb); } else { Py_XDECREF(tp); Py_XDECREF(v); Py_XDECREF(tb); r = -1; } } Py_DECREF(gc); #endif } #endif return r; #endif } /* PyObject_GenericGetAttrNoDict */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { __Pyx_TypeName type_name = __Pyx_PyType_GetName(tp); PyErr_Format(PyExc_AttributeError, #if PY_MAJOR_VERSION >= 3 "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", type_name, attr_name); #else "'" __Pyx_FMT_TYPENAME "' object has no attribute '%.400s'", type_name, PyString_AS_STRING(attr_name)); #endif __Pyx_DECREF_TypeName(type_name); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { PyObject *descr; PyTypeObject *tp = Py_TYPE(obj); if (unlikely(!PyString_Check(attr_name))) { return PyObject_GenericGetAttr(obj, attr_name); } assert(!tp->tp_dictoffset); descr = _PyType_Lookup(tp, attr_name); if (unlikely(!descr)) { return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); } Py_INCREF(descr); #if PY_MAJOR_VERSION < 3 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) #endif { descrgetfunc f = Py_TYPE(descr)->tp_descr_get; if (unlikely(f)) { PyObject *res = f(descr, obj, (PyObject *)tp); Py_DECREF(descr); return res; } } return descr; } #endif /* PyObject_GenericGetAttr */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) { if (unlikely(Py_TYPE(obj)->tp_dictoffset)) { return PyObject_GenericGetAttr(obj, attr_name); } return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name); } #endif /* SetupReduce */ #if !CYTHON_COMPILING_IN_LIMITED_API static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { int ret; PyObject *name_attr; name_attr = __Pyx_PyObject_GetAttrStrNoError(meth, __pyx_n_s_name_2); if (likely(name_attr)) { ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); } else { ret = -1; } if (unlikely(ret < 0)) { PyErr_Clear(); ret = 0; } Py_XDECREF(name_attr); return ret; } static int __Pyx_setup_reduce(PyObject* type_obj) { int ret = 0; PyObject *object_reduce = NULL; PyObject *object_getstate = NULL; PyObject *object_reduce_ex = NULL; PyObject *reduce = NULL; PyObject *reduce_ex = NULL; PyObject *reduce_cython = NULL; PyObject *setstate = NULL; PyObject *setstate_cython = NULL; PyObject *getstate = NULL; #if CYTHON_USE_PYTYPE_LOOKUP getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate); #else getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate); if (!getstate && PyErr_Occurred()) { goto __PYX_BAD; } #endif if (getstate) { #if CYTHON_USE_PYTYPE_LOOKUP object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate); #else object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate); if (!object_getstate && PyErr_Occurred()) { goto __PYX_BAD; } #endif if (object_getstate != getstate) { goto __PYX_GOOD; } } #if CYTHON_USE_PYTYPE_LOOKUP object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; #else object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; #endif reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD; if (reduce_ex == object_reduce_ex) { #if CYTHON_USE_PYTYPE_LOOKUP object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; #else object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; #endif reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD; if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython); if (likely(reduce_cython)) { ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; } else if (reduce == object_reduce || PyErr_Occurred()) { goto __PYX_BAD; } setstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate); if (!setstate) PyErr_Clear(); if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython); if (likely(setstate_cython)) { ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; } else if (!setstate || PyErr_Occurred()) { goto __PYX_BAD; } } PyType_Modified((PyTypeObject*)type_obj); } } goto __PYX_GOOD; __PYX_BAD: if (!PyErr_Occurred()) { __Pyx_TypeName type_obj_name = __Pyx_PyType_GetName((PyTypeObject*)type_obj); PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for " __Pyx_FMT_TYPENAME, type_obj_name); __Pyx_DECREF_TypeName(type_obj_name); } ret = -1; __PYX_GOOD: #if !CYTHON_USE_PYTYPE_LOOKUP Py_XDECREF(object_reduce); Py_XDECREF(object_reduce_ex); Py_XDECREF(object_getstate); Py_XDECREF(getstate); #endif Py_XDECREF(reduce); Py_XDECREF(reduce_ex); Py_XDECREF(reduce_cython); Py_XDECREF(setstate); Py_XDECREF(setstate_cython); return ret; } #endif /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType_3_0_9 #define __PYX_HAVE_RT_ImportType_3_0_9 static PyTypeObject *__Pyx_ImportType_3_0_9(PyObject *module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_9 check_size) { PyObject *result = 0; char warning[200]; Py_ssize_t basicsize; Py_ssize_t itemsize; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; PyObject *py_itemsize; #endif result = PyObject_GetAttrString(module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #if !CYTHON_COMPILING_IN_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; itemsize = ((PyTypeObject *)result)->tp_itemsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; py_itemsize = PyObject_GetAttrString(result, "__itemsize__"); if (!py_itemsize) goto bad; itemsize = PyLong_AsSsize_t(py_itemsize); Py_DECREF(py_itemsize); py_itemsize = 0; if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (itemsize) { if (size % alignment) { alignment = size % alignment; } if (itemsize < (Py_ssize_t)alignment) itemsize = (Py_ssize_t)alignment; } if ((size_t)(basicsize + itemsize) < size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize+itemsize); goto bad; } if (check_size == __Pyx_ImportType_CheckSize_Error_3_0_9 && ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd-%zd from PyObject", module_name, class_name, size, basicsize, basicsize+itemsize); goto bad; } else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_0_9 && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(result); return NULL; } #endif /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *module = 0; PyObject *empty_dict = 0; PyObject *empty_list = 0; #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (unlikely(!py_import)) goto bad; if (!from_list) { empty_list = PyList_New(0); if (unlikely(!empty_list)) goto bad; from_list = empty_list; } #endif empty_dict = PyDict_New(); if (unlikely(!empty_dict)) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.') != NULL) { module = PyImport_ImportModuleLevelObject( name, __pyx_d, empty_dict, from_list, 1); if (unlikely(!module)) { if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (unlikely(!py_level)) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, __pyx_d, empty_dict, from_list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, __pyx_d, empty_dict, from_list, level); #endif } } bad: Py_XDECREF(empty_dict); Py_XDECREF(empty_list); #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif return module; } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { const char* module_name_str = 0; PyObject* module_name = 0; PyObject* module_dot = 0; PyObject* full_name = 0; PyErr_Clear(); module_name_str = PyModule_GetName(module); if (unlikely(!module_name_str)) { goto modbad; } module_name = PyUnicode_FromString(module_name_str); if (unlikely(!module_name)) { goto modbad; } module_dot = PyUnicode_Concat(module_name, __pyx_kp_u__8); if (unlikely(!module_dot)) { goto modbad; } full_name = PyUnicode_Concat(module_dot, name); if (unlikely(!full_name)) { goto modbad; } #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) goto modbad; value = PyObject_GetItem(modules, full_name); } #else value = PyImport_GetModule(full_name); #endif modbad: Py_XDECREF(full_name); Py_XDECREF(module_dot); Py_XDECREF(module_name); } if (unlikely(!value)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } /* ImportDottedModule */ #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx__ImportDottedModule_Error(PyObject *name, PyObject *parts_tuple, Py_ssize_t count) { PyObject *partial_name = NULL, *slice = NULL, *sep = NULL; if (unlikely(PyErr_Occurred())) { PyErr_Clear(); } if (likely(PyTuple_GET_SIZE(parts_tuple) == count)) { partial_name = name; } else { slice = PySequence_GetSlice(parts_tuple, 0, count); if (unlikely(!slice)) goto bad; sep = PyUnicode_FromStringAndSize(".", 1); if (unlikely(!sep)) goto bad; partial_name = PyUnicode_Join(sep, slice); } PyErr_Format( #if PY_MAJOR_VERSION < 3 PyExc_ImportError, "No module named '%s'", PyString_AS_STRING(partial_name)); #else #if PY_VERSION_HEX >= 0x030600B1 PyExc_ModuleNotFoundError, #else PyExc_ImportError, #endif "No module named '%U'", partial_name); #endif bad: Py_XDECREF(sep); Py_XDECREF(slice); Py_XDECREF(partial_name); return NULL; } #endif #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx__ImportDottedModule_Lookup(PyObject *name) { PyObject *imported_module; #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) return NULL; imported_module = __Pyx_PyDict_GetItemStr(modules, name); Py_XINCREF(imported_module); #else imported_module = PyImport_GetModule(name); #endif return imported_module; } #endif #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple) { Py_ssize_t i, nparts; nparts = PyTuple_GET_SIZE(parts_tuple); for (i=1; i < nparts && module; i++) { PyObject *part, *submodule; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS part = PyTuple_GET_ITEM(parts_tuple, i); #else part = PySequence_ITEM(parts_tuple, i); #endif submodule = __Pyx_PyObject_GetAttrStrNoError(module, part); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(part); #endif Py_DECREF(module); module = submodule; } if (unlikely(!module)) { return __Pyx__ImportDottedModule_Error(name, parts_tuple, i); } return module; } #endif static PyObject *__Pyx__ImportDottedModule(PyObject *name, PyObject *parts_tuple) { #if PY_MAJOR_VERSION < 3 PyObject *module, *from_list, *star = __pyx_n_s__9; CYTHON_UNUSED_VAR(parts_tuple); from_list = PyList_New(1); if (unlikely(!from_list)) return NULL; Py_INCREF(star); PyList_SET_ITEM(from_list, 0, star); module = __Pyx_Import(name, from_list, 0); Py_DECREF(from_list); return module; #else PyObject *imported_module; PyObject *module = __Pyx_Import(name, NULL, 0); if (!parts_tuple || unlikely(!module)) return module; imported_module = __Pyx__ImportDottedModule_Lookup(name); if (likely(imported_module)) { Py_DECREF(module); return imported_module; } PyErr_Clear(); return __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple); #endif } static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030400B1 PyObject *module = __Pyx__ImportDottedModule_Lookup(name); if (likely(module)) { PyObject *spec = __Pyx_PyObject_GetAttrStrNoError(module, __pyx_n_s_spec); if (likely(spec)) { PyObject *unsafe = __Pyx_PyObject_GetAttrStrNoError(spec, __pyx_n_s_initializing); if (likely(!unsafe || !__Pyx_PyObject_IsTrue(unsafe))) { Py_DECREF(spec); spec = NULL; } Py_XDECREF(unsafe); } if (likely(!spec)) { PyErr_Clear(); return module; } Py_DECREF(spec); Py_DECREF(module); } else if (PyErr_Occurred()) { PyErr_Clear(); } #endif return __Pyx__ImportDottedModule(name, parts_tuple); } /* ImportDottedModuleRelFirst */ static PyObject *__Pyx_ImportDottedModuleRelFirst(PyObject *name, PyObject *parts_tuple) { PyObject *module; PyObject *from_list = NULL; #if PY_MAJOR_VERSION < 3 PyObject *star = __pyx_n_s__9; from_list = PyList_New(1); if (unlikely(!from_list)) return NULL; Py_INCREF(star); PyList_SET_ITEM(from_list, 0, star); #endif module = __Pyx_Import(name, from_list, -1); Py_XDECREF(from_list); if (module) { #if PY_MAJOR_VERSION >= 3 if (parts_tuple) { module = __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple); } #endif return module; } if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) return NULL; PyErr_Clear(); return __Pyx_ImportDottedModule(name, parts_tuple); } /* FetchSharedCythonModule */ static PyObject *__Pyx_FetchSharedCythonABIModule(void) { return __Pyx_PyImport_AddModuleRef((char*) __PYX_ABI_MODULE_NAME); } /* FetchCommonType */ static int __Pyx_VerifyCachedType(PyObject *cached_type, const char *name, Py_ssize_t basicsize, Py_ssize_t expected_basicsize) { if (!PyType_Check(cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", name); return -1; } if (basicsize != expected_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", name); return -1; } return 0; } #if !CYTHON_USE_TYPE_SPECS static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* abi_module; const char* object_name; PyTypeObject *cached_type = NULL; abi_module = __Pyx_FetchSharedCythonABIModule(); if (!abi_module) return NULL; object_name = strrchr(type->tp_name, '.'); object_name = object_name ? object_name+1 : type->tp_name; cached_type = (PyTypeObject*) PyObject_GetAttrString(abi_module, object_name); if (cached_type) { if (__Pyx_VerifyCachedType( (PyObject *)cached_type, object_name, cached_type->tp_basicsize, type->tp_basicsize) < 0) { goto bad; } goto done; } if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); if (PyType_Ready(type) < 0) goto bad; if (PyObject_SetAttrString(abi_module, object_name, (PyObject *)type) < 0) goto bad; Py_INCREF(type); cached_type = type; done: Py_DECREF(abi_module); return cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } #else static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *abi_module, *cached_type = NULL; const char* object_name = strrchr(spec->name, '.'); object_name = object_name ? object_name+1 : spec->name; abi_module = __Pyx_FetchSharedCythonABIModule(); if (!abi_module) return NULL; cached_type = PyObject_GetAttrString(abi_module, object_name); if (cached_type) { Py_ssize_t basicsize; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__"); if (unlikely(!py_basicsize)) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; #else basicsize = likely(PyType_Check(cached_type)) ? ((PyTypeObject*) cached_type)->tp_basicsize : -1; #endif if (__Pyx_VerifyCachedType( cached_type, object_name, basicsize, spec->basicsize) < 0) { goto bad; } goto done; } if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); CYTHON_UNUSED_VAR(module); cached_type = __Pyx_PyType_FromModuleAndSpec(abi_module, spec, bases); if (unlikely(!cached_type)) goto bad; if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad; if (PyObject_SetAttrString(abi_module, object_name, cached_type) < 0) goto bad; done: Py_DECREF(abi_module); assert(cached_type == NULL || PyType_Check(cached_type)); return (PyTypeObject *) cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } #endif /* PyVectorcallFastCallDict */ #if CYTHON_METH_FASTCALL static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { PyObject *res = NULL; PyObject *kwnames; PyObject **newargs; PyObject **kwvalues; Py_ssize_t i, pos; size_t j; PyObject *key, *value; unsigned long keys_are_strings; Py_ssize_t nkw = PyDict_GET_SIZE(kw); newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0])); if (unlikely(newargs == NULL)) { PyErr_NoMemory(); return NULL; } for (j = 0; j < nargs; j++) newargs[j] = args[j]; kwnames = PyTuple_New(nkw); if (unlikely(kwnames == NULL)) { PyMem_Free(newargs); return NULL; } kwvalues = newargs + nargs; pos = i = 0; keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS; while (PyDict_Next(kw, &pos, &key, &value)) { keys_are_strings &= Py_TYPE(key)->tp_flags; Py_INCREF(key); Py_INCREF(value); PyTuple_SET_ITEM(kwnames, i, key); kwvalues[i] = value; i++; } if (unlikely(!keys_are_strings)) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); goto cleanup; } res = vc(func, newargs, nargs, kwnames); cleanup: Py_DECREF(kwnames); for (i = 0; i < nkw; i++) Py_DECREF(kwvalues[i]); PyMem_Free(newargs); return res; } static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { if (likely(kw == NULL) || PyDict_GET_SIZE(kw) == 0) { return vc(func, args, nargs, NULL); } return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw); } #endif /* CythonFunctionShared */ #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) { if (__Pyx_CyFunction_Check(func)) { return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc; } else if (PyCFunction_Check(func)) { return PyCFunction_GetFunction(func) == (PyCFunction) cfunc; } return 0; } #else static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) { return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; } #endif static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API __Pyx_Py_XDECREF_SET( __Pyx_CyFunction_GetClassObj(f), ((classobj) ? __Pyx_NewRef(classobj) : NULL)); #else __Pyx_Py_XDECREF_SET( ((PyCMethodObject *) (f))->mm_class, (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL)); #endif } static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) { CYTHON_UNUSED_VAR(closure); if (unlikely(op->func_doc == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_doc = PyObject_GetAttrString(op->func, "__doc__"); if (unlikely(!op->func_doc)) return NULL; #else if (((PyCFunctionObject*)op)->m_ml->ml_doc) { #if PY_MAJOR_VERSION >= 3 op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); #else op->func_doc = PyString_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); #endif if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } #endif } Py_INCREF(op->func_doc); return op->func_doc; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (value == NULL) { value = Py_None; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->func_doc, value); return 0; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_name == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_name = PyObject_GetAttrString(op->func, "__name__"); #elif PY_MAJOR_VERSION >= 3 op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #else op->func_name = PyString_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->func_name, value); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); Py_INCREF(op->func_qualname); return op->func_qualname; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->func_qualname, value); return 0; } static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } static int __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL)) { PyErr_SetString(PyExc_TypeError, "function's dictionary may not be deleted"); return -1; } if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "setting function's dictionary to a non-dict"); return -1; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->func_dict, value); return 0; } static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(op); CYTHON_UNUSED_VAR(context); Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context) { PyObject* result = (op->func_code) ? op->func_code : Py_None; CYTHON_UNUSED_VAR(context); Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyTuple_Check(value))) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->defaults_tuple, value); return 0; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result = op->defaults_tuple; CYTHON_UNUSED_VAR(context); if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result = op->defaults_kwdict; CYTHON_UNUSED_VAR(context); if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value || value == Py_None) { value = NULL; } else if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); __Pyx_Py_XDECREF_SET(op->func_annotations, value); return 0; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) { PyObject* result = op->func_annotations; CYTHON_UNUSED_VAR(context); if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { int is_coroutine; CYTHON_UNUSED_VAR(context); if (op->func_is_coroutine) { return __Pyx_NewRef(op->func_is_coroutine); } is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE; #if PY_VERSION_HEX >= 0x03050000 if (is_coroutine) { PyObject *module, *fromlist, *marker = __pyx_n_s_is_coroutine; fromlist = PyList_New(1); if (unlikely(!fromlist)) return NULL; Py_INCREF(marker); #if CYTHON_ASSUME_SAFE_MACROS PyList_SET_ITEM(fromlist, 0, marker); #else if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) { Py_DECREF(marker); Py_DECREF(fromlist); return NULL; } #endif module = PyImport_ImportModuleLevelObject(__pyx_n_s_asyncio_coroutines, NULL, NULL, fromlist, 0); Py_DECREF(fromlist); if (unlikely(!module)) goto ignore; op->func_is_coroutine = __Pyx_PyObject_GetAttrStr(module, marker); Py_DECREF(module); if (likely(op->func_is_coroutine)) { return __Pyx_NewRef(op->func_is_coroutine); } ignore: PyErr_Clear(); } #endif op->func_is_coroutine = __Pyx_PyBool_FromLong(is_coroutine); return __Pyx_NewRef(op->func_is_coroutine); } #if CYTHON_COMPILING_IN_LIMITED_API static PyObject * __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_GetAttrString(op->func, "__module__"); } static int __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_SetAttrString(op->func, "__module__", value); } #endif static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {(char *) "_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0}, #endif {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { #if !CYTHON_COMPILING_IN_LIMITED_API {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0}, #endif #if CYTHON_USE_TYPE_SPECS {(char *) "__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0}, #if CYTHON_METH_FASTCALL #if CYTHON_BACKPORT_VECTORCALL {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0}, #else #if !CYTHON_COMPILING_IN_LIMITED_API {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0}, #endif #endif #endif #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0}, #else {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0}, #endif #endif {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args) { CYTHON_UNUSED_VAR(args); #if PY_MAJOR_VERSION >= 3 Py_INCREF(m->func_qualname); return m->func_qualname; #else return PyString_FromString(((PyCFunctionObject*)m)->m_ml->ml_name); #endif } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist) #endif static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { #if !CYTHON_COMPILING_IN_LIMITED_API PyCFunctionObject *cf = (PyCFunctionObject*) op; #endif if (unlikely(op == NULL)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API op->func = PyCFunction_NewEx(ml, (PyObject*)op, module); if (unlikely(!op->func)) return NULL; #endif op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; #if !CYTHON_COMPILING_IN_LIMITED_API cf->m_ml = ml; cf->m_self = (PyObject *) op; #endif Py_XINCREF(closure); op->func_closure = closure; #if !CYTHON_COMPILING_IN_LIMITED_API Py_XINCREF(module); cf->m_module = module; #endif op->func_dict = NULL; op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API op->func_classobj = NULL; #else ((PyCMethodObject*)op)->mm_class = NULL; #endif op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults_pyobjects = 0; op->defaults_size = 0; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; op->func_is_coroutine = NULL; #if CYTHON_METH_FASTCALL switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { case METH_NOARGS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS; break; case METH_O: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O; break; case METH_METHOD | METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD; break; case METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS; break; case METH_VARARGS | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = NULL; break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); Py_DECREF(op); return NULL; } #endif return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func); #else Py_CLEAR(((PyCFunctionObject*)m)->m_module); #endif Py_CLEAR(m->func_dict); Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x030900B1 Py_CLEAR(__Pyx_CyFunction_GetClassObj(m)); #else { PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class; ((PyCMethodObject *) (m))->mm_class = NULL; Py_XDECREF(cls); } #endif #endif Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); Py_CLEAR(m->func_is_coroutine); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_XDECREF(pydefaults[i]); PyObject_Free(m->defaults); m->defaults = NULL; } return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); __Pyx_PyHeapTypeObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func); #else Py_VISIT(((PyCFunctionObject*)m)->m_module); #endif Py_VISIT(m->func_dict); Py_VISIT(m->func_name); Py_VISIT(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); Py_VISIT(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(__Pyx_CyFunction_GetClassObj(m)); #endif Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); Py_VISIT(m->func_is_coroutine); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_VISIT(pydefaults[i]); } return 0; } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("", op->func_qualname, (void *)op); #else return PyString_FromFormat("", PyString_AsString(op->func_qualname), (void *)op); #endif } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *f = ((__pyx_CyFunctionObject*)func)->func; PyObject *py_name = NULL; PyCFunction meth; int flags; meth = PyCFunction_GetFunction(f); if (unlikely(!meth)) return NULL; flags = PyCFunction_GetFlags(f); if (unlikely(flags < 0)) return NULL; #else PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; int flags = f->m_ml->ml_flags; #endif Py_ssize_t size; switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_MACROS size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 0)) return (*meth)(self, NULL); #if CYTHON_COMPILING_IN_LIMITED_API py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); if (!py_name) return NULL; PyErr_Format(PyExc_TypeError, "%.200S() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", py_name, size); Py_DECREF(py_name); #else PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); #endif return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_MACROS size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } #if CYTHON_COMPILING_IN_LIMITED_API py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); if (!py_name) return NULL; PyErr_Format(PyExc_TypeError, "%.200S() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", py_name, size); Py_DECREF(py_name); #else PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); #endif return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); return NULL; } #if CYTHON_COMPILING_IN_LIMITED_API py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); if (!py_name) return NULL; PyErr_Format(PyExc_TypeError, "%.200S() takes no keyword arguments", py_name); Py_DECREF(py_name); #else PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); #endif return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *self, *result; #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)func)->m_self; #endif result = __Pyx_CyFunction_CallMethod(func, self, arg, kw); return result; } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; #if CYTHON_METH_FASTCALL __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc); if (vc) { #if CYTHON_ASSUME_SAFE_MACROS return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw); #else (void) &__Pyx_PyVectorcall_FastCallDict; return PyVectorcall_Call(func, args, kw); #endif } #endif if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; #if CYTHON_ASSUME_SAFE_MACROS argc = PyTuple_GET_SIZE(args); #else argc = PyTuple_Size(args); if (unlikely(!argc) < 0) return NULL; #endif new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); #if PY_MAJOR_VERSION > 2 PyErr_Format(PyExc_TypeError, "unbound method %.200S() needs an argument", cyfunc->func_qualname); #else PyErr_SetString(PyExc_TypeError, "unbound method needs an argument"); #endif return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } #if CYTHON_METH_FASTCALL static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames) { int ret = 0; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { if (unlikely(nargs < 1)) { PyErr_Format(PyExc_TypeError, "%.200s() needs an argument", ((PyCFunctionObject*)cyfunc)->m_ml->ml_name); return -1; } ret = 1; } if (unlikely(kwnames) && unlikely(PyTuple_GET_SIZE(kwnames))) { PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", ((PyCFunctionObject*)cyfunc)->m_ml->ml_name); return -1; } return ret; } static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; #if CYTHON_BACKPORT_VECTORCALL Py_ssize_t nargs = (Py_ssize_t)nargsf; #else Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); #endif PyObject *self; switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: self = ((PyCFunctionObject*)cyfunc)->m_self; break; default: return NULL; } if (unlikely(nargs != 0)) { PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", def->ml_name, nargs); return NULL; } return def->ml_meth(self, NULL); } static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; #if CYTHON_BACKPORT_VECTORCALL Py_ssize_t nargs = (Py_ssize_t)nargsf; #else Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); #endif PyObject *self; switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: self = ((PyCFunctionObject*)cyfunc)->m_self; break; default: return NULL; } if (unlikely(nargs != 1)) { PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", def->ml_name, nargs); return NULL; } return def->ml_meth(self, args[0]); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; #if CYTHON_BACKPORT_VECTORCALL Py_ssize_t nargs = (Py_ssize_t)nargsf; #else Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); #endif PyObject *self; switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: self = ((PyCFunctionObject*)cyfunc)->m_self; break; default: return NULL; } return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))def->ml_meth)(self, args, nargs, kwnames); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc); #if CYTHON_BACKPORT_VECTORCALL Py_ssize_t nargs = (Py_ssize_t)nargsf; #else Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); #endif PyObject *self; switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: self = ((PyCFunctionObject*)cyfunc)->m_self; break; default: return NULL; } return ((__Pyx_PyCMethod)(void(*)(void))def->ml_meth)(self, cls, args, (size_t)nargs, kwnames); } #endif #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_CyFunctionType_slots[] = { {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc}, {Py_tp_repr, (void *)__Pyx_CyFunction_repr}, {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod}, {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse}, {Py_tp_clear, (void *)__Pyx_CyFunction_clear}, {Py_tp_methods, (void *)__pyx_CyFunction_methods}, {Py_tp_members, (void *)__pyx_CyFunction_members}, {Py_tp_getset, (void *)__pyx_CyFunction_getsets}, {Py_tp_descr_get, (void *)__Pyx_PyMethod_New}, {0, 0}, }; static PyType_Spec __pyx_CyFunctionType_spec = { __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif #if (defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL) _Py_TPFLAGS_HAVE_VECTORCALL | #endif Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, __pyx_CyFunctionType_slots }; #else static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, (destructor) __Pyx_CyFunction_dealloc, #if !CYTHON_METH_FASTCALL 0, #elif CYTHON_BACKPORT_VECTORCALL (printfunc)offsetof(__pyx_CyFunctionObject, func_vectorcall), #else offsetof(PyCFunctionObject, vectorcall), #endif 0, 0, #if PY_MAJOR_VERSION < 3 0, #else 0, #endif (reprfunc) __Pyx_CyFunction_repr, 0, 0, 0, 0, __Pyx_CyFunction_CallAsMethod, 0, 0, 0, 0, #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif #if defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL _Py_TPFLAGS_HAVE_VECTORCALL | #endif Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, 0, (traverseproc) __Pyx_CyFunction_traverse, (inquiry) __Pyx_CyFunction_clear, 0, #if PY_VERSION_HEX < 0x030500A0 offsetof(__pyx_CyFunctionObject, func_weakreflist), #else offsetof(PyCFunctionObject, m_weakreflist), #endif 0, 0, __pyx_CyFunction_methods, __pyx_CyFunction_members, __pyx_CyFunction_getsets, 0, 0, __Pyx_PyMethod_New, 0, offsetof(__pyx_CyFunctionObject, func_dict), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if PY_VERSION_HEX >= 0x030400a1 0, #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, #endif #if __PYX_NEED_TP_PRINT_SLOT 0, #endif #if PY_VERSION_HEX >= 0x030C0000 0, #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, #endif }; #endif static int __pyx_CyFunction_init(PyObject *module) { #if CYTHON_USE_TYPE_SPECS __pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_CyFunctionType_spec, NULL); #else CYTHON_UNUSED_VAR(module); __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); #endif if (unlikely(__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_Malloc(size); if (unlikely(!m->defaults)) return PyErr_NoMemory(); memset(m->defaults, 0, size); m->defaults_pyobjects = pyobjects; m->defaults_size = size; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* CythonFunction */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { PyObject *op = __Pyx_CyFunction_Init( PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), ml, flags, qualname, closure, module, globals, code ); if (likely(op)) { PyObject_GC_Track(op); } return op; } /* CalculateMetaclass */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { Py_ssize_t i, nbases; #if CYTHON_ASSUME_SAFE_MACROS nbases = PyTuple_GET_SIZE(bases); #else nbases = PyTuple_Size(bases); if (nbases < 0) return NULL; #endif for (i=0; i < nbases; i++) { PyTypeObject *tmptype; #if CYTHON_ASSUME_SAFE_MACROS PyObject *tmp = PyTuple_GET_ITEM(bases, i); #else PyObject *tmp = PyTuple_GetItem(bases, i); if (!tmp) return NULL; #endif tmptype = Py_TYPE(tmp); #if PY_MAJOR_VERSION < 3 if (tmptype == &PyClass_Type) continue; #endif if (!metaclass) { metaclass = tmptype; continue; } if (PyType_IsSubtype(metaclass, tmptype)) continue; if (PyType_IsSubtype(tmptype, metaclass)) { metaclass = tmptype; continue; } PyErr_SetString(PyExc_TypeError, "metaclass conflict: " "the metaclass of a derived class " "must be a (non-strict) subclass " "of the metaclasses of all its bases"); return NULL; } if (!metaclass) { #if PY_MAJOR_VERSION < 3 metaclass = &PyClass_Type; #else metaclass = &PyType_Type; #endif } Py_INCREF((PyObject*) metaclass); return (PyObject*) metaclass; } /* PyObjectLookupSpecial */ #if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error) { PyObject *res; PyTypeObject *tp = Py_TYPE(obj); #if PY_MAJOR_VERSION < 3 if (unlikely(PyInstance_Check(obj))) return with_error ? __Pyx_PyObject_GetAttrStr(obj, attr_name) : __Pyx_PyObject_GetAttrStrNoError(obj, attr_name); #endif res = _PyType_Lookup(tp, attr_name); if (likely(res)) { descrgetfunc f = Py_TYPE(res)->tp_descr_get; if (!f) { Py_INCREF(res); } else { res = f(res, obj, (PyObject *)tp); } } else if (with_error) { PyErr_SetObject(PyExc_AttributeError, attr_name); } return res; } #endif /* Py3ClassCreate */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *ns; if (metaclass) { PyObject *prep = __Pyx_PyObject_GetAttrStrNoError(metaclass, __pyx_n_s_prepare); if (prep) { PyObject *pargs[3] = {NULL, name, bases}; ns = __Pyx_PyObject_FastCallDict(prep, pargs+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, mkw); Py_DECREF(prep); } else { if (unlikely(PyErr_Occurred())) return NULL; ns = PyDict_New(); } } else { ns = PyDict_New(); } if (unlikely(!ns)) return NULL; if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad; #if PY_VERSION_HEX >= 0x03030000 if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad; #else CYTHON_MAYBE_UNUSED_VAR(qualname); #endif if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad; return ns; bad: Py_DECREF(ns); return NULL; } #if PY_VERSION_HEX < 0x030600A4 && CYTHON_PEP487_INIT_SUBCLASS static int __Pyx_SetNamesPEP487(PyObject *type_obj) { PyTypeObject *type = (PyTypeObject*) type_obj; PyObject *names_to_set, *key, *value, *set_name, *tmp; Py_ssize_t i = 0; #if CYTHON_USE_TYPE_SLOTS names_to_set = PyDict_Copy(type->tp_dict); #else { PyObject *d = PyObject_GetAttr(type_obj, __pyx_n_s_dict_2); names_to_set = NULL; if (likely(d)) { PyObject *names_to_set = PyDict_New(); int ret = likely(names_to_set) ? PyDict_Update(names_to_set, d) : -1; Py_DECREF(d); if (unlikely(ret < 0)) Py_CLEAR(names_to_set); } } #endif if (unlikely(names_to_set == NULL)) goto bad; while (PyDict_Next(names_to_set, &i, &key, &value)) { set_name = __Pyx_PyObject_LookupSpecialNoError(value, __pyx_n_s_set_name); if (unlikely(set_name != NULL)) { tmp = __Pyx_PyObject_Call2Args(set_name, type_obj, key); Py_DECREF(set_name); if (unlikely(tmp == NULL)) { __Pyx_TypeName value_type_name = __Pyx_PyType_GetName(Py_TYPE(value)); __Pyx_TypeName type_name = __Pyx_PyType_GetName(type); PyErr_Format(PyExc_RuntimeError, #if PY_MAJOR_VERSION >= 3 "Error calling __set_name__ on '" __Pyx_FMT_TYPENAME "' instance %R " "in '" __Pyx_FMT_TYPENAME "'", value_type_name, key, type_name); #else "Error calling __set_name__ on '" __Pyx_FMT_TYPENAME "' instance %.100s in '" __Pyx_FMT_TYPENAME "'", value_type_name, PyString_Check(key) ? PyString_AS_STRING(key) : "?", type_name); #endif goto bad; } else { Py_DECREF(tmp); } } else if (unlikely(PyErr_Occurred())) { goto bad; } } Py_DECREF(names_to_set); return 0; bad: Py_XDECREF(names_to_set); return -1; } static PyObject *__Pyx_InitSubclassPEP487(PyObject *type_obj, PyObject *mkw) { #if CYTHON_USE_TYPE_SLOTS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS PyTypeObject *type = (PyTypeObject*) type_obj; PyObject *mro = type->tp_mro; Py_ssize_t i, nbases; if (unlikely(!mro)) goto done; (void) &__Pyx_GetBuiltinName; Py_INCREF(mro); nbases = PyTuple_GET_SIZE(mro); assert(PyTuple_GET_ITEM(mro, 0) == type_obj); for (i = 1; i < nbases-1; i++) { PyObject *base, *dict, *meth; base = PyTuple_GET_ITEM(mro, i); dict = ((PyTypeObject *)base)->tp_dict; meth = __Pyx_PyDict_GetItemStrWithError(dict, __pyx_n_s_init_subclass); if (unlikely(meth)) { descrgetfunc f = Py_TYPE(meth)->tp_descr_get; PyObject *res; Py_INCREF(meth); if (likely(f)) { res = f(meth, NULL, type_obj); Py_DECREF(meth); if (unlikely(!res)) goto bad; meth = res; } res = __Pyx_PyObject_FastCallDict(meth, NULL, 0, mkw); Py_DECREF(meth); if (unlikely(!res)) goto bad; Py_DECREF(res); goto done; } else if (unlikely(PyErr_Occurred())) { goto bad; } } done: Py_XDECREF(mro); return type_obj; bad: Py_XDECREF(mro); Py_DECREF(type_obj); return NULL; #else PyObject *super_type, *super, *func, *res; #if CYTHON_COMPILING_IN_PYPY && !defined(PySuper_Type) super_type = __Pyx_GetBuiltinName(__pyx_n_s_super); #else super_type = (PyObject*) &PySuper_Type; (void) &__Pyx_GetBuiltinName; #endif super = likely(super_type) ? __Pyx_PyObject_Call2Args(super_type, type_obj, type_obj) : NULL; #if CYTHON_COMPILING_IN_PYPY && !defined(PySuper_Type) Py_XDECREF(super_type); #endif if (unlikely(!super)) { Py_CLEAR(type_obj); goto done; } func = __Pyx_PyObject_GetAttrStrNoError(super, __pyx_n_s_init_subclass); Py_DECREF(super); if (likely(!func)) { if (unlikely(PyErr_Occurred())) Py_CLEAR(type_obj); goto done; } res = __Pyx_PyObject_FastCallDict(func, NULL, 0, mkw); Py_DECREF(func); if (unlikely(!res)) Py_CLEAR(type_obj); Py_XDECREF(res); done: return type_obj; #endif } #endif static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass) { PyObject *result; PyObject *owned_metaclass = NULL; PyObject *margs[4] = {NULL, name, bases, dict}; if (allow_py2_metaclass) { owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass); if (owned_metaclass) { metaclass = owned_metaclass; } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) { PyErr_Clear(); } else { return NULL; } } if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) { metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases); Py_XDECREF(owned_metaclass); if (unlikely(!metaclass)) return NULL; owned_metaclass = metaclass; } result = __Pyx_PyObject_FastCallDict(metaclass, margs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, #if PY_VERSION_HEX < 0x030600A4 (metaclass == (PyObject*)&PyType_Type) ? NULL : mkw #else mkw #endif ); Py_XDECREF(owned_metaclass); #if PY_VERSION_HEX < 0x030600A4 && CYTHON_PEP487_INIT_SUBCLASS if (likely(result) && likely(PyType_Check(result))) { if (unlikely(__Pyx_SetNamesPEP487(result) < 0)) { Py_CLEAR(result); } else { result = __Pyx_InitSubclassPEP487(result, mkw); } } #else (void) &__Pyx_GetBuiltinName; #endif return result; } /* Py3UpdateBases */ static PyObject* __Pyx_PEP560_update_bases(PyObject *bases) { Py_ssize_t i, j, size_bases; PyObject *base, *meth, *new_base, *result, *new_bases = NULL; size_bases = PyTuple_GET_SIZE(bases); for (i = 0; i < size_bases; i++) { base = PyTuple_GET_ITEM(bases, i); if (PyType_Check(base)) { if (new_bases) { if (PyList_Append(new_bases, base) < 0) { goto error; } } continue; } meth = __Pyx_PyObject_GetAttrStrNoError(base, __pyx_n_s_mro_entries); if (!meth && PyErr_Occurred()) { goto error; } if (!meth) { if (new_bases) { if (PyList_Append(new_bases, base) < 0) { goto error; } } continue; } new_base = __Pyx_PyObject_CallOneArg(meth, bases); Py_DECREF(meth); if (!new_base) { goto error; } if (!PyTuple_Check(new_base)) { PyErr_SetString(PyExc_TypeError, "__mro_entries__ must return a tuple"); Py_DECREF(new_base); goto error; } if (!new_bases) { if (!(new_bases = PyList_New(i))) { goto error; } for (j = 0; j < i; j++) { base = PyTuple_GET_ITEM(bases, j); PyList_SET_ITEM(new_bases, j, base); Py_INCREF(base); } } j = PyList_GET_SIZE(new_bases); if (PyList_SetSlice(new_bases, j, j, new_base) < 0) { goto error; } Py_DECREF(new_base); } if (!new_bases) { Py_INCREF(bases); return bases; } result = PyList_AsTuple(new_bases); Py_DECREF(new_bases); return result; error: Py_XDECREF(new_bases); return NULL; } /* CLineInTraceback */ #ifndef CYTHON_CLINE_IN_TRACEBACK static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline; PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif CYTHON_MAYBE_UNUSED_VAR(tstate); if (unlikely(!__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, *cython_runtime_dict, __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) } else #endif { PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStrNoError(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { PyErr_Clear(); use_cline = NULL; } } if (!use_cline) { c_line = 0; (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ #if !CYTHON_COMPILING_IN_LIMITED_API static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #endif /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, PyObject *firstlineno, PyObject *name) { PyObject *replace = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; replace = PyObject_GetAttrString(code, "replace"); if (likely(replace)) { PyObject *result; result = PyObject_Call(replace, __pyx_empty_tuple, scratch_dict); Py_DECREF(replace); return result; } PyErr_Clear(); #if __PYX_LIMITED_VERSION_HEX < 0x030780000 { PyObject *compiled = NULL, *result = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "code", code))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "type", (PyObject*)(&PyType_Type)))) return NULL; compiled = Py_CompileString( "out = type(code)(\n" " code.co_argcount, code.co_kwonlyargcount, code.co_nlocals, code.co_stacksize,\n" " code.co_flags, code.co_code, code.co_consts, code.co_names,\n" " code.co_varnames, code.co_filename, co_name, co_firstlineno,\n" " code.co_lnotab)\n", "", Py_file_input); if (!compiled) return NULL; result = PyEval_EvalCode(compiled, scratch_dict, scratch_dict); Py_DECREF(compiled); if (!result) PyErr_Print(); Py_DECREF(result); result = PyDict_GetItemString(scratch_dict, "out"); if (result) Py_INCREF(result); return result; } #else return NULL; #endif } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; PyObject *replace = NULL, *getframe = NULL, *frame = NULL; PyObject *exc_type, *exc_value, *exc_traceback; int success = 0; if (c_line) { (void) __pyx_cfilenm; (void) __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); } PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); code_object = Py_CompileString("_getframe()", filename, Py_eval_input); if (unlikely(!code_object)) goto bad; py_py_line = PyLong_FromLong(py_line); if (unlikely(!py_py_line)) goto bad; py_funcname = PyUnicode_FromString(funcname); if (unlikely(!py_funcname)) goto bad; dict = PyDict_New(); if (unlikely(!dict)) goto bad; { PyObject *old_code_object = code_object; code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); Py_DECREF(old_code_object); } if (unlikely(!code_object)) goto bad; getframe = PySys_GetObject("_getframe"); if (unlikely(!getframe)) goto bad; if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; frame = PyEval_EvalCode(code_object, dict, dict); if (unlikely(!frame) || frame == Py_None) goto bad; success = 1; bad: PyErr_Restore(exc_type, exc_value, exc_traceback); Py_XDECREF(code_object); Py_XDECREF(py_py_line); Py_XDECREF(py_funcname); Py_XDECREF(dict); Py_XDECREF(replace); if (success) { PyTraceBack_Here( (struct _frame*)frame); } Py_XDECREF(frame); } #else static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = NULL; PyObject *py_funcname = NULL; #if PY_MAJOR_VERSION < 3 PyObject *py_srcfile = NULL; py_srcfile = PyString_FromString(filename); if (!py_srcfile) goto bad; #endif if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; funcname = PyUnicode_AsUTF8(py_funcname); if (!funcname) goto bad; #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); if (!py_funcname) goto bad; #endif } #if PY_MAJOR_VERSION < 3 py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); #else py_code = PyCode_NewEmpty(filename, funcname, py_line); #endif Py_XDECREF(py_funcname); return py_code; bad: Py_XDECREF(py_funcname); #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_srcfile); #endif return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) { /* If the code object creation fails, then we should clear the fetched exception references and propagate the new exception */ Py_XDECREF(ptype); Py_XDECREF(pvalue); Py_XDECREF(ptraceback); goto bad; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #endif /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_readstat_type_t(readstat_type_t value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const readstat_type_t neg_one = (readstat_type_t) -1, const_zero = (readstat_type_t) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(readstat_type_t) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(readstat_type_t) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(readstat_type_t) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(readstat_type_t) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(readstat_type_t) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(readstat_type_t), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(readstat_type_t)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntFromPy */ static CYTHON_INLINE readstat_type_t __Pyx_PyInt_As_readstat_type_t(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const readstat_type_t neg_one = (readstat_type_t) -1, const_zero = (readstat_type_t) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(readstat_type_t) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(readstat_type_t, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (readstat_type_t) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(readstat_type_t) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) >= 2 * PyLong_SHIFT)) { return (readstat_type_t) (((((readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0])); } } break; case 3: if ((8 * sizeof(readstat_type_t) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) >= 3 * PyLong_SHIFT)) { return (readstat_type_t) (((((((readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0])); } } break; case 4: if ((8 * sizeof(readstat_type_t) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) >= 4 * PyLong_SHIFT)) { return (readstat_type_t) (((((((((readstat_type_t)digits[3]) << PyLong_SHIFT) | (readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (readstat_type_t) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(readstat_type_t) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(readstat_type_t, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(readstat_type_t) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(readstat_type_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(readstat_type_t) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 2 * PyLong_SHIFT)) { return (readstat_type_t) (((readstat_type_t)-1)*(((((readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case 2: if ((8 * sizeof(readstat_type_t) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 2 * PyLong_SHIFT)) { return (readstat_type_t) ((((((readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case -3: if ((8 * sizeof(readstat_type_t) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 3 * PyLong_SHIFT)) { return (readstat_type_t) (((readstat_type_t)-1)*(((((((readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case 3: if ((8 * sizeof(readstat_type_t) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 3 * PyLong_SHIFT)) { return (readstat_type_t) ((((((((readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case -4: if ((8 * sizeof(readstat_type_t) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 4 * PyLong_SHIFT)) { return (readstat_type_t) (((readstat_type_t)-1)*(((((((((readstat_type_t)digits[3]) << PyLong_SHIFT) | (readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case 4: if ((8 * sizeof(readstat_type_t) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 4 * PyLong_SHIFT)) { return (readstat_type_t) ((((((((((readstat_type_t)digits[3]) << PyLong_SHIFT) | (readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; } } #endif if ((sizeof(readstat_type_t) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(readstat_type_t, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(readstat_type_t) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(readstat_type_t, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available, cannot convert large enums"); return (readstat_type_t) -1; } else { readstat_type_t val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (readstat_type_t) -1; val = __Pyx_PyInt_As_readstat_type_t(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to readstat_type_t"); return (readstat_type_t) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to readstat_type_t"); return (readstat_type_t) -1; } /* CIntFromPy */ static CYTHON_INLINE __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format neg_one = (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) -1, const_zero = (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) >= 2 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) (((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0])); } } break; case 3: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) >= 3 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) (((((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0])); } } break; case 4: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) >= 4 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) (((((((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[3]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 2 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) (((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)-1)*(((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0]))); } } break; case 2: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 2 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) ((((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0]))); } } break; case -3: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 3 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) (((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)-1)*(((((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0]))); } } break; case 3: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 3 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) ((((((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0]))); } } break; case -4: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 4 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) (((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)-1)*(((((((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[3]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0]))); } } break; case 4: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) - 1 > 4 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) ((((((((((__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[3]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)digits[0]))); } } break; } } #endif if ((sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available, cannot convert large enums"); return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) -1; } else { __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) -1; val = __Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format"); return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format"); return (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) -1; } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_char(char value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const char neg_one = (char) -1, const_zero = (char) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(char) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(char) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(char) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(char), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(char)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format neg_one = (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) -1, const_zero = (__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(__pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(long) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(long) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } } #endif if ((sizeof(long) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int ret = -1; #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; long idigit; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (unlikely(!PyLong_CheckExact(v))) { PyObject *tmp = v; v = PyNumber_Long(v); assert(PyLong_CheckExact(v)); Py_DECREF(tmp); if (unlikely(!v)) return (long) -1; } #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(x) == 0) return (long) 0; is_negative = Py_SIZE(x) < 0; #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; is_negative = result == 1; } #endif if (is_unsigned && unlikely(is_negative)) { goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); if (unlikely(!stepval)) return (long) -1; } else { stepval = __Pyx_NewRef(v); } val = (long) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; val |= ((long) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(stepval) == 0) goto unpacking_done; #endif } idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((long) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 unpacking_done: #endif if (!is_unsigned) { if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif Py_DECREF(v); if (likely(!ret)) return val; } return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(int) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(int) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } } #endif if ((sizeof(int) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int ret = -1; #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; long idigit; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (unlikely(!PyLong_CheckExact(v))) { PyObject *tmp = v; v = PyNumber_Long(v); assert(PyLong_CheckExact(v)); Py_DECREF(tmp); if (unlikely(!v)) return (int) -1; } #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(x) == 0) return (int) 0; is_negative = Py_SIZE(x) < 0; #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; is_negative = result == 1; } #endif if (is_unsigned && unlikely(is_negative)) { goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); if (unlikely(!stepval)) return (int) -1; } else { stepval = __Pyx_NewRef(v); } val = (int) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; val |= ((int) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(stepval) == 0) goto unpacking_done; #endif } idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((int) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 unpacking_done: #endif if (!is_unsigned) { if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif Py_DECREF(v); if (likely(!ret)) return val; } return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* FormatTypeName */ #if CYTHON_COMPILING_IN_LIMITED_API static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp) { PyObject *name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_n_s_name_2); if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) { PyErr_Clear(); Py_XDECREF(name); name = __Pyx_NewRef(__pyx_n_s__15); } return name; } #endif /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (cls == a || cls == b) return 1; mro = cls->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { PyObject *base = PyTuple_GET_ITEM(mro, i); if (base == (PyObject *)a || base == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); } #if PY_MAJOR_VERSION == 2 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { PyObject *exception, *value, *tb; int res; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&exception, &value, &tb); res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } if (!res) { res = PyObject_IsSubclass(err, exc_type2); if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } } __Pyx_ErrRestore(exception, value, tb); return res; } #else static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { if (exc_type1) { return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); } else { return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } } #endif static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i= 0x030B00A4 return Py_Version & ~0xFFUL; #else const char* rt_version = Py_GetVersion(); unsigned long version = 0; unsigned long factor = 0x01000000UL; unsigned int digit = 0; int i = 0; while (factor) { while ('0' <= rt_version[i] && rt_version[i] <= '9') { digit = digit * 10 + (unsigned int) (rt_version[i] - '0'); ++i; } version += factor * digit; if (rt_version[i] != '.') break; digit = 0; factor >>= 8; ++i; } return version; #endif } static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { const unsigned long MAJOR_MINOR = 0xFFFF0000UL; if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) return 0; if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) return 1; { char message[200]; PyOS_snprintf(message, sizeof(message), "compile time Python version %d.%d " "of module '%.100s' " "%s " "runtime version %d.%d", (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), __Pyx_MODULE_NAME, (allow_newer) ? "was newer than" : "does not match", (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) ); return PyErr_WarnEx(NULL, message, 1); } } /* VoidPtrExport */ static int __Pyx_ExportVoidPtr(PyObject *name, void *p, const char *sig) { PyObject *d; PyObject *cobj = 0; d = PyDict_GetItem(__pyx_d, __pyx_n_s_pyx_capi); Py_XINCREF(d); if (!d) { d = PyDict_New(); if (!d) goto bad; if (__Pyx_PyObject_SetAttrStr(__pyx_m, __pyx_n_s_pyx_capi, d) < 0) goto bad; } cobj = PyCapsule_New(p, sig, 0); if (!cobj) goto bad; if (PyDict_SetItem(d, name, cobj) < 0) goto bad; Py_DECREF(cobj); Py_DECREF(d); return 0; bad: Py_XDECREF(cobj); Py_XDECREF(d); return -1; } /* FunctionExport */ static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { void (*fp)(void); void *p; } tmp; d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__"); if (!d) { PyErr_Clear(); d = PyDict_New(); if (!d) goto bad; Py_INCREF(d); if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0) goto bad; } tmp.fp = f; cobj = PyCapsule_New(tmp.p, sig, 0); if (!cobj) goto bad; if (PyDict_SetItemString(d, name, cobj) < 0) goto bad; Py_DECREF(cobj); Py_DECREF(d); return 0; bad: Py_XDECREF(cobj); Py_XDECREF(d); return -1; } /* InitStrings */ #if PY_MAJOR_VERSION >= 3 static int __Pyx_InitString(__Pyx_StringTabEntry t, PyObject **str) { if (t.is_unicode | t.is_str) { if (t.intern) { *str = PyUnicode_InternFromString(t.s); } else if (t.encoding) { *str = PyUnicode_Decode(t.s, t.n - 1, t.encoding, NULL); } else { *str = PyUnicode_FromStringAndSize(t.s, t.n - 1); } } else { *str = PyBytes_FromStringAndSize(t.s, t.n - 1); } if (!*str) return -1; if (PyObject_Hash(*str) == -1) return -1; return 0; } #endif static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION >= 3 __Pyx_InitString(*t, t->p); #else if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) return -1; #endif ++t; } return 0; } #include static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { size_t len = strlen(s); if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "byte string is too long"); return -1; } return (Py_ssize_t) len; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return __Pyx_PyUnicode_FromStringAndSize(c_str, len); } static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return PyByteArray_FromStringAndSize(c_str, len); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #if !CYTHON_PEP393_ENABLED static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; } #else static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif } #endif #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_LIMITED_API) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { __Pyx_TypeName result_type_name = __Pyx_PyType_GetName(Py_TYPE(result)); #if PY_MAJOR_VERSION >= 3 if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " "The ability to return an instance of a strict subclass of int is deprecated, " "and may be removed in a future version of Python.", result_type_name)) { __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } __Pyx_DECREF_TypeName(result_type_name); return result; } #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type " __Pyx_FMT_TYPENAME ")", type_name, type_name, result_type_name); __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x) || PyLong_Check(x))) #else if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; res = m->nb_long(x); } #else if (likely(m && m->nb_int)) { name = "int"; res = m->nb_int(x); } #endif #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Int(x); } #endif if (likely(res)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else if (unlikely(!PyLong_CheckExact(res))) { #endif return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(b); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS if (likely(__Pyx_PyLong_IsCompact(b))) { return __Pyx_PyLong_CompactValue(b); } else { const digit* digits = __Pyx_PyLong_Digits(b); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); #if PY_MAJOR_VERSION < 3 } else if (likely(PyInt_CheckExact(o))) { return PyInt_AS_LONG(o); #endif } else { Py_ssize_t ival; PyObject *x; x = PyNumber_Index(o); if (!x) return -1; ival = PyInt_AsLong(x); Py_DECREF(x); return ival; } } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } /* #### Code section: utility_code_pragmas_end ### */ #ifdef _MSC_VER #pragma warning( pop ) #endif /* #### Code section: end ### */ #endif /* Py_PYTHON_H */ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/pyreadstat/_readstat_parser.pxd0000644023477200000240000001332114574360757022044 0ustar00fajardoostaffs# cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# from libc.stddef cimport wchar_t from readstat_api cimport * # Definitions of enum types ctypedef enum py_file_extension: FILE_EXT_SAV FILE_EXT_SAS7BDAT FILE_EXT_DTA FILE_EXT_XPORT FILE_EXT_POR FILE_EXT_SAS7BCAT ctypedef enum py_file_format: FILE_FORMAT_SAS FILE_FORMAT_SPSS FILE_FORMAT_STATA ctypedef enum py_datetime_format: DATE_FORMAT_NOTADATE DATE_FORMAT_DATE DATE_FORMAT_DATETIME DATE_FORMAT_TIME ctypedef enum py_variable_format: VAR_FORMAT_STRING VAR_FORMAT_LONG VAR_FORMAT_FLOAT VAR_FORMAT_MISSING # Definitions of extension types cdef class data_container: """ This extension type holds all the data we need to get from our file from the readstat parser and will be used later to compose our pandas data frame """ cdef int n_obs cdef int n_vars cdef int max_n_obs cdef list col_data cdef list col_data_len cdef list col_names cdef list col_labels cdef list col_dtypes cdef list col_numpy_dtypes cdef list col_dtypes_isobject cdef list col_dytpes_isfloat cdef list col_formats cdef list col_formats_original cdef object origin cdef py_file_format file_format cdef bint is_unkown_number_rows cdef str file_label cdef str file_encoding cdef bint metaonly cdef bint dates_as_pandas cdef object label_to_var_name cdef object labels_raw cdef object notes cdef str user_encoding cdef str table_name cdef bint filter_cols cdef list use_cols cdef bint usernan cdef dict missing_ranges cdef dict missing_user_values cdef dict variable_storage_width cdef variable_display_width cdef variable_alignment cdef variable_measure cdef bint no_datetime_conversion cdef int ctime cdef int mtime cdef dict readstat_to_numpy_types # definitions of functions cdef py_datetime_format transform_variable_format(str var_format, py_file_format file_format) cdef object transform_datetime(py_datetime_format var_format, double tstamp, py_file_format file_format, object origin, bint dates_as_pandas) cdef int handle_metadata(readstat_metadata_t *metadata, void *ctx) except READSTAT_HANDLER_ABORT cdef int handle_variable(int index, readstat_variable_t *variable, char *val_labels, void *ctx) except READSTAT_HANDLER_ABORT cdef int handle_value(int obs_index, readstat_variable_t * variable, readstat_value_t value, void *ctx) except READSTAT_HANDLER_ABORT cdef int handle_value_label(char *val_labels, readstat_value_t value, char *label, void *ctx) except READSTAT_HANDLER_ABORT cdef int handle_note (int note_index, char *note, void *ctx) except READSTAT_HANDLER_ABORT cdef void check_exit_status(readstat_error_t retcode) except * cdef void run_readstat_parser(char * filename, data_container data, py_file_extension file_extension, long row_limit, long row_offset) except * cdef object data_container_to_dict(data_container data) cdef object dict_to_pandas_dataframe(object final_container, data_container data) cdef object data_container_extract_metadata(data_container data) cdef object run_conversion(object filename_path, py_file_format file_format, py_file_extension file_extension, str encoding, bint metaonly, bint dates_as_pandas, list usecols, bint usernan, bint no_datetime_conversion, long row_limit, long row_offset, str output_format, list extra_datetime_formats, list extra_date_formats) # definitions for stuff about dates cdef list sas_date_formats cdef list sas_datetime_formats cdef list sas_time_formats cdef list sas_all_formats cdef object sas_origin cdef list spss_datetime_formats cdef list spss_date_formats cdef list spss_time_formats cdef list spss_all_formats cdef object spss_origin cdef list stata_datetime_formats cdef list stata_date_formats cdef list stata_time_formats cdef list stata_all_formats cdef object stata_origin # Stuff for opening files on windows in order to handle international characters # Courtesy of Jonathon Love # works only in python 3 #cdef extern from "readstat_io_unistd.h": # cdef struct unistd_io_ctx_t "unistd_io_ctx_s": # int fd cdef extern from "Python.h": wchar_t* PyUnicode_AsWideCharString(object, Py_ssize_t *) except NULL # these ones would make the c file produced by cython not portable between windows and unix # therefore the conditional including of the libraries is handled in C cdef extern from "conditional_includes.h": int _wsopen(const wchar_t *filename, int oflag, int shflag, int pmode) int _O_RDONLY int _O_BINARY int _O_WRONLY int _O_CREAT int _SH_DENYRW # Denies read and write access to a file. int _SH_DENYWR # Denies write access to a file. int _SH_DENYRD # Denies read access to a file. int _SH_DENYNO void assign_fd(void *io_ctx, int fd) long seek_fd(readstat_off_t offset, readstat_io_flags_t whence, void *io_ctx) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/pyreadstat/_readstat_parser.pyx0000644023477200000240000012440014574360757022072 0ustar00fajardoostaffs# cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# from cpython.datetime cimport import_datetime, timedelta_new, datetime_new from cpython.exc cimport PyErr_Occurred from cpython.object cimport PyObject from libc.math cimport NAN, floor #from datetime import timedelta, datetime from collections import OrderedDict import datetime import os import warnings import sys import pandas as pd import numpy as np #from pandas._libs import Timestamp from readstat_api cimport * # necessary to work with the datetime C API import_datetime() cdef list sas_date_formats = ["WEEKDATE", "MMDDYY", "DDMMYY", "YYMMDD", "DATE", "DATE9", "YYMMDD10", "DDMMYYB", "DDMMYYB10", "DDMMYYC", "DDMMYYC10", "DDMMYYD", "DDMMYYD10", "DDMMYYN6", "DDMMYYN8", "DDMMYYP", "DDMMYYP10", "DDMMYYS", "DDMMYYS10", "MMDDYYB", "MMDDYYB10", "MMDDYYC", "MMDDYYC10", "MMDDYYD", "MMDDYYD10", "MMDDYYN6", "MMDDYYN8", "MMDDYYP", "MMDDYYP10", "MMDDYYS", "MMDDYYS10", #"MONNAME", "MONTH", "WEEKDAY", "QTR", "QTRR", "YEAR","DAY", "DOWNAME" # these do not print as full dates in sas "WEEKDATX", "DTDATE", "IS8601DA", "E8601DA", "B8601DA", "YYMMDDB", "YYMMDDD", "YYMMDDN", "YYMMDDP", "YYMMDDS",] cdef list sas_datetime_formats = ["DATETIME", "DATETIME18", "DATETIME19", "DATETIME20", "DATETIME21", "DATETIME22", "E8601DT", "DATEAMPM", "MDYAMPM", "IS8601DT", "B8601DT", "B8601DN"] cdef list sas_time_formats = ["TIME", "HHMM", "TIME20.3", "TIME20", "TIME5", "TOD", "TIMEAMPM", "IS8601TM", "E8601TM", "B8601TM", ] # "HOUR" # these do not print as full time formats in sas #cdef list sas_all_formats = sas_date_formats + sas_datetime_formats + sas_time_formats cdef list sas_all_formats cdef object sas_origin = datetime_new(1960, 1, 1, 0, 0, 0, 0, None) cdef list spss_datetime_formats = ["DATETIME", "DATETIME8", 'DATETIME17', 'DATETIME20', 'DATETIME23.2',"YMDHMS16","YMDHMS19","YMDHMS19.2", "YMDHMS20"] cdef list spss_date_formats = ["DATE",'DATE8','DATE11', 'DATE12', "ADATE","ADATE8", "ADATE10", "EDATE", 'EDATE8','EDATE10', "JDATE", "JDATE5", "JDATE7", "SDATE", "SDATE8", "SDATE10",] cdef list spss_time_formats = ["TIME", "DTIME", 'TIME8', 'TIME5', 'TIME11.2'] #cdef list spss_all_formats = spss_date_formats + spss_datetime_formats + spss_time_formats cdef list spss_all_formats cdef object spss_origin = datetime_new(1582, 10, 14, 0, 0, 0, 0, None) cdef list stata_datetime_formats = ["%tC", "%tc"] cdef list stata_date_formats = ["%td", "%d", "%tdD_m_Y", "%tdCCYY-NN-DD"] cdef list stata_time_formats = ["%tcHH:MM:SS", "%tcHH:MM"] #cdef list stata_all_formats = stata_datetime_formats + stata_date_formats + stata_time_formats cdef list stata_all_formats cdef object stata_origin = datetime_new(1960, 1, 1, 0, 0, 0, 0, None) cdef dict readstat_to_numpy_types = {READSTAT_TYPE_STRING: object, READSTAT_TYPE_STRING_REF: object, READSTAT_TYPE_INT8: np.int64, READSTAT_TYPE_INT16: np.int64, READSTAT_TYPE_INT32:np.int64, READSTAT_TYPE_FLOAT: np.float64, READSTAT_TYPE_DOUBLE: np.float64} cdef class data_container: """ This extension type holds all the data we need to get from our file from the readstat parser and will be used later to compose our pandas data frame """ def __cinit__(self): self.n_obs = 0 self.n_vars = 0 self.max_n_obs = 0 self.col_data = list() self.col_data_len = list() self.col_names = list() self.col_labels = list() self.col_dtypes = list() self.col_numpy_dtypes = list() self.col_dtypes_isobject = list() self.col_dytpes_isfloat = list() self.col_formats = list() self.col_formats_original = list() self.origin = None self.is_unkown_number_rows = 0 self.file_encoding = None self.file_label = None self.metaonly = 0 self.dates_as_pandas = 0 self.label_to_var_name = dict() self.labels_raw = dict() self.notes = list() self.user_encoding = None self.table_name = None self.filter_cols = 0 self.use_cols = list() self.usernan = 0 self.missing_ranges = dict() self.missing_user_values = dict() self.variable_storage_width = dict() self.variable_display_width = dict() self.variable_alignment = dict() self.variable_measure = dict() self.no_datetime_conversion = 0 self.ctime = 0 self.mtime = 0 class metadata_container: """ This class holds metadata we want to give back to python """ def __init__(self): self.column_names = list() self.column_labels = list() self.column_names_to_labels = dict() self.file_encoding = None self.number_columns = None self.number_rows = None self.variable_value_labels = dict() self.value_labels = dict() self.variable_to_label = dict() self.notes = list() self.original_variable_types = dict() self.readstat_variable_types = dict() self.table_name = None self.missing_ranges = dict() self.missing_user_values = dict() self.variable_storage_width = dict() self.variable_display_width = dict() self.variable_alignment = dict() self.variable_measure = dict() self.creation_time = None self.modification_time = None class ReadstatError(Exception): """ Just defining a custom exception to raise when readstat gives an error return code. """ pass class PyreadstatError(Exception): """ Just defining a custom exception to raise when pyreadstat raises an exception. """ pass cdef py_datetime_format transform_variable_format(str var_format, py_file_format file_format): """ Transforms a readstat var_format to a date, datetime or time format label """ if file_format == FILE_FORMAT_SAS: if var_format in sas_all_formats: if var_format in sas_date_formats: return DATE_FORMAT_DATE elif var_format in sas_datetime_formats: return DATE_FORMAT_DATETIME elif var_format in sas_time_formats: return DATE_FORMAT_TIME else: return DATE_FORMAT_NOTADATE elif file_format == FILE_FORMAT_SPSS: if var_format in spss_all_formats: if var_format in spss_date_formats: return DATE_FORMAT_DATE elif var_format in spss_datetime_formats: return DATE_FORMAT_DATETIME elif var_format in spss_time_formats: return DATE_FORMAT_TIME else: return DATE_FORMAT_NOTADATE elif file_format == FILE_FORMAT_STATA: if var_format in stata_all_formats: if var_format in stata_date_formats: return DATE_FORMAT_DATE elif var_format in stata_datetime_formats: return DATE_FORMAT_DATETIME elif var_format in stata_time_formats: return DATE_FORMAT_TIME else: return DATE_FORMAT_NOTADATE cdef object transform_datetime(py_datetime_format var_format, double tstamp, py_file_format file_format, object origin, bint dates_as_pandas): """ Transforms a tstamp integer value to a date, time or datetime pyton object. tstamp could represent number of days, seconds or milliseconds """ cdef object tdelta cdef int days cdef int secs cdef double msecs cdef int usecs cdef object mydat if var_format == DATE_FORMAT_DATE: if file_format == FILE_FORMAT_SPSS: # tstamp is in seconds days = (floor(tstamp / 86400)) secs = (tstamp % 86400) tdelta = timedelta_new(days, secs, 0) #tdelta = timedelta(seconds=tstamp) else: # tstamp is in days days = tstamp tdelta = timedelta_new(days, 0, 0) #tdelta = timedelta(days=tstamp) mydat = origin + tdelta if dates_as_pandas: return mydat else: return mydat.date() elif var_format == DATE_FORMAT_DATETIME: if file_format == FILE_FORMAT_STATA: # tstamp is in millisecons days = (floor(tstamp / 86400000)) msecs = tstamp % 86400000 secs = (msecs/1000) usecs = ((msecs % 1000) * 1000 ) tdelta = timedelta_new(days, secs, usecs) #tdelta = timedelta(milliseconds=tstamp) else: # tstamp in seconds days = (floor(tstamp / 86400)) secs = (tstamp % 86400) tdelta = timedelta_new(days, secs, 0) #tdelta = timedelta(seconds=tstamp) mydat = origin + tdelta return mydat elif var_format == DATE_FORMAT_TIME: if file_format == FILE_FORMAT_STATA: # tstamp is in millisecons days = (floor(tstamp / 86400000)) msecs = tstamp % 86400000 secs = (msecs/1000) usecs = ((msecs % 1000) * 1000 ) tdelta = timedelta_new(days, secs, usecs) #tdelta = timedelta(milliseconds=tstamp) else: # tstamp in seconds days = (floor(tstamp / 86400)) secs = (tstamp % 86400) tdelta = timedelta_new(days, secs, 0) #tdelta = timedelta(seconds=tstamp) mydat = origin + tdelta return mydat.time() cdef object convert_readstat_to_python_value(readstat_value_t value, int index, data_container dc): """ Converts a readstat value to a python value. """ #py_file_format file_format, py_datetime_format var_format cdef readstat_type_t var_type cdef py_datetime_format var_format cdef py_variable_format pyformat cdef object origin cdef bint dates_as_pandas cdef py_file_format file_format cdef object result cdef char * c_str_value cdef str py_str_value cdef int8_t c_int8_value cdef int16_t c_int16_value cdef int32_t c_int32_value cdef int64_t c_int64_value cdef float c_float_value cdef double c_double_value cdef long py_long_value cdef double py_float_value cdef double tstamp var_type = dc.col_dtypes[index] var_format = dc.col_formats[index] origin = dc.origin dates_as_pandas = dc.dates_as_pandas file_format = dc.file_format # transform to values cython can deal with if var_type == READSTAT_TYPE_STRING or var_type == READSTAT_TYPE_STRING_REF: c_str_value = readstat_string_value(value) if c_str_value != NULL: py_str_value = c_str_value else: py_str_value = '' pyformat = VAR_FORMAT_STRING elif var_type == READSTAT_TYPE_INT8: c_int8_value = readstat_int8_value(value) py_long_value = c_int8_value pyformat = VAR_FORMAT_LONG elif var_type == READSTAT_TYPE_INT16: c_int16_value = readstat_int16_value(value) py_long_value = c_int16_value pyformat = VAR_FORMAT_LONG elif var_type == READSTAT_TYPE_INT32: c_int32_value = readstat_int32_value(value) py_long_value = c_int32_value pyformat = VAR_FORMAT_LONG elif var_type == READSTAT_TYPE_FLOAT: c_float_value = readstat_float_value(value) py_float_value = c_float_value pyformat = VAR_FORMAT_FLOAT elif var_type == READSTAT_TYPE_DOUBLE: c_double_value = readstat_double_value(value); py_float_value = c_double_value pyformat = VAR_FORMAT_FLOAT else: raise PyreadstatError("Unkown data type") # final transformation and storage if pyformat == VAR_FORMAT_STRING: if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: result = py_str_value else: #str_byte_val = py_str_value.encode("UTF-8") raise PyreadstatError("STRING type with value '%s' with date type in column '%s'" % (py_str_value, dc.col_names[index])) elif pyformat == VAR_FORMAT_LONG: if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: result = py_long_value else: tstamp = py_long_value result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) elif pyformat == VAR_FORMAT_FLOAT: if var_format == DATE_FORMAT_NOTADATE or dc.no_datetime_conversion: result = py_float_value else: #tstamp = py_float_value tstamp = py_float_value result = transform_datetime(var_format, tstamp, file_format, origin, dates_as_pandas) #elif pyformat == VAR_FORMAT_MISSING: # pass else: raise PyreadstatError("Failed convert C to python value") return result cdef int handle_metadata(readstat_metadata_t *metadata, void *ctx) except READSTAT_HANDLER_ABORT: """ This function sets the number of observations(rows), number of variables (columns) in data container and initializes the col_data which will store all the data we need. It also reads other metadata from the file. """ cdef int var_count, obs_count cdef data_container dc = ctx #cdef object row cdef char * flabel_orig cdef char * fencoding_orig cdef str flabel, fencoding cdef bint metaonly cdef char * table cdef int ctime cdef int mtime metaonly = dc.metaonly var_count = readstat_get_var_count(metadata) if var_count<0: raise PyreadstatError("Failed to read number of variables") obs_count = readstat_get_row_count(metadata) if obs_count <0: # if <0 it means the number of rows is not known, allocate 100 000 obs_count = 100000 dc.is_unkown_number_rows = 1 dc.n_obs = obs_count dc.n_vars = var_count dc.col_data_len = [obs_count] * var_count dc.col_numpy_dtypes = [None] * var_count dc.col_dytpes_isfloat = [0] * var_count dc.col_dtypes_isobject = [0] * var_count # read other metadata flabel_orig = readstat_get_file_label(metadata); fencoding_orig = readstat_get_file_encoding(metadata) if flabel_orig != NULL and flabel_orig[0]: flabel = flabel_orig else: flabel = None if fencoding_orig != NULL and fencoding_orig[0]: fencoding = fencoding_orig else: fencoding = None dc.file_encoding = fencoding dc.file_label = flabel table = readstat_get_table_name(metadata) if table != NULL and table[0]: dc.table_name = table dc.ctime = readstat_get_creation_time(metadata) dc.mtime = readstat_get_modified_time(metadata) return READSTAT_HANDLER_OK cdef int handle_variable(int index, readstat_variable_t *variable, char *val_labels, void *ctx) except READSTAT_HANDLER_ABORT: """ This function extracts the name, label, type and format from a variable and stores it in data container for a later access. It also extracts the label set to which the variable is associated, if any. """ cdef char * var_name, cdef char * var_label cdef char * var_format cdef str col_name, col_label, label_name, col_format_original cdef py_datetime_format col_format_final cdef readstat_type_t var_type cdef py_file_format file_format cdef readstat_label_set_t * lset cdef int n_ranges cdef readstat_value_t loval, hival cdef object pyloval, pyhival cdef list missing_ranges cdef object curnptype cdef object row cdef bint metaonly cdef int obs_count cdef bint iscurnptypefloat cdef bint iscurnptypeobject cdef str newcolname cdef int dupcolcnt cdef data_container dc = ctx # get variable name, label, format and type and put into our data container var_name = readstat_variable_get_name(variable) if var_name == NULL: col_name = None else: col_name = var_name # if the user introduced a list of columns to include, continue only if the column is in the list if dc.filter_cols and not (col_name in dc.use_cols): dc.n_vars -= 1 return READSTAT_HANDLER_SKIP_VARIABLE index = readstat_variable_get_index_after_skipping(variable) if col_name in dc.col_names: dupcolcnt = 1 while True: newcolname = col_name + "_duplicated" + str(dupcolcnt) if newcolname in col_name: dupcolcnt += 1 continue else: msg = "column '{0}' is duplicated, renamed to '{1}'".format(col_name, newcolname) warnings.warn(msg) col_name = newcolname break dc.col_names.append(col_name) # the name of the value label for the variable if val_labels != NULL: label_name = val_labels if label_name: dc.label_to_var_name[col_name] = label_name var_label = readstat_variable_get_label(variable) if var_label == NULL: col_label = None else: col_label = var_label dc.col_labels.append(col_label) # format, we have to transform it in something more usable var_format = readstat_variable_get_format(variable) if var_format == NULL: col_format_original = "NULL" else: col_format_original = var_format file_format = dc.file_format dc.col_formats_original.append(col_format_original) col_format_final = transform_variable_format(col_format_original, file_format) dc.col_formats.append(col_format_final) # readstat type var_type = readstat_variable_get_type(variable) dc.col_dtypes.append(var_type) # equivalent numpy type # if it's a date then we need object if col_format_final != DATE_FORMAT_NOTADATE and dc.no_datetime_conversion == 0: curnptype = object else: curnptype = readstat_to_numpy_types[var_type] iscurnptypefloat = 0 iscurnptypeobject = 0 # book keeping numpy types dc.col_numpy_dtypes[index] = curnptype if curnptype == object: iscurnptypeobject = 1 if curnptype == np.float64: iscurnptypefloat = 1 dc.col_dtypes_isobject[index] = iscurnptypeobject dc.col_dytpes_isfloat[index] = iscurnptypefloat metaonly = dc.metaonly # pre-allocate data if metaonly: row = np.empty(1, dtype=curnptype) else: obs_count = dc.n_obs row = np.empty(obs_count, dtype=curnptype) if iscurnptypeobject or iscurnptypefloat: row.fill(np.nan) dc.col_data.append(row) # missing values if dc.usernan: n_ranges = readstat_variable_get_missing_ranges_count(variable) if n_ranges>0: missing_ranges = list() for i in range(0, n_ranges): loval = readstat_variable_get_missing_range_lo(variable, i) pyloval = convert_readstat_to_python_value(loval, index, dc) hival = readstat_variable_get_missing_range_hi(variable, i) pyhival = convert_readstat_to_python_value(hival, index, dc) missing_ranges.append({'lo':pyloval, 'hi':pyhival}) dc.missing_ranges[col_name] = missing_ranges cdef size_t storage_width storage_width = readstat_variable_get_storage_width(variable) dc.variable_storage_width[col_name] = storage_width dc.variable_display_width[col_name] = readstat_variable_get_display_width(variable) cdef readstat_alignment_t align cdef str pyalign align = readstat_variable_get_alignment(variable) if align == READSTAT_ALIGNMENT_UNKNOWN: pyalign = "unknown" elif align == READSTAT_ALIGNMENT_LEFT: pyalign = "left" elif align == READSTAT_ALIGNMENT_CENTER: pyalign = "center" elif align == READSTAT_ALIGNMENT_RIGHT: pyalign = "right" else: pyalign = "undetermined" dc.variable_alignment[col_name] = pyalign cdef readstat_measure_t measure cdef str pymeasure measure = readstat_variable_get_measure(variable) if measure == READSTAT_MEASURE_UNKNOWN: pymeasure = "unknown" elif measure == READSTAT_MEASURE_NOMINAL: pymeasure = "nominal" elif measure == READSTAT_MEASURE_ORDINAL: pymeasure = "ordinal" elif measure == READSTAT_MEASURE_SCALE: pymeasure = "scale" else: pymeasure = "undetermined" dc.variable_measure[col_name] = pymeasure return READSTAT_HANDLER_OK cdef int handle_value(int obs_index, readstat_variable_t * variable, readstat_value_t value, void *ctx) except READSTAT_HANDLER_ABORT: """ This function transforms every value to python types, and to datetime if necessary and stores it into the arrays in data container col_data """ cdef data_container dc cdef int index cdef int max_n_obs cdef bint is_unkown_number_rows cdef int var_max_rows cdef object buf_list cdef bint iscurnptypeobject cdef bint iscurnptypefloat cdef int missing_tag cdef object pyvalue cdef set curset cdef object curnptype # extract variables we need from data container dc = ctx index = readstat_variable_get_index_after_skipping(variable) max_n_obs = dc.max_n_obs is_unkown_number_rows = dc.is_unkown_number_rows # check that we still have enough room in our pre-allocated lists # if not, add more room iscurnptypeobject = dc.col_dtypes_isobject[index] iscurnptypefloat = dc.col_dytpes_isfloat[index] if is_unkown_number_rows: if max_n_obs <= obs_index: dc.max_n_obs = obs_index + 1 var_max_rows = dc.col_data_len[index] if var_max_rows <= obs_index: curnptype = dc.col_numpy_dtypes[index] buf_list = np.empty(100000, dtype=curnptype) if iscurnptypeobject or iscurnptypefloat: buf_list.fill(np.nan) dc.col_data[index] = np.append(dc.col_data[index], buf_list) var_max_rows += 100000 dc.col_data_len[index] = var_max_rows # transform to python value types if readstat_value_is_missing(value, variable): # The user does not want to retrieve missing values if not dc.usernan or readstat_value_is_system_missing(value): if iscurnptypefloat == 1 or iscurnptypeobject == 1: # already allocated pass #dc.col_data[index][obs_index] = np.nan # for any type except float, the numpy type will be object as now we have nans else: dc.col_numpy_dtypes[index] = object dc.col_dtypes_isobject[index] = 1 iscurnptypeobject = 1 dc.col_data[index] = dc.col_data[index].astype(object, copy=False) dc.col_data[index][obs_index:] = np.nan #dc.col_data[index][obs_index] = NAN elif readstat_value_is_defined_missing(value, variable): # SPSS missing values pyvalue = convert_readstat_to_python_value(value, index, dc) dc.col_data[index][obs_index] = pyvalue elif readstat_value_is_tagged_missing(value): iscurnptypeobject = dc.col_dtypes_isobject[index] # SAS and Stata missing values missing_tag = readstat_value_tag(value) # In SAS missing values are A to Z or _ in stata a to z # if (missing_tag >=65 and missing_tag <= 90) or missing_tag == 95 or (missing_tag >=61 and missing_tag <= 122): if iscurnptypeobject == 1: dc.col_data[index][obs_index] = chr(missing_tag) else: dc.col_numpy_dtypes[index] = object dc.col_dtypes_isobject[index] = 1 dc.col_dytpes_isfloat[index] = 0 iscurnptypeobject = 1 dc.col_data[index] = dc.col_data[index].astype(object, copy=False) dc.col_data[index][obs_index] = chr(missing_tag) curset = dc.missing_user_values.get(index) if curset is None: curset = set() curset.add(chr(missing_tag)) dc.missing_user_values[index] = curset else: pyvalue = convert_readstat_to_python_value(value, index, dc) dc.col_data[index][obs_index] = pyvalue return READSTAT_HANDLER_OK cdef int handle_value_label(char *val_labels, readstat_value_t value, char *label, void *ctx) except READSTAT_HANDLER_ABORT: """ Reads the label for the value that belongs to the label set val_labels. In Handle variable we need to do a map from variable name to val_label so that later we can match both things. """ cdef data_container dc = ctx cdef char * c_str_value cdef str py_str_value cdef int8_t c_int8_value cdef int16_t c_int16_value cdef int32_t c_int32_value cdef int64_t c_int64_value cdef float c_float_value cdef double c_double_value cdef long py_long_value cdef double py_float_value cdef py_variable_format pyformat cdef object labels_raw cdef str var_label cdef object cur_dir cdef str value_label_name var_label = val_labels value_label_name = label cdef readstat_type_t value_type value_type = readstat_value_type(value) labels_raw = dc.labels_raw cur_dict = labels_raw.get(var_label) if not cur_dict: cur_dict = dict() if readstat_value_is_tagged_missing(value): # SAS and Stata missing values missing_tag = readstat_value_tag(value) # In SAS missing values are A to Z or _ in stata a to z cur_dict[chr(missing_tag)] = value_label_name else: if value_type == READSTAT_TYPE_STRING or value_type == READSTAT_TYPE_STRING_REF: c_str_value = readstat_string_value(value) py_str_value = c_str_value pyformat = VAR_FORMAT_STRING elif value_type == READSTAT_TYPE_INT8: c_int8_value = readstat_int8_value(value) py_long_value = c_int8_value pyformat = VAR_FORMAT_LONG elif value_type == READSTAT_TYPE_INT16: c_int16_value = readstat_int16_value(value) py_long_value = c_int16_value pyformat = VAR_FORMAT_LONG elif value_type == READSTAT_TYPE_INT32: c_int32_value = readstat_int32_value(value) py_long_value = c_int32_value pyformat = VAR_FORMAT_LONG elif value_type == READSTAT_TYPE_FLOAT: c_float_value = readstat_float_value(value) py_float_value = c_float_value pyformat = VAR_FORMAT_FLOAT elif value_type == READSTAT_TYPE_DOUBLE: c_double_value = readstat_double_value(value); py_float_value = c_double_value pyformat = VAR_FORMAT_FLOAT else: raise PyreadstatError("Unkown data type") if pyformat == VAR_FORMAT_STRING: cur_dict[py_str_value] = value_label_name elif pyformat == VAR_FORMAT_LONG: cur_dict[py_long_value] = value_label_name elif pyformat == VAR_FORMAT_FLOAT: cur_dict[py_float_value] = value_label_name elif pyformat == VAR_FORMAT_MISSING: pass else: raise PyreadstatError("Failed convert C to python value") dc.labels_raw[var_label] = cur_dict return READSTAT_HANDLER_OK cdef int handle_note (int note_index, char *note, void *ctx) except READSTAT_HANDLER_ABORT: """ Collects notes (text annotations) attached to the documents. It happens for spss and stata """ cdef str pynote cdef data_container dc = ctx pynote = note dc.notes.append(pynote) return READSTAT_HANDLER_OK cdef int handle_open(const char *u8_path, void *io_ctx) except READSTAT_HANDLER_ABORT: """ Special open handler for windows in order to be able to handle paths with international characters Courtesy of Jonathon Love. """ cdef int fd cdef Py_ssize_t length if not os.path.isfile(u8_path): return -1 if os.name == "nt": u16_path = PyUnicode_AsWideCharString(u8_path, &length) fd = _wsopen(u16_path, _O_RDONLY | _O_BINARY, _SH_DENYWR, 0) assign_fd(io_ctx, fd) return fd else: return -1 cdef void check_exit_status(readstat_error_t retcode) except *: """ transforms a readstat exit status to a python error if status is not READSTAT OK """ cdef char * err_readstat cdef str err_message if retcode != READSTAT_OK: err_readstat = readstat_error_message(retcode) err_message = err_readstat raise ReadstatError(err_message) cdef void run_readstat_parser(char * filename, data_container data, py_file_extension file_extension, long row_limit, long row_offset) except *: """ Runs the parsing of the file by readstat library """ cdef readstat_parser_t *parser cdef readstat_error_t error cdef readstat_metadata_handler metadata_handler cdef readstat_variable_handler variable_handler cdef readstat_value_handler value_handler cdef readstat_value_label_handler value_label_handler cdef readstat_note_handler note_handler cdef void *ctx cdef str err_message cdef PyObject *pyerr cdef bint metaonly cdef char *err_readstat cdef bytes encoding_byte metaonly = data.metaonly ctx = data #readstat_error_t error = READSTAT_OK; parser = readstat_parser_init() metadata_handler = handle_metadata variable_handler = handle_variable value_handler = handle_value value_label_handler = handle_value_label note_handler = handle_note check_exit_status(readstat_set_metadata_handler(parser, metadata_handler)) check_exit_status(readstat_set_variable_handler(parser, variable_handler)) check_exit_status(readstat_set_value_label_handler(parser, value_label_handler)) check_exit_status(readstat_set_note_handler(parser, note_handler)) # on windows we need a custom open handler in order to deal with internation characters in the path. if os.name == "nt": open_handler = handle_open readstat_set_open_handler(parser, open_handler) if not metaonly: check_exit_status(readstat_set_value_handler(parser, value_handler)) # if the user set the encoding manually if data.user_encoding: encoding_bytes = data.user_encoding.encode("utf-8") readstat_set_file_character_encoding(parser, encoding_bytes) if row_limit: check_exit_status(readstat_set_row_limit(parser, row_limit)) if row_offset: check_exit_status(readstat_set_row_offset(parser, row_offset)) # parse! if file_extension == FILE_EXT_SAV: error = readstat_parse_sav(parser, filename, ctx); elif file_extension == FILE_EXT_SAS7BDAT: error = readstat_parse_sas7bdat(parser, filename, ctx); elif file_extension == FILE_EXT_DTA: error = readstat_parse_dta(parser, filename, ctx); elif file_extension == FILE_EXT_XPORT: error = readstat_parse_xport(parser, filename, ctx); elif file_extension == FILE_EXT_POR: error = readstat_parse_por(parser, filename, ctx); elif file_extension == FILE_EXT_SAS7BCAT: error = readstat_parse_sas7bcat(parser, filename, ctx); #error = parse_func(parser, filename, ctx); readstat_parser_free(parser) # check if a python error ocurred, if yes, it will be printed by the interpreter, # if not, make sure that the return from parse_func is OK, if not print pyerr = PyErr_Occurred() if pyerr == NULL: check_exit_status(error) cdef object data_container_to_dict(data_container data): """ Transforms a data container object to a pandas data frame """ cdef object final_container cdef list col_data cdef list col_names cdef str cur_name_str cdef int fc_cnt cdef bint is_unkown_number_rows cdef int max_n_obs cdef bint metaonly final_container = OrderedDict() col_data = data.col_data col_names = data.col_names is_unkown_number_rows = data.is_unkown_number_rows max_n_obs = data.max_n_obs metaonly = data.metaonly for fc_cnt in range(0, len(col_names)): cur_name_str = col_names[fc_cnt] cur_data = col_data[fc_cnt] if is_unkown_number_rows and not metaonly: cur_data = cur_data[0:max_n_obs] if not metaonly: final_container[cur_name_str] = cur_data else: final_container[cur_name_str] = list() return final_container cdef object dict_to_pandas_dataframe(object dict_data, data_container dc): """ Transforms a dict of numpy arrays to a pandas data frame """ cdef bint dates_as_pandas cdef int index cdef str column cdef py_datetime_format var_format cdef list dtypes dates_as_pandas = dc.dates_as_pandas if dict_data: data_frame = pd.DataFrame.from_dict(dict_data) if dates_as_pandas: dtypes = data_frame.dtypes.tolist() # check that datetime columns are datetime type # this is needed in case all date values are nan for index, column in enumerate(data_frame.columns): var_format = dc.col_formats[index] if dtypes[index] != ' filename_bytes data = data_container() ctx = data data.file_format = file_format data.metaonly = metaonly data.dates_as_pandas = dates_as_pandas if encoding: data.user_encoding = encoding if file_format == FILE_FORMAT_SAS: origin = sas_origin elif file_format == FILE_FORMAT_SPSS: origin = spss_origin elif file_format == FILE_FORMAT_STATA: origin = stata_origin else: raise PyreadstatError("Unknown file format") data.origin = origin if usecols is not None: data.filter_cols = 1 data.use_cols = usecols data.usernan = usernan data.no_datetime_conversion = no_datetime_conversion # go! run_readstat_parser(filename, data, file_extension, row_limit, row_offset) data_dict = data_container_to_dict(data) if output_format == 'dict': data_frame = data_dict elif output_format == 'pandas': data_frame = dict_to_pandas_dataframe(data_dict, data) metadata = data_container_extract_metadata(data) return data_frame, metadata ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418353.0 pyreadstat-1.2.7/pyreadstat/_readstat_writer.c0000644023477200000240000410126314574564661021522 0ustar00fajardoostaffs/* Generated by Cython 3.0.9 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ "pyreadstat/conditional_includes.h", "src/readstat.h", "src/readstat_io_unistd.h" ], "extra_compile_args": [ "-Ireadstat", "-DHAVE_ZLIB=1" ], "include_dirs": [ "pyreadstat", "src", "src/stata", "src/spss", "src/sas", "." ], "libraries": [ "m", "z" ], "name": "pyreadstat._readstat_writer", "sources": [ "pyreadstat/_readstat_writer.pyx", "./src/CKHashTable.c", "./src/readstat_bits.c", "./src/readstat_convert.c", "./src/readstat_error.c", "./src/readstat_io_unistd.c", "./src/readstat_malloc.c", "./src/readstat_metadata.c", "./src/readstat_parser.c", "./src/readstat_value.c", "./src/readstat_variable.c", "./src/readstat_writer.c", "./src/sas/ieee.c", "./src/sas/readstat_sas.c", "./src/sas/readstat_sas7bcat_read.c", "./src/sas/readstat_sas7bcat_write.c", "./src/sas/readstat_sas7bdat_read.c", "./src/sas/readstat_sas7bdat_write.c", "./src/sas/readstat_sas_rle.c", "./src/sas/readstat_xport.c", "./src/sas/readstat_xport_parse_format.c", "./src/sas/readstat_xport_read.c", "./src/sas/readstat_xport_write.c", "./src/spss/readstat_por.c", "./src/spss/readstat_por_parse.c", "./src/spss/readstat_por_read.c", "./src/spss/readstat_por_write.c", "./src/spss/readstat_sav.c", "./src/spss/readstat_sav_compress.c", "./src/spss/readstat_sav_parse.c", "./src/spss/readstat_sav_parse_timestamp.c", "./src/spss/readstat_sav_read.c", "./src/spss/readstat_sav_write.c", "./src/spss/readstat_spss.c", "./src/spss/readstat_spss_parse.c", "./src/spss/readstat_zsav_compress.c", "./src/spss/readstat_zsav_read.c", "./src/spss/readstat_zsav_write.c", "./src/stata/readstat_dta.c", "./src/stata/readstat_dta_parse_timestamp.c", "./src/stata/readstat_dta_read.c", "./src/stata/readstat_dta_write.c" ] }, "module_name": "pyreadstat._readstat_writer" } END: Cython Metadata */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ #if defined(CYTHON_LIMITED_API) && 0 #ifndef Py_LIMITED_API #if CYTHON_LIMITED_API+0 > 0x03030000 #define Py_LIMITED_API CYTHON_LIMITED_API #else #define Py_LIMITED_API 0x03030000 #endif #endif #endif #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02070000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.7+ or Python 3.3+. #else #if defined(CYTHON_LIMITED_API) && CYTHON_LIMITED_API #define __PYX_EXTRA_ABI_MODULE_NAME "limited" #else #define __PYX_EXTRA_ABI_MODULE_NAME "" #endif #define CYTHON_ABI "3_0_9" __PYX_EXTRA_ABI_MODULE_NAME #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." #define CYTHON_HEX_VERSION 0x030009F0 #define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG #define HAVE_LONG_LONG #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX #if defined(GRAALVM_PYTHON) /* For very preliminary testing purposes. Most variables are set the same as PyPy. The existence of this section does not imply that anything works or is even tested */ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 1 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3) #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(PYPY_VERSION) #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3) #endif #if PY_VERSION_HEX < 0x03090000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1 && PYPY_VERSION_NUM >= 0x07030C00) #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(CYTHON_LIMITED_API) #ifdef Py_LIMITED_API #undef __PYX_LIMITED_VERSION_HEX #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API #endif #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 1 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_CLINE_IN_TRACEBACK #define CYTHON_CLINE_IN_TRACEBACK 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 1 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #endif #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 1 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(Py_GIL_DISABLED) || defined(Py_NOGIL) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 1 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #ifndef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #ifndef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #ifndef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #ifndef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #ifndef CYTHON_FAST_GIL #define CYTHON_FAST_GIL (PY_MAJOR_VERSION < 3 || PY_VERSION_HEX >= 0x03060000 && PY_VERSION_HEX < 0x030C00A6) #endif #ifndef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL (PY_VERSION_HEX >= 0x030700A1) #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #if PY_VERSION_HEX < 0x030400a1 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #elif !defined(CYTHON_USE_TP_FINALIZE) #define CYTHON_USE_TP_FINALIZE 1 #endif #if PY_VERSION_HEX < 0x030600B1 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #elif !defined(CYTHON_USE_DICT_VERSIONS) #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5) #endif #if PY_VERSION_HEX < 0x030700A3 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #elif !defined(CYTHON_USE_EXC_INFO_STACK) #define CYTHON_USE_EXC_INFO_STACK 1 #endif #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if !defined(CYTHON_VECTORCALL) #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL && PY_VERSION_HEX >= 0x030800B1) #endif #define CYTHON_BACKPORT_VECTORCALL (CYTHON_METH_FASTCALL && PY_VERSION_HEX < 0x030800B1) #if CYTHON_USE_PYLONG_INTERNALS #if PY_MAJOR_VERSION < 3 #include "longintrepr.h" #endif #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED #if defined(__cplusplus) /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(maybe_unused) #define CYTHON_UNUSED [[maybe_unused]] #endif #endif #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_UNUSED_VAR # if defined(__cplusplus) template void CYTHON_UNUSED_VAR( const T& ) { } # else # define CYTHON_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x) #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #ifndef CYTHON_USE_CPP_STD_MOVE #if defined(__cplusplus) && (\ __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) #define CYTHON_USE_CPP_STD_MOVE 1 #else #define CYTHON_USE_CPP_STD_MOVE 0 #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifdef _MSC_VER #ifndef _MSC_STDINT_H_ #if _MSC_VER < 1300 typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #else typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; #endif #endif #if _MSC_VER < 1300 #ifdef _WIN64 typedef unsigned long long __pyx_uintptr_t; #else typedef unsigned int __pyx_uintptr_t; #endif #else #ifdef _WIN64 typedef unsigned __int64 __pyx_uintptr_t; #else typedef unsigned __int32 __pyx_uintptr_t; #endif #endif #else #include typedef uintptr_t __pyx_uintptr_t; #endif #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifdef __cplusplus template struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL::value) #else #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0) #endif #if CYTHON_COMPILING_IN_PYPY == 1 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x030A0000) #else #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000) #endif #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_DefaultClassType PyClass_Type #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyObject *exception_table = NULL; PyObject *types_module=NULL, *code_type=NULL, *result=NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030B0000 PyObject *version_info; PyObject *py_minor_version = NULL; #endif long minor_version = 0; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); #if __PYX_LIMITED_VERSION_HEX >= 0x030B0000 minor_version = 11; #else if (!(version_info = PySys_GetObject("version_info"))) goto end; if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; minor_version = PyLong_AsLong(py_minor_version); Py_DECREF(py_minor_version); if (minor_version == -1 && PyErr_Occurred()) goto end; #endif if (!(types_module = PyImport_ImportModule("types"))) goto end; if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; if (minor_version <= 7) { (void)p; result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOO", a, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else if (minor_version <= 10) { result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOO", a,p, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else { if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOO", a,p, k, l, s, f, code, c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); } end: Py_XDECREF(code_type); Py_XDECREF(exception_table); Py_XDECREF(types_module); if (type) { PyErr_Restore(type, value, traceback); } return result; } #ifndef CO_OPTIMIZED #define CO_OPTIMIZED 0x0001 #endif #ifndef CO_NEWLOCALS #define CO_NEWLOCALS 0x0002 #endif #ifndef CO_VARARGS #define CO_VARARGS 0x0004 #endif #ifndef CO_VARKEYWORDS #define CO_VARKEYWORDS 0x0008 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x0200 #endif #ifndef CO_GENERATOR #define CO_GENERATOR 0x0020 #endif #ifndef CO_COROUTINE #define CO_COROUTINE 0x0080 #endif #elif PY_VERSION_HEX >= 0x030B0000 static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyCodeObject *result; PyObject *empty_bytes = PyBytes_FromStringAndSize("", 0); if (!empty_bytes) return NULL; result = #if PY_VERSION_HEX >= 0x030C0000 PyUnstable_Code_NewWithPosOnlyArgs #else PyCode_NewWithPosOnlyArgs #endif (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, empty_bytes); Py_DECREF(empty_bytes); return result; } #elif PY_VERSION_HEX >= 0x030800B2 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif #endif #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE) #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type) #else #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is) #define __Pyx_Py_Is(x, y) Py_Is(x, y) #else #define __Pyx_Py_Is(x, y) ((x) == (y)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone) #define __Pyx_Py_IsNone(ob) Py_IsNone(ob) #else #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue) #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob) #else #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse) #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob) #else #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False) #endif #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o) #else #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o) #endif #ifndef CO_COROUTINE #define CO_COROUTINE 0x80 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x200 #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef Py_TPFLAGS_SEQUENCE #define Py_TPFLAGS_SEQUENCE 0 #endif #ifndef Py_TPFLAGS_MAPPING #define Py_TPFLAGS_MAPPING 0 #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #if PY_VERSION_HEX >= 0x030d00A4 # define __Pyx_PyCFunctionFast PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords #else # define __Pyx_PyCFunctionFast _PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #endif #if CYTHON_METH_FASTCALL #define __Pyx_METH_FASTCALL METH_FASTCALL #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords #else #define __Pyx_METH_FASTCALL METH_VARARGS #define __Pyx_PyCFunction_FastCall PyCFunction #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords #endif #if CYTHON_VECTORCALL #define __pyx_vectorcallfunc vectorcallfunc #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n)) #elif CYTHON_BACKPORT_VECTORCALL typedef PyObject *(*__pyx_vectorcallfunc)(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames); #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET ((size_t)1 << (8 * sizeof(size_t) - 1)) #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(((size_t)(n)) & ~__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)) #else #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) #endif #if PY_MAJOR_VERSION >= 0x030900B1 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) #else #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) #endif #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) #elif !CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; } #endif static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void *cfunc) { #if CYTHON_COMPILING_IN_LIMITED_API return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; #else return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; #endif } #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) #if __PYX_LIMITED_VERSION_HEX < 0x030900B1 #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); #else #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b) #define __Pyx_PyCMethod PyCMethod #endif #ifndef METH_METHOD #define METH_METHOD 0x200 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyThreadState_Current PyThreadState_Get() #elif !CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() #elif PY_VERSION_HEX >= 0x03060000 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #elif PY_VERSION_HEX >= 0x03000000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #else #define __Pyx_PyThreadState_Current _PyThreadState_Current #endif #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE void *__Pyx_PyModule_GetState(PyObject *op) { void *result; result = PyModule_GetState(op); if (!result) Py_FatalError("Couldn't find the module state"); return result; } #endif #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE(obj), name, func_ctype) #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name)) #else #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name) #endif #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) #include "pythread.h" #define Py_tss_NEEDS_INIT 0 typedef int Py_tss_t; static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { *key = PyThread_create_key(); return 0; } static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); *key = Py_tss_NEEDS_INIT; return key; } static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { PyObject_Free(key); } static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { return *key != Py_tss_NEEDS_INIT; } static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { PyThread_delete_key(*key); *key = Py_tss_NEEDS_INIT; } static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { return PyThread_set_key_value(*key, value); } static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { return PyThread_get_key_value(*key); } #endif #if PY_MAJOR_VERSION < 3 #if CYTHON_COMPILING_IN_PYPY #if PYPY_VERSION_NUM < 0x07030600 #if defined(__cplusplus) && __cplusplus >= 201402L [[deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")]] #elif defined(__GNUC__) || defined(__clang__) __attribute__ ((__deprecated__("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6"))) #elif defined(_MSC_VER) __declspec(deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")) #endif static CYTHON_INLINE int PyGILState_Check(void) { return 0; } #else // PYPY_VERSION_NUM < 0x07030600 #endif // PYPY_VERSION_NUM < 0x07030600 #else static CYTHON_INLINE int PyGILState_Check(void) { PyThreadState * tstate = _PyThreadState_Current; return tstate && (tstate == PyGILState_GetThisThreadState()); } #endif #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B4 && PY_VERSION_HEX < 0x030d0000 && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); if (res == NULL) PyErr_Clear(); return res; } #elif PY_MAJOR_VERSION >= 3 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000) #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError #define __Pyx_PyDict_GetItemStr PyDict_GetItem #else static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { #if CYTHON_COMPILING_IN_PYPY return PyDict_GetItem(dict, name); #else PyDictEntry *ep; PyDictObject *mp = (PyDictObject*) dict; long hash = ((PyStringObject *) name)->ob_shash; assert(hash != -1); ep = (mp->ma_lookup)(mp, name, hash); if (ep == NULL) { return NULL; } return ep->me_value; #endif } #define __Pyx_PyDict_GetItemStr PyDict_GetItem #endif #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0) #define __Pyx_PyObject_GetIterNextFunc(obj) (Py_TYPE(obj)->tp_iternext) #else #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) #define __Pyx_PyObject_GetIterNextFunc(obj) PyIter_Next #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_SetItemOnTypeDict(tp, k, v) PyObject_GenericSetAttr((PyObject*)tp, k, v) #else #define __Pyx_SetItemOnTypeDict(tp, k, v) PyDict_SetItem(tp->tp_dict, k, v) #endif #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX >= 0x03080000 #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ PyTypeObject *type = Py_TYPE((PyObject*)obj);\ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ PyObject_GC_Del(obj);\ Py_DECREF(type);\ } #else #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GetLength(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U) #define __Pyx_PyUnicode_KIND(u) ((void)u, (0)) #define __Pyx_PyUnicode_DATA(u) ((void*)u) #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i)) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u)) #elif PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_READY(op) (0) #else #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #endif #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u)) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch) #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #else #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #endif #else #define CYTHON_PEP393_ENABLED 0 #define PyUnicode_1BYTE_KIND 1 #define PyUnicode_2BYTE_KIND 2 #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535U : 1114111U) #define __Pyx_PyUnicode_KIND(u) ((int)sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = (Py_UNICODE) ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY #if !defined(PyUnicode_DecodeUnicodeEscape) #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors) #endif #if !defined(PyUnicode_Contains) || (PY_MAJOR_VERSION == 2 && PYPY_VERSION_NUM < 0x07030500) #undef PyUnicode_Contains #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) #define PyObject_ASCII(o) PyObject_Repr(o) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #ifndef PyObject_Unicode #define PyObject_Unicode PyObject_Str #endif #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #else #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) #else #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) #endif #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #else static CYTHON_INLINE PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *module = PyImport_AddModule(name); Py_XINCREF(module); return module; } #endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define __Pyx_Py3Int_Check(op) PyLong_Check(op) #define __Pyx_Py3Int_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #else #define __Pyx_Py3Int_Check(op) (PyLong_Check(op) || PyInt_Check(op)) #define __Pyx_Py3Int_CheckExact(op) (PyLong_CheckExact(op) || PyInt_CheckExact(op)) #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t #endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef __Pyx_PyAsyncMethodsStruct typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #endif #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) #if !defined(_USE_MATH_DEFINES) #define _USE_MATH_DEFINES #endif #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #define __PYX_MARK_ERR_POS(f_index, lineno) \ { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifdef CYTHON_EXTERN_C #undef __PYX_EXTERN_C #define __PYX_EXTERN_C CYTHON_EXTERN_C #elif defined(__PYX_EXTERN_C) #ifdef _MSC_VER #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.") #else #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead. #endif #else #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__pyreadstat___readstat_writer #define __PYX_HAVE_API__pyreadstat___readstat_writer /* Early includes */ #include #include #include #include "readstat.h" #include "readstat_io_unistd.h" #include "conditional_includes.h" #include #ifdef _OPENMP #include #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 1 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) #define __PYX_DEFAULT_STRING_ENCODING "utf8" #define __Pyx_PyObject_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #else #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #endif #if CYTHON_USE_PYLONG_INTERNALS #if PY_VERSION_HEX >= 0x030C00A7 #ifndef _PyLong_SIGN_MASK #define _PyLong_SIGN_MASK 3 #endif #ifndef _PyLong_NON_SIZE_BITS #define _PyLong_NON_SIZE_BITS 3 #endif #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK) #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0) #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x)) #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1) #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0) #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_SignedDigitCount(x)\ ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x)) #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue) #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x) #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x) #else #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0]) #endif typedef Py_ssize_t __Pyx_compact_pylong; typedef size_t __Pyx_compact_upylong; #else #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0) #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x)) #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x) #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1) #define __Pyx_PyLong_CompactValue(x)\ ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0])) typedef sdigit __Pyx_compact_pylong; typedef digit __Pyx_compact_upylong; #endif #if PY_VERSION_HEX >= 0x030C00A5 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) #else #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) #endif #endif #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #include static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = (char) c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #include static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } #if !CYTHON_USE_MODULE_STATE static PyObject *__pyx_m = NULL; #endif static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm = __FILE__; static const char *__pyx_filename; /* #### Code section: filename_table ### */ static const char *__pyx_f[] = { "pyreadstat/_readstat_writer.pyx", "pyreadstat/_readstat_parser.pxd", }; /* #### Code section: utility_code_proto_before_types ### */ /* ForceInitThreads.proto */ #ifndef __PYX_FORCE_INIT_THREADS #define __PYX_FORCE_INIT_THREADS 0 #endif /* #### Code section: numeric_typedefs ### */ /* #### Code section: complex_type_declarations ### */ /* #### Code section: type_declarations ### */ /*--- Type declarations ---*/ struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container; /* "_readstat_parser.pxd":22 * * # Definitions of enum types * ctypedef enum py_file_extension: # <<<<<<<<<<<<<< * FILE_EXT_SAV * FILE_EXT_SAS7BDAT */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension { __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAV, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BDAT, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_DTA, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_XPORT, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_POR, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BCAT }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension; /* "_readstat_parser.pxd":30 * FILE_EXT_SAS7BCAT * * ctypedef enum py_file_format: # <<<<<<<<<<<<<< * FILE_FORMAT_SAS * FILE_FORMAT_SPSS */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_format { __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS, __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS, __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_t_10pyreadstat_16_readstat_parser_py_file_format; /* "_readstat_parser.pxd":35 * FILE_FORMAT_STATA * * ctypedef enum py_datetime_format: # <<<<<<<<<<<<<< * DATE_FORMAT_NOTADATE * DATE_FORMAT_DATE */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format { __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATE, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATETIME, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_TIME }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format; /* "_readstat_parser.pxd":41 * DATE_FORMAT_TIME * * ctypedef enum py_variable_format: # <<<<<<<<<<<<<< * VAR_FORMAT_STRING * VAR_FORMAT_LONG */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format { __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_STRING, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_MISSING }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format; /* "pyreadstat/_readstat_writer.pxd":56 * ssize_t write(int fd, const void *buf, size_t nbyte) * * ctypedef enum dst_file_format: # <<<<<<<<<<<<<< * FILE_FORMAT_SAS7BDAT * FILE_FORMAT_SAS7BCAT */ enum __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format { __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAS7BDAT, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAS7BCAT, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_XPORT, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAV, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_POR }; typedef enum __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format; /* "pyreadstat/_readstat_writer.pxd":64 * FILE_FORMAT_POR * * ctypedef enum pywriter_variable_type: # <<<<<<<<<<<<<< * PYWRITER_DOUBLE * PYWRITER_INTEGER */ enum __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type { __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DOUBLE, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_INTEGER, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_LOGICAL, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US }; typedef enum __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type; /* "_readstat_parser.pxd":49 * # Definitions of extension types * * cdef class data_container: # <<<<<<<<<<<<<< * """ * This extension type holds all the data we need to get from our file from */ struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container { PyObject_HEAD int n_obs; int n_vars; int max_n_obs; PyObject *col_data; PyObject *col_data_len; PyObject *col_names; PyObject *col_labels; PyObject *col_dtypes; PyObject *col_numpy_dtypes; PyObject *col_dtypes_isobject; PyObject *col_dytpes_isfloat; PyObject *col_formats; PyObject *col_formats_original; PyObject *origin; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format file_format; int is_unkown_number_rows; PyObject *file_label; PyObject *file_encoding; int metaonly; int dates_as_pandas; PyObject *label_to_var_name; PyObject *labels_raw; PyObject *notes; PyObject *user_encoding; PyObject *table_name; int filter_cols; PyObject *use_cols; int usernan; PyObject *missing_ranges; PyObject *missing_user_values; PyObject *variable_storage_width; PyObject *variable_display_width; PyObject *variable_alignment; PyObject *variable_measure; int no_datetime_conversion; int ctime; int mtime; }; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, Py_ssize_t); void (*DECREF)(void*, PyObject*, Py_ssize_t); void (*GOTREF)(void*, PyObject*, Py_ssize_t); void (*GIVEREF)(void*, PyObject*, Py_ssize_t); void* (*SetupContext)(const char*, Py_ssize_t, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__)) #define __Pyx_RefNannyFinishContextNogil() __Pyx_RefNannyFinishContext() #endif #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContextNogil() #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_Py_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; Py_XDECREF(tmp);\ } while (0) #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #if PY_VERSION_HEX >= 0x030C00A6 #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL) #else #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type) #endif #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL) #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* PyObjectGetAttrStrNoError.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __pyx_dict_cached_value;\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) do {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* PyFunctionFastCall.proto */ #if CYTHON_FAST_PYCALL #if !CYTHON_VECTORCALL #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); #endif #define __Pyx_BUILD_ASSERT_EXPR(cond)\ (sizeof(char [1 - 2*!(cond)]) - 1) #ifndef Py_MEMBER_SIZE #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) #endif #if !CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03080000 #include "frameobject.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #define __Pxy_PyFrame_Initialize_Offsets() #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus) #else static size_t __pyx_pyframe_localsplus_offset = 0; #include "frameobject.h" #define __Pxy_PyFrame_Initialize_Offsets()\ ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) #define __Pyx_PyFrame_GetLocalsplus(frame)\ (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) #endif #endif #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectFastCall.proto */ #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL) static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs); /* IncludeStringH.proto */ #include /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* StrEquals.proto */ #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals #else #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals #endif /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* RaiseUnexpectedTypeError.proto */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); /* UnpackUnboundCMethod.proto */ typedef struct { PyObject *type; PyObject **method_name; PyCFunction func; PyObject *method; int flag; } __Pyx_CachedCFunction; /* CallUnboundCMethod1.proto */ static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg); #else #define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg) #endif /* py_dict_keys.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d); /* CallUnboundCMethod0.proto */ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CallUnboundCMethod0(cfunc, self)\ (likely((cfunc)->func) ?\ (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\ (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\ (PY_VERSION_HEX >= 0x030700A0 ?\ (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\ (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\ (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\ (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\ (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\ ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\ __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\ __Pyx__CallUnboundCMethod0(cfunc, self)) #else #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) #endif /* PyObject_Str.proto */ #define __Pyx_PyObject_Str(obj)\ (likely(PyString_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj)) /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); /* RaiseNeedMoreValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* IterFinish.proto */ static CYTHON_INLINE int __Pyx_IterFinish(void); /* UnpackItemEndCheck.proto */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /* PyIntBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) #endif /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* ObjectGetItem.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key); #else #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) #endif /* dict_getitem_default.proto */ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value); /* CallUnboundCMethod2.proto */ static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1 static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); #else #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2) #endif /* pyfrozenset_new.proto */ static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it); /* PySetContains.proto */ static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq); /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { Py_INCREF(x); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 L->ob_item[len] = x; #else PyList_SET_ITEM(list, len, x); #endif __Pyx_SET_SIZE(list, len + 1); return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); #define __Pyx_PyObject_Dict_GetItem(obj, name)\ (likely(PyDict_CheckExact(obj)) ?\ __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) #endif /* py_dict_items.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /* PySequenceContains.proto */ static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { int result = PySequence_Contains(seq, item); return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* UnicodeAsUCS4.proto */ static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject*); /* object_ord.proto */ #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyObject_Ord(c)\ (likely(PyUnicode_Check(c)) ? (long)__Pyx_PyUnicode_AsPy_UCS4(c) : __Pyx__PyObject_Ord(c)) #else #define __Pyx_PyObject_Ord(c) __Pyx__PyObject_Ord(c) #endif static long __Pyx__PyObject_Ord(PyObject* c); /* PyIntCompare.proto */ static CYTHON_INLINE int __Pyx_PyInt_BoolNeObjC(PyObject *op1, PyObject *op2, long intval, long inplace); /* WriteUnraisableException.proto */ static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil); /* RaiseUnboundLocalError.proto */ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); /* ListCompAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len)) { Py_INCREF(x); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 L->ob_item[len] = x; #else PyList_SET_ITEM(list, len, x); #endif __Pyx_SET_SIZE(list, len + 1); return 0; } return PyList_Append(list, x); } #else #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) #endif /* GetAttr.proto */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); /* HasAttr.proto */ #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 #define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n) #else static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); #endif /* GetTopmostException.proto */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); #endif /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); #else #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif /* PyFloatBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyFloat_DivideObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check); #else #define __Pyx_PyFloat_DivideObjC(op1, op2, floatval, inplace, zerodivision_check)\ ((inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2))) #endif /* SwapException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); #endif /* TypeImport.proto */ #ifndef __PYX_HAVE_RT_ImportType_proto_3_0_9 #define __PYX_HAVE_RT_ImportType_proto_3_0_9 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #include #endif #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L #define __PYX_GET_STRUCT_ALIGNMENT_3_0_9(s) alignof(s) #else #define __PYX_GET_STRUCT_ALIGNMENT_3_0_9(s) sizeof(void*) #endif enum __Pyx_ImportType_CheckSize_3_0_9 { __Pyx_ImportType_CheckSize_Error_3_0_9 = 0, __Pyx_ImportType_CheckSize_Warn_3_0_9 = 1, __Pyx_ImportType_CheckSize_Ignore_3_0_9 = 2 }; static PyTypeObject *__Pyx_ImportType_3_0_9(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_9 check_size); #endif /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportDottedModule.proto */ static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple); #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple); #endif /* ImportDottedModuleRelFirst.proto */ static PyObject *__Pyx_ImportDottedModuleRelFirst(PyObject *name, PyObject *parts_tuple); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* PyObjectCallNoArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); /* CLineInTraceback.proto */ #ifdef CYTHON_CLINE_IN_TRACEBACK #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #else static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #endif /* CodeObjectCache.proto */ #if !CYTHON_COMPILING_IN_LIMITED_API typedef struct { PyCodeObject* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); #endif /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_readstat_type_t(readstat_type_t value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); /* CIntFromPy.proto */ static CYTHON_INLINE readstat_type_t __Pyx_PyInt_As_readstat_type_t(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(PyObject *); /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%U" static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp); #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) #else typedef const char *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%.200s" #define __Pyx_PyType_GetName(tp) ((tp)->tp_name) #define __Pyx_DECREF_TypeName(obj) #endif /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2)) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) /* CheckBinaryVersion.proto */ static unsigned long __Pyx_get_runtime_version(void); static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); /* FunctionExport.proto */ static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig); /* VoidPtrImport.proto */ static int __Pyx_ImportVoidPtr_3_0_9(PyObject *module, const char *name, void **p, const char *sig); /* FunctionImport.proto */ static int __Pyx_ImportFunction_3_0_9(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* #### Code section: module_declarations ### */ /* Module declarations from "libc.stddef" */ /* Module declarations from "pyreadstat.readstat_api" */ /* Module declarations from "libc.math" */ /* Module declarations from "pyreadstat._readstat_parser" */ static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_readstat_to_numpy_types = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types (*__pyx_vp_10pyreadstat_16_readstat_parser_readstat_to_numpy_types) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_date_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_date_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_datetime_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_datetime_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_time_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_time_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_all_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_all_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_all_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_origin = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_origin (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_origin) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_datetime_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_datetime_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_date_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_date_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_time_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_time_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_all_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_all_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_all_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_origin = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_origin (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_origin) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_datetime_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_datetime_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_date_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_date_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_time_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_time_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_all_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_all_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_all_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_origin = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_origin (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_origin) static void (*__pyx_f_10pyreadstat_16_readstat_parser_check_exit_status)(readstat_error_t); /*proto*/ /* Module declarations from "pyreadstat._readstat_writer" */ static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_int_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_int_mixed_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_float_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_numeric_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_datetime_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_nat_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_pyrwriter_datetimelike_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_pandas_to_readstat_types = 0; static double __pyx_v_10pyreadstat_16_readstat_writer_spss_offset_secs; static double __pyx_v_10pyreadstat_16_readstat_writer_sas_offset_secs; static double __pyx_v_10pyreadstat_16_readstat_writer_spss_offset_days; static double __pyx_v_10pyreadstat_16_readstat_writer_sas_offset_days; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_date_0 = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_sas = 0; static PyObject *__pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_stata = 0; static double __pyx_f_10pyreadstat_16_readstat_writer_convert_datetimelike_to_number(__pyx_t_10pyreadstat_16_readstat_writer_dst_file_format, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, PyObject *); /*proto*/ static char *__pyx_f_10pyreadstat_16_readstat_writer_get_datetimelike_format_for_readstat(__pyx_t_10pyreadstat_16_readstat_writer_dst_file_format, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_writer_get_pandas_str_series_max_length(PyObject *, PyObject *); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_writer_check_series_all_same_types(PyObject *, PyObject *); /*proto*/ static PyObject *__pyx_f_10pyreadstat_16_readstat_writer_get_pandas_column_types(PyObject *, PyObject *, PyObject *); /*proto*/ static Py_ssize_t __pyx_f_10pyreadstat_16_readstat_writer_write_bytes(void const *, size_t, void *); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_writer_open_file(PyObject *); /*proto*/ static int __pyx_f_10pyreadstat_16_readstat_writer_close_file(int); /*proto*/ static readstat_label_set_t *__pyx_f_10pyreadstat_16_readstat_writer_set_value_label(readstat_writer_t *, PyObject *, PyObject *, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format, PyObject *, PyObject *); /*proto*/ static void __pyx_f_10pyreadstat_16_readstat_writer_add_missing_ranges(PyObject *, readstat_variable_t *, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, PyObject *); /*proto*/ static void __pyx_f_10pyreadstat_16_readstat_writer_set_variable_alignment(readstat_variable_t *, PyObject *, PyObject *); /*proto*/ static void __pyx_f_10pyreadstat_16_readstat_writer_set_variable_display_width(readstat_variable_t *, int, PyObject *); /*proto*/ static void __pyx_f_10pyreadstat_16_readstat_writer_set_variable_measure(readstat_variable_t *, PyObject *, PyObject *); /*proto*/ /* #### Code section: typeinfo ### */ /* #### Code section: before_global_var ### */ #define __Pyx_MODULE_NAME "pyreadstat._readstat_writer" extern int __pyx_module_is_main_pyreadstat___readstat_writer; int __pyx_module_is_main_pyreadstat___readstat_writer = 0; /* Implementation of "pyreadstat._readstat_writer" */ /* #### Code section: global_var ### */ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_chr; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_zip; static PyObject *__pyx_builtin_object; static PyObject *__pyx_builtin_UnicodeError; /* #### Code section: string_decls ### */ static const char __pyx_k_x[] = "x"; static const char __pyx_k__2[] = " "; static const char __pyx_k__4[] = "*"; static const char __pyx_k__5[] = "."; static const char __pyx_k_hi[] = "hi"; static const char __pyx_k_lo[] = "lo"; static const char __pyx_k_np[] = "np"; static const char __pyx_k_nt[] = "nt"; static const char __pyx_k_os[] = "os"; static const char __pyx_k_pd[] = "pd"; static const char __pyx_k__17[] = "_"; static const char __pyx_k__18[] = "?"; static const char __pyx_k_any[] = "any"; static const char __pyx_k_chr[] = "chr"; static const char __pyx_k_get[] = "get"; static const char __pyx_k_loc[] = "loc"; static const char __pyx_k_min[] = "min"; static const char __pyx_k_nan[] = "nan"; static const char __pyx_k_sys[] = "sys"; static const char __pyx_k_utc[] = "utc"; static const char __pyx_k_zip[] = "zip"; static const char __pyx_k_asm8[] = "asm8"; static const char __pyx_k_copy[] = "copy"; static const char __pyx_k_core[] = "core"; static const char __pyx_k_date[] = "date"; static const char __pyx_k_days[] = "days"; static const char __pyx_k_drop[] = "drop"; static const char __pyx_k_iloc[] = "iloc"; static const char __pyx_k_int8[] = "int8"; static const char __pyx_k_isin[] = "isin"; static const char __pyx_k_isna[] = "isna"; static const char __pyx_k_keys[] = "keys"; static const char __pyx_k_left[] = "left"; static const char __pyx_k_libs[] = "_libs"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_name[] = "name"; static const char __pyx_k_path[] = "path"; static const char __pyx_k_spec[] = "__spec__"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_time[] = "time"; static const char __pyx_k_warn[] = "warn"; static const char __pyx_k_M8_ns[] = "__pyx_d); Py_CLEAR(clear_module_state->__pyx_b); Py_CLEAR(clear_module_state->__pyx_cython_runtime); Py_CLEAR(clear_module_state->__pyx_empty_tuple); Py_CLEAR(clear_module_state->__pyx_empty_bytes); Py_CLEAR(clear_module_state->__pyx_empty_unicode); #ifdef __Pyx_CyFunction_USED Py_CLEAR(clear_module_state->__pyx_CyFunctionType); #endif #ifdef __Pyx_FusedFunction_USED Py_CLEAR(clear_module_state->__pyx_FusedFunctionType); #endif Py_CLEAR(clear_module_state->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container); Py_CLEAR(clear_module_state->__pyx_n_s_CategoricalDtype); Py_CLEAR(clear_module_state->__pyx_kp_s_Column_labels_must_be_strings); Py_CLEAR(clear_module_state->__pyx_n_s_DataFrame); Py_CLEAR(clear_module_state->__pyx_n_s_Float32Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_Float64Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_Int16Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_Int32Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_Int64Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_Int8Dtype); Py_CLEAR(clear_module_state->__pyx_kp_s_M8_ns); Py_CLEAR(clear_module_state->__pyx_kp_s_Non_unique_column_names_detected); Py_CLEAR(clear_module_state->__pyx_n_s_PyreadstatError); Py_CLEAR(clear_module_state->__pyx_n_s_ReadstatError); Py_CLEAR(clear_module_state->__pyx_n_s_Timestamp); Py_CLEAR(clear_module_state->__pyx_n_s_UInt16Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_UInt32Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_UInt64Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_UInt8Dtype); Py_CLEAR(clear_module_state->__pyx_n_s_UnicodeError); Py_CLEAR(clear_module_state->__pyx_kp_s_Unknown_data_format_to_insert); Py_CLEAR(clear_module_state->__pyx_kp_s_Unknown_pywriter_variable_format); Py_CLEAR(clear_module_state->__pyx_n_s__17); Py_CLEAR(clear_module_state->__pyx_n_s__18); Py_CLEAR(clear_module_state->__pyx_kp_s__2); Py_CLEAR(clear_module_state->__pyx_n_s__4); Py_CLEAR(clear_module_state->__pyx_kp_u__5); Py_CLEAR(clear_module_state->__pyx_kp_s_alignment_for_variable_s_must_be); Py_CLEAR(clear_module_state->__pyx_n_s_any); Py_CLEAR(clear_module_state->__pyx_n_s_asarray); Py_CLEAR(clear_module_state->__pyx_n_s_asm8); Py_CLEAR(clear_module_state->__pyx_n_s_astype); Py_CLEAR(clear_module_state->__pyx_n_s_calendar); Py_CLEAR(clear_module_state->__pyx_n_s_center); Py_CLEAR(clear_module_state->__pyx_kp_s_character_missing_ranges_value_g); Py_CLEAR(clear_module_state->__pyx_n_s_chr); Py_CLEAR(clear_module_state->__pyx_n_s_class_getitem); Py_CLEAR(clear_module_state->__pyx_n_s_cline_in_traceback); Py_CLEAR(clear_module_state->__pyx_kp_s_column_labels_must_be_either_lis); Py_CLEAR(clear_module_state->__pyx_n_s_columns); Py_CLEAR(clear_module_state->__pyx_n_s_combine); Py_CLEAR(clear_module_state->__pyx_n_s_copy); Py_CLEAR(clear_module_state->__pyx_n_s_core); Py_CLEAR(clear_module_state->__pyx_n_s_date); Py_CLEAR(clear_module_state->__pyx_n_s_datetime); Py_CLEAR(clear_module_state->__pyx_n_s_datetime64); Py_CLEAR(clear_module_state->__pyx_kp_s_datetime64_ms); Py_CLEAR(clear_module_state->__pyx_kp_s_datetime64_ns); Py_CLEAR(clear_module_state->__pyx_kp_s_datetime64_us); Py_CLEAR(clear_module_state->__pyx_kp_s_datetime64_us_2); Py_CLEAR(clear_module_state->__pyx_n_s_days); Py_CLEAR(clear_module_state->__pyx_kp_s_dictionaries_in_missing_ranges_m); Py_CLEAR(clear_module_state->__pyx_n_s_drop); Py_CLEAR(clear_module_state->__pyx_n_s_dropna); Py_CLEAR(clear_module_state->__pyx_n_s_dtype); Py_CLEAR(clear_module_state->__pyx_n_s_dtypes); Py_CLEAR(clear_module_state->__pyx_n_s_encode); Py_CLEAR(clear_module_state->__pyx_n_s_enumerate); Py_CLEAR(clear_module_state->__pyx_n_s_expanduser); Py_CLEAR(clear_module_state->__pyx_kp_s_file_path_could_not_be_encoded_w); Py_CLEAR(clear_module_state->__pyx_kp_s_first_argument_must_be_a_pandas); Py_CLEAR(clear_module_state->__pyx_n_s_float); Py_CLEAR(clear_module_state->__pyx_n_s_float32); Py_CLEAR(clear_module_state->__pyx_n_s_float64); Py_CLEAR(clear_module_state->__pyx_n_s_fsdecode); Py_CLEAR(clear_module_state->__pyx_n_s_fsencode); Py_CLEAR(clear_module_state->__pyx_n_s_get); Py_CLEAR(clear_module_state->__pyx_n_s_getfilesystemencoding); Py_CLEAR(clear_module_state->__pyx_n_s_hi); Py_CLEAR(clear_module_state->__pyx_n_s_iloc); Py_CLEAR(clear_module_state->__pyx_n_s_import); Py_CLEAR(clear_module_state->__pyx_n_s_initializing); Py_CLEAR(clear_module_state->__pyx_n_s_int16); Py_CLEAR(clear_module_state->__pyx_n_s_int32); Py_CLEAR(clear_module_state->__pyx_n_s_int64); Py_CLEAR(clear_module_state->__pyx_n_s_int8); Py_CLEAR(clear_module_state->__pyx_n_s_is_datetime64_any_dtype); Py_CLEAR(clear_module_state->__pyx_n_s_is_datetime64_ns_dtype); Py_CLEAR(clear_module_state->__pyx_n_s_isalpha); Py_CLEAR(clear_module_state->__pyx_n_s_isin); Py_CLEAR(clear_module_state->__pyx_n_s_isna); Py_CLEAR(clear_module_state->__pyx_n_s_items); Py_CLEAR(clear_module_state->__pyx_n_s_keys); Py_CLEAR(clear_module_state->__pyx_n_s_left); Py_CLEAR(clear_module_state->__pyx_kp_s_length_of_column_labels_must_be); Py_CLEAR(clear_module_state->__pyx_n_s_libs); Py_CLEAR(clear_module_state->__pyx_n_s_lo); Py_CLEAR(clear_module_state->__pyx_n_s_loc); Py_CLEAR(clear_module_state->__pyx_n_s_main); Py_CLEAR(clear_module_state->__pyx_kp_s_measure_for_variable_s_must_be_e); Py_CLEAR(clear_module_state->__pyx_n_s_min); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_hi_and_lo_values); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_hi_and_lo_values_2); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_max_1_discrete_nu); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_max_1_range_value); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_max_3_discrete_nu); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_max_3_string_valu); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_string_values_len); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_values_in_diction); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_ranges_values_must_be_bo); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_user_values_not_allowed); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_user_values_supports_val); Py_CLEAR(clear_module_state->__pyx_kp_s_missing_user_values_values_in_di); Py_CLEAR(clear_module_state->__pyx_n_s_name); Py_CLEAR(clear_module_state->__pyx_n_s_name_2); Py_CLEAR(clear_module_state->__pyx_n_s_nan); Py_CLEAR(clear_module_state->__pyx_n_s_nominal); Py_CLEAR(clear_module_state->__pyx_n_s_np); Py_CLEAR(clear_module_state->__pyx_n_s_nt); Py_CLEAR(clear_module_state->__pyx_kp_s_numeric_missing_ranges_value_giv); Py_CLEAR(clear_module_state->__pyx_n_s_numpy); Py_CLEAR(clear_module_state->__pyx_n_s_object); Py_CLEAR(clear_module_state->__pyx_n_s_ordinal); Py_CLEAR(clear_module_state->__pyx_n_s_os); Py_CLEAR(clear_module_state->__pyx_n_s_pandas); Py_CLEAR(clear_module_state->__pyx_n_s_pandas_api_types); Py_CLEAR(clear_module_state->__pyx_n_s_path); Py_CLEAR(clear_module_state->__pyx_kp_s_path_must_be_either_str_or_bytes); Py_CLEAR(clear_module_state->__pyx_n_s_pd); Py_CLEAR(clear_module_state->__pyx_n_s_range); Py_CLEAR(clear_module_state->__pyx_n_s_readstat_parser); Py_CLEAR(clear_module_state->__pyx_n_s_replace); Py_CLEAR(clear_module_state->__pyx_n_s_reset_index); Py_CLEAR(clear_module_state->__pyx_n_s_right); Py_CLEAR(clear_module_state->__pyx_n_s_round); Py_CLEAR(clear_module_state->__pyx_n_s_scale); Py_CLEAR(clear_module_state->__pyx_n_s_spec); Py_CLEAR(clear_module_state->__pyx_n_s_startswith); Py_CLEAR(clear_module_state->__pyx_n_s_string); Py_CLEAR(clear_module_state->__pyx_n_s_surrogateescape); Py_CLEAR(clear_module_state->__pyx_n_s_sys); Py_CLEAR(clear_module_state->__pyx_n_s_test); Py_CLEAR(clear_module_state->__pyx_n_s_time); Py_CLEAR(clear_module_state->__pyx_n_s_timegm); Py_CLEAR(clear_module_state->__pyx_n_s_timestamps); Py_CLEAR(clear_module_state->__pyx_n_s_timetuple); Py_CLEAR(clear_module_state->__pyx_n_s_timezone); Py_CLEAR(clear_module_state->__pyx_n_s_timezone_2); Py_CLEAR(clear_module_state->__pyx_n_s_tolist); Py_CLEAR(clear_module_state->__pyx_n_s_total_seconds); Py_CLEAR(clear_module_state->__pyx_n_s_tslibs); Py_CLEAR(clear_module_state->__pyx_n_s_tzinfo); Py_CLEAR(clear_module_state->__pyx_n_s_uint16); Py_CLEAR(clear_module_state->__pyx_n_s_uint32); Py_CLEAR(clear_module_state->__pyx_n_s_uint64); Py_CLEAR(clear_module_state->__pyx_n_s_uint8); Py_CLEAR(clear_module_state->__pyx_n_s_union); Py_CLEAR(clear_module_state->__pyx_n_s_unknown); Py_CLEAR(clear_module_state->__pyx_kp_s_unknown_file_format); Py_CLEAR(clear_module_state->__pyx_n_s_upper); Py_CLEAR(clear_module_state->__pyx_n_s_utc); Py_CLEAR(clear_module_state->__pyx_kp_s_utf_8); Py_CLEAR(clear_module_state->__pyx_n_s_values); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_name_s_contains_a_space); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_name_s_is_of_type_s_and); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_name_s_starts_with_an_i); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_value_labels_type_of_La); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_value_labels_type_of_Va); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_value_labels_type_of_Va_2); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_value_labels_type_of_Va_3); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_value_labels_type_of_Va_4); Py_CLEAR(clear_module_state->__pyx_kp_s_variable_value_labels_value_for); Py_CLEAR(clear_module_state->__pyx_n_s_warn); Py_CLEAR(clear_module_state->__pyx_n_s_warnings); Py_CLEAR(clear_module_state->__pyx_n_s_x); Py_CLEAR(clear_module_state->__pyx_n_s_zip); Py_CLEAR(clear_module_state->__pyx_float_1e6); Py_CLEAR(clear_module_state->__pyx_float_1e9); Py_CLEAR(clear_module_state->__pyx_int_0); Py_CLEAR(clear_module_state->__pyx_int_1); Py_CLEAR(clear_module_state->__pyx_int_65); Py_CLEAR(clear_module_state->__pyx_int_97); Py_CLEAR(clear_module_state->__pyx_int_1970); Py_CLEAR(clear_module_state->__pyx_int_neg_9223056417655); Py_CLEAR(clear_module_state->__pyx_slice_); Py_CLEAR(clear_module_state->__pyx_tuple__3); Py_CLEAR(clear_module_state->__pyx_tuple__6); Py_CLEAR(clear_module_state->__pyx_tuple__7); Py_CLEAR(clear_module_state->__pyx_tuple__8); Py_CLEAR(clear_module_state->__pyx_tuple__9); Py_CLEAR(clear_module_state->__pyx_tuple__10); Py_CLEAR(clear_module_state->__pyx_tuple__11); Py_CLEAR(clear_module_state->__pyx_tuple__12); Py_CLEAR(clear_module_state->__pyx_tuple__13); Py_CLEAR(clear_module_state->__pyx_tuple__14); Py_CLEAR(clear_module_state->__pyx_tuple__15); Py_CLEAR(clear_module_state->__pyx_tuple__16); return 0; } #endif /* #### Code section: module_state_traverse ### */ #if CYTHON_USE_MODULE_STATE static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { __pyx_mstate *traverse_module_state = __pyx_mstate(m); if (!traverse_module_state) return 0; Py_VISIT(traverse_module_state->__pyx_d); Py_VISIT(traverse_module_state->__pyx_b); Py_VISIT(traverse_module_state->__pyx_cython_runtime); Py_VISIT(traverse_module_state->__pyx_empty_tuple); Py_VISIT(traverse_module_state->__pyx_empty_bytes); Py_VISIT(traverse_module_state->__pyx_empty_unicode); #ifdef __Pyx_CyFunction_USED Py_VISIT(traverse_module_state->__pyx_CyFunctionType); #endif #ifdef __Pyx_FusedFunction_USED Py_VISIT(traverse_module_state->__pyx_FusedFunctionType); #endif Py_VISIT(traverse_module_state->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container); Py_VISIT(traverse_module_state->__pyx_n_s_CategoricalDtype); Py_VISIT(traverse_module_state->__pyx_kp_s_Column_labels_must_be_strings); Py_VISIT(traverse_module_state->__pyx_n_s_DataFrame); Py_VISIT(traverse_module_state->__pyx_n_s_Float32Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_Float64Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_Int16Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_Int32Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_Int64Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_Int8Dtype); Py_VISIT(traverse_module_state->__pyx_kp_s_M8_ns); Py_VISIT(traverse_module_state->__pyx_kp_s_Non_unique_column_names_detected); Py_VISIT(traverse_module_state->__pyx_n_s_PyreadstatError); Py_VISIT(traverse_module_state->__pyx_n_s_ReadstatError); Py_VISIT(traverse_module_state->__pyx_n_s_Timestamp); Py_VISIT(traverse_module_state->__pyx_n_s_UInt16Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_UInt32Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_UInt64Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_UInt8Dtype); Py_VISIT(traverse_module_state->__pyx_n_s_UnicodeError); Py_VISIT(traverse_module_state->__pyx_kp_s_Unknown_data_format_to_insert); Py_VISIT(traverse_module_state->__pyx_kp_s_Unknown_pywriter_variable_format); Py_VISIT(traverse_module_state->__pyx_n_s__17); Py_VISIT(traverse_module_state->__pyx_n_s__18); Py_VISIT(traverse_module_state->__pyx_kp_s__2); Py_VISIT(traverse_module_state->__pyx_n_s__4); Py_VISIT(traverse_module_state->__pyx_kp_u__5); Py_VISIT(traverse_module_state->__pyx_kp_s_alignment_for_variable_s_must_be); Py_VISIT(traverse_module_state->__pyx_n_s_any); Py_VISIT(traverse_module_state->__pyx_n_s_asarray); Py_VISIT(traverse_module_state->__pyx_n_s_asm8); Py_VISIT(traverse_module_state->__pyx_n_s_astype); Py_VISIT(traverse_module_state->__pyx_n_s_calendar); Py_VISIT(traverse_module_state->__pyx_n_s_center); Py_VISIT(traverse_module_state->__pyx_kp_s_character_missing_ranges_value_g); Py_VISIT(traverse_module_state->__pyx_n_s_chr); Py_VISIT(traverse_module_state->__pyx_n_s_class_getitem); Py_VISIT(traverse_module_state->__pyx_n_s_cline_in_traceback); Py_VISIT(traverse_module_state->__pyx_kp_s_column_labels_must_be_either_lis); Py_VISIT(traverse_module_state->__pyx_n_s_columns); Py_VISIT(traverse_module_state->__pyx_n_s_combine); Py_VISIT(traverse_module_state->__pyx_n_s_copy); Py_VISIT(traverse_module_state->__pyx_n_s_core); Py_VISIT(traverse_module_state->__pyx_n_s_date); Py_VISIT(traverse_module_state->__pyx_n_s_datetime); Py_VISIT(traverse_module_state->__pyx_n_s_datetime64); Py_VISIT(traverse_module_state->__pyx_kp_s_datetime64_ms); Py_VISIT(traverse_module_state->__pyx_kp_s_datetime64_ns); Py_VISIT(traverse_module_state->__pyx_kp_s_datetime64_us); Py_VISIT(traverse_module_state->__pyx_kp_s_datetime64_us_2); Py_VISIT(traverse_module_state->__pyx_n_s_days); Py_VISIT(traverse_module_state->__pyx_kp_s_dictionaries_in_missing_ranges_m); Py_VISIT(traverse_module_state->__pyx_n_s_drop); Py_VISIT(traverse_module_state->__pyx_n_s_dropna); Py_VISIT(traverse_module_state->__pyx_n_s_dtype); Py_VISIT(traverse_module_state->__pyx_n_s_dtypes); Py_VISIT(traverse_module_state->__pyx_n_s_encode); Py_VISIT(traverse_module_state->__pyx_n_s_enumerate); Py_VISIT(traverse_module_state->__pyx_n_s_expanduser); Py_VISIT(traverse_module_state->__pyx_kp_s_file_path_could_not_be_encoded_w); Py_VISIT(traverse_module_state->__pyx_kp_s_first_argument_must_be_a_pandas); Py_VISIT(traverse_module_state->__pyx_n_s_float); Py_VISIT(traverse_module_state->__pyx_n_s_float32); Py_VISIT(traverse_module_state->__pyx_n_s_float64); Py_VISIT(traverse_module_state->__pyx_n_s_fsdecode); Py_VISIT(traverse_module_state->__pyx_n_s_fsencode); Py_VISIT(traverse_module_state->__pyx_n_s_get); Py_VISIT(traverse_module_state->__pyx_n_s_getfilesystemencoding); Py_VISIT(traverse_module_state->__pyx_n_s_hi); Py_VISIT(traverse_module_state->__pyx_n_s_iloc); Py_VISIT(traverse_module_state->__pyx_n_s_import); Py_VISIT(traverse_module_state->__pyx_n_s_initializing); Py_VISIT(traverse_module_state->__pyx_n_s_int16); Py_VISIT(traverse_module_state->__pyx_n_s_int32); Py_VISIT(traverse_module_state->__pyx_n_s_int64); Py_VISIT(traverse_module_state->__pyx_n_s_int8); Py_VISIT(traverse_module_state->__pyx_n_s_is_datetime64_any_dtype); Py_VISIT(traverse_module_state->__pyx_n_s_is_datetime64_ns_dtype); Py_VISIT(traverse_module_state->__pyx_n_s_isalpha); Py_VISIT(traverse_module_state->__pyx_n_s_isin); Py_VISIT(traverse_module_state->__pyx_n_s_isna); Py_VISIT(traverse_module_state->__pyx_n_s_items); Py_VISIT(traverse_module_state->__pyx_n_s_keys); Py_VISIT(traverse_module_state->__pyx_n_s_left); Py_VISIT(traverse_module_state->__pyx_kp_s_length_of_column_labels_must_be); Py_VISIT(traverse_module_state->__pyx_n_s_libs); Py_VISIT(traverse_module_state->__pyx_n_s_lo); Py_VISIT(traverse_module_state->__pyx_n_s_loc); Py_VISIT(traverse_module_state->__pyx_n_s_main); Py_VISIT(traverse_module_state->__pyx_kp_s_measure_for_variable_s_must_be_e); Py_VISIT(traverse_module_state->__pyx_n_s_min); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_hi_and_lo_values); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_hi_and_lo_values_2); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_max_1_discrete_nu); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_max_1_range_value); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_max_3_discrete_nu); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_max_3_string_valu); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_string_values_len); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_values_in_diction); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_ranges_values_must_be_bo); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_user_values_not_allowed); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_user_values_supports_val); Py_VISIT(traverse_module_state->__pyx_kp_s_missing_user_values_values_in_di); Py_VISIT(traverse_module_state->__pyx_n_s_name); Py_VISIT(traverse_module_state->__pyx_n_s_name_2); Py_VISIT(traverse_module_state->__pyx_n_s_nan); Py_VISIT(traverse_module_state->__pyx_n_s_nominal); Py_VISIT(traverse_module_state->__pyx_n_s_np); Py_VISIT(traverse_module_state->__pyx_n_s_nt); Py_VISIT(traverse_module_state->__pyx_kp_s_numeric_missing_ranges_value_giv); Py_VISIT(traverse_module_state->__pyx_n_s_numpy); Py_VISIT(traverse_module_state->__pyx_n_s_object); Py_VISIT(traverse_module_state->__pyx_n_s_ordinal); Py_VISIT(traverse_module_state->__pyx_n_s_os); Py_VISIT(traverse_module_state->__pyx_n_s_pandas); Py_VISIT(traverse_module_state->__pyx_n_s_pandas_api_types); Py_VISIT(traverse_module_state->__pyx_n_s_path); Py_VISIT(traverse_module_state->__pyx_kp_s_path_must_be_either_str_or_bytes); Py_VISIT(traverse_module_state->__pyx_n_s_pd); Py_VISIT(traverse_module_state->__pyx_n_s_range); Py_VISIT(traverse_module_state->__pyx_n_s_readstat_parser); Py_VISIT(traverse_module_state->__pyx_n_s_replace); Py_VISIT(traverse_module_state->__pyx_n_s_reset_index); Py_VISIT(traverse_module_state->__pyx_n_s_right); Py_VISIT(traverse_module_state->__pyx_n_s_round); Py_VISIT(traverse_module_state->__pyx_n_s_scale); Py_VISIT(traverse_module_state->__pyx_n_s_spec); Py_VISIT(traverse_module_state->__pyx_n_s_startswith); Py_VISIT(traverse_module_state->__pyx_n_s_string); Py_VISIT(traverse_module_state->__pyx_n_s_surrogateescape); Py_VISIT(traverse_module_state->__pyx_n_s_sys); Py_VISIT(traverse_module_state->__pyx_n_s_test); Py_VISIT(traverse_module_state->__pyx_n_s_time); Py_VISIT(traverse_module_state->__pyx_n_s_timegm); Py_VISIT(traverse_module_state->__pyx_n_s_timestamps); Py_VISIT(traverse_module_state->__pyx_n_s_timetuple); Py_VISIT(traverse_module_state->__pyx_n_s_timezone); Py_VISIT(traverse_module_state->__pyx_n_s_timezone_2); Py_VISIT(traverse_module_state->__pyx_n_s_tolist); Py_VISIT(traverse_module_state->__pyx_n_s_total_seconds); Py_VISIT(traverse_module_state->__pyx_n_s_tslibs); Py_VISIT(traverse_module_state->__pyx_n_s_tzinfo); Py_VISIT(traverse_module_state->__pyx_n_s_uint16); Py_VISIT(traverse_module_state->__pyx_n_s_uint32); Py_VISIT(traverse_module_state->__pyx_n_s_uint64); Py_VISIT(traverse_module_state->__pyx_n_s_uint8); Py_VISIT(traverse_module_state->__pyx_n_s_union); Py_VISIT(traverse_module_state->__pyx_n_s_unknown); Py_VISIT(traverse_module_state->__pyx_kp_s_unknown_file_format); Py_VISIT(traverse_module_state->__pyx_n_s_upper); Py_VISIT(traverse_module_state->__pyx_n_s_utc); Py_VISIT(traverse_module_state->__pyx_kp_s_utf_8); Py_VISIT(traverse_module_state->__pyx_n_s_values); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_name_s_contains_a_space); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_name_s_is_of_type_s_and); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_name_s_starts_with_an_i); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_value_labels_type_of_La); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_value_labels_type_of_Va); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_value_labels_type_of_Va_2); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_value_labels_type_of_Va_3); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_value_labels_type_of_Va_4); Py_VISIT(traverse_module_state->__pyx_kp_s_variable_value_labels_value_for); Py_VISIT(traverse_module_state->__pyx_n_s_warn); Py_VISIT(traverse_module_state->__pyx_n_s_warnings); Py_VISIT(traverse_module_state->__pyx_n_s_x); Py_VISIT(traverse_module_state->__pyx_n_s_zip); Py_VISIT(traverse_module_state->__pyx_float_1e6); Py_VISIT(traverse_module_state->__pyx_float_1e9); Py_VISIT(traverse_module_state->__pyx_int_0); Py_VISIT(traverse_module_state->__pyx_int_1); Py_VISIT(traverse_module_state->__pyx_int_65); Py_VISIT(traverse_module_state->__pyx_int_97); Py_VISIT(traverse_module_state->__pyx_int_1970); Py_VISIT(traverse_module_state->__pyx_int_neg_9223056417655); Py_VISIT(traverse_module_state->__pyx_slice_); Py_VISIT(traverse_module_state->__pyx_tuple__3); Py_VISIT(traverse_module_state->__pyx_tuple__6); Py_VISIT(traverse_module_state->__pyx_tuple__7); Py_VISIT(traverse_module_state->__pyx_tuple__8); Py_VISIT(traverse_module_state->__pyx_tuple__9); Py_VISIT(traverse_module_state->__pyx_tuple__10); Py_VISIT(traverse_module_state->__pyx_tuple__11); Py_VISIT(traverse_module_state->__pyx_tuple__12); Py_VISIT(traverse_module_state->__pyx_tuple__13); Py_VISIT(traverse_module_state->__pyx_tuple__14); Py_VISIT(traverse_module_state->__pyx_tuple__15); Py_VISIT(traverse_module_state->__pyx_tuple__16); return 0; } #endif /* #### Code section: module_state_defines ### */ #define __pyx_d __pyx_mstate_global->__pyx_d #define __pyx_b __pyx_mstate_global->__pyx_b #define __pyx_cython_runtime __pyx_mstate_global->__pyx_cython_runtime #define __pyx_empty_tuple __pyx_mstate_global->__pyx_empty_tuple #define __pyx_empty_bytes __pyx_mstate_global->__pyx_empty_bytes #define __pyx_empty_unicode __pyx_mstate_global->__pyx_empty_unicode #ifdef __Pyx_CyFunction_USED #define __pyx_CyFunctionType __pyx_mstate_global->__pyx_CyFunctionType #endif #ifdef __Pyx_FusedFunction_USED #define __pyx_FusedFunctionType __pyx_mstate_global->__pyx_FusedFunctionType #endif #ifdef __Pyx_Generator_USED #define __pyx_GeneratorType __pyx_mstate_global->__pyx_GeneratorType #endif #ifdef __Pyx_IterableCoroutine_USED #define __pyx_IterableCoroutineType __pyx_mstate_global->__pyx_IterableCoroutineType #endif #ifdef __Pyx_Coroutine_USED #define __pyx_CoroutineAwaitType __pyx_mstate_global->__pyx_CoroutineAwaitType #endif #ifdef __Pyx_Coroutine_USED #define __pyx_CoroutineType __pyx_mstate_global->__pyx_CoroutineType #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #define __pyx_ptype_10pyreadstat_16_readstat_parser_data_container __pyx_mstate_global->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container #if CYTHON_USE_MODULE_STATE #endif #define __pyx_n_s_CategoricalDtype __pyx_mstate_global->__pyx_n_s_CategoricalDtype #define __pyx_kp_s_Column_labels_must_be_strings __pyx_mstate_global->__pyx_kp_s_Column_labels_must_be_strings #define __pyx_n_s_DataFrame __pyx_mstate_global->__pyx_n_s_DataFrame #define __pyx_n_s_Float32Dtype __pyx_mstate_global->__pyx_n_s_Float32Dtype #define __pyx_n_s_Float64Dtype __pyx_mstate_global->__pyx_n_s_Float64Dtype #define __pyx_n_s_Int16Dtype __pyx_mstate_global->__pyx_n_s_Int16Dtype #define __pyx_n_s_Int32Dtype __pyx_mstate_global->__pyx_n_s_Int32Dtype #define __pyx_n_s_Int64Dtype __pyx_mstate_global->__pyx_n_s_Int64Dtype #define __pyx_n_s_Int8Dtype __pyx_mstate_global->__pyx_n_s_Int8Dtype #define __pyx_kp_s_M8_ns __pyx_mstate_global->__pyx_kp_s_M8_ns #define __pyx_kp_s_Non_unique_column_names_detected __pyx_mstate_global->__pyx_kp_s_Non_unique_column_names_detected #define __pyx_n_s_PyreadstatError __pyx_mstate_global->__pyx_n_s_PyreadstatError #define __pyx_n_s_ReadstatError __pyx_mstate_global->__pyx_n_s_ReadstatError #define __pyx_n_s_Timestamp __pyx_mstate_global->__pyx_n_s_Timestamp #define __pyx_n_s_UInt16Dtype __pyx_mstate_global->__pyx_n_s_UInt16Dtype #define __pyx_n_s_UInt32Dtype __pyx_mstate_global->__pyx_n_s_UInt32Dtype #define __pyx_n_s_UInt64Dtype __pyx_mstate_global->__pyx_n_s_UInt64Dtype #define __pyx_n_s_UInt8Dtype __pyx_mstate_global->__pyx_n_s_UInt8Dtype #define __pyx_n_s_UnicodeError __pyx_mstate_global->__pyx_n_s_UnicodeError #define __pyx_kp_s_Unknown_data_format_to_insert __pyx_mstate_global->__pyx_kp_s_Unknown_data_format_to_insert #define __pyx_kp_s_Unknown_pywriter_variable_format __pyx_mstate_global->__pyx_kp_s_Unknown_pywriter_variable_format #define __pyx_n_s__17 __pyx_mstate_global->__pyx_n_s__17 #define __pyx_n_s__18 __pyx_mstate_global->__pyx_n_s__18 #define __pyx_kp_s__2 __pyx_mstate_global->__pyx_kp_s__2 #define __pyx_n_s__4 __pyx_mstate_global->__pyx_n_s__4 #define __pyx_kp_u__5 __pyx_mstate_global->__pyx_kp_u__5 #define __pyx_kp_s_alignment_for_variable_s_must_be __pyx_mstate_global->__pyx_kp_s_alignment_for_variable_s_must_be #define __pyx_n_s_any __pyx_mstate_global->__pyx_n_s_any #define __pyx_n_s_asarray __pyx_mstate_global->__pyx_n_s_asarray #define __pyx_n_s_asm8 __pyx_mstate_global->__pyx_n_s_asm8 #define __pyx_n_s_astype __pyx_mstate_global->__pyx_n_s_astype #define __pyx_n_s_calendar __pyx_mstate_global->__pyx_n_s_calendar #define __pyx_n_s_center __pyx_mstate_global->__pyx_n_s_center #define __pyx_kp_s_character_missing_ranges_value_g __pyx_mstate_global->__pyx_kp_s_character_missing_ranges_value_g #define __pyx_n_s_chr __pyx_mstate_global->__pyx_n_s_chr #define __pyx_n_s_class_getitem __pyx_mstate_global->__pyx_n_s_class_getitem #define __pyx_n_s_cline_in_traceback __pyx_mstate_global->__pyx_n_s_cline_in_traceback #define __pyx_kp_s_column_labels_must_be_either_lis __pyx_mstate_global->__pyx_kp_s_column_labels_must_be_either_lis #define __pyx_n_s_columns __pyx_mstate_global->__pyx_n_s_columns #define __pyx_n_s_combine __pyx_mstate_global->__pyx_n_s_combine #define __pyx_n_s_copy __pyx_mstate_global->__pyx_n_s_copy #define __pyx_n_s_core __pyx_mstate_global->__pyx_n_s_core #define __pyx_n_s_date __pyx_mstate_global->__pyx_n_s_date #define __pyx_n_s_datetime __pyx_mstate_global->__pyx_n_s_datetime #define __pyx_n_s_datetime64 __pyx_mstate_global->__pyx_n_s_datetime64 #define __pyx_kp_s_datetime64_ms __pyx_mstate_global->__pyx_kp_s_datetime64_ms #define __pyx_kp_s_datetime64_ns __pyx_mstate_global->__pyx_kp_s_datetime64_ns #define __pyx_kp_s_datetime64_us __pyx_mstate_global->__pyx_kp_s_datetime64_us #define __pyx_kp_s_datetime64_us_2 __pyx_mstate_global->__pyx_kp_s_datetime64_us_2 #define __pyx_n_s_days __pyx_mstate_global->__pyx_n_s_days #define __pyx_kp_s_dictionaries_in_missing_ranges_m __pyx_mstate_global->__pyx_kp_s_dictionaries_in_missing_ranges_m #define __pyx_n_s_drop __pyx_mstate_global->__pyx_n_s_drop #define __pyx_n_s_dropna __pyx_mstate_global->__pyx_n_s_dropna #define __pyx_n_s_dtype __pyx_mstate_global->__pyx_n_s_dtype #define __pyx_n_s_dtypes __pyx_mstate_global->__pyx_n_s_dtypes #define __pyx_n_s_encode __pyx_mstate_global->__pyx_n_s_encode #define __pyx_n_s_enumerate __pyx_mstate_global->__pyx_n_s_enumerate #define __pyx_n_s_expanduser __pyx_mstate_global->__pyx_n_s_expanduser #define __pyx_kp_s_file_path_could_not_be_encoded_w __pyx_mstate_global->__pyx_kp_s_file_path_could_not_be_encoded_w #define __pyx_kp_s_first_argument_must_be_a_pandas __pyx_mstate_global->__pyx_kp_s_first_argument_must_be_a_pandas #define __pyx_n_s_float __pyx_mstate_global->__pyx_n_s_float #define __pyx_n_s_float32 __pyx_mstate_global->__pyx_n_s_float32 #define __pyx_n_s_float64 __pyx_mstate_global->__pyx_n_s_float64 #define __pyx_n_s_fsdecode __pyx_mstate_global->__pyx_n_s_fsdecode #define __pyx_n_s_fsencode __pyx_mstate_global->__pyx_n_s_fsencode #define __pyx_n_s_get __pyx_mstate_global->__pyx_n_s_get #define __pyx_n_s_getfilesystemencoding __pyx_mstate_global->__pyx_n_s_getfilesystemencoding #define __pyx_n_s_hi __pyx_mstate_global->__pyx_n_s_hi #define __pyx_n_s_iloc __pyx_mstate_global->__pyx_n_s_iloc #define __pyx_n_s_import __pyx_mstate_global->__pyx_n_s_import #define __pyx_n_s_initializing __pyx_mstate_global->__pyx_n_s_initializing #define __pyx_n_s_int16 __pyx_mstate_global->__pyx_n_s_int16 #define __pyx_n_s_int32 __pyx_mstate_global->__pyx_n_s_int32 #define __pyx_n_s_int64 __pyx_mstate_global->__pyx_n_s_int64 #define __pyx_n_s_int8 __pyx_mstate_global->__pyx_n_s_int8 #define __pyx_n_s_is_datetime64_any_dtype __pyx_mstate_global->__pyx_n_s_is_datetime64_any_dtype #define __pyx_n_s_is_datetime64_ns_dtype __pyx_mstate_global->__pyx_n_s_is_datetime64_ns_dtype #define __pyx_n_s_isalpha __pyx_mstate_global->__pyx_n_s_isalpha #define __pyx_n_s_isin __pyx_mstate_global->__pyx_n_s_isin #define __pyx_n_s_isna __pyx_mstate_global->__pyx_n_s_isna #define __pyx_n_s_items __pyx_mstate_global->__pyx_n_s_items #define __pyx_n_s_keys __pyx_mstate_global->__pyx_n_s_keys #define __pyx_n_s_left __pyx_mstate_global->__pyx_n_s_left #define __pyx_kp_s_length_of_column_labels_must_be __pyx_mstate_global->__pyx_kp_s_length_of_column_labels_must_be #define __pyx_n_s_libs __pyx_mstate_global->__pyx_n_s_libs #define __pyx_n_s_lo __pyx_mstate_global->__pyx_n_s_lo #define __pyx_n_s_loc __pyx_mstate_global->__pyx_n_s_loc #define __pyx_n_s_main __pyx_mstate_global->__pyx_n_s_main #define __pyx_kp_s_measure_for_variable_s_must_be_e __pyx_mstate_global->__pyx_kp_s_measure_for_variable_s_must_be_e #define __pyx_n_s_min __pyx_mstate_global->__pyx_n_s_min #define __pyx_kp_s_missing_ranges_hi_and_lo_values __pyx_mstate_global->__pyx_kp_s_missing_ranges_hi_and_lo_values #define __pyx_kp_s_missing_ranges_hi_and_lo_values_2 __pyx_mstate_global->__pyx_kp_s_missing_ranges_hi_and_lo_values_2 #define __pyx_kp_s_missing_ranges_max_1_discrete_nu __pyx_mstate_global->__pyx_kp_s_missing_ranges_max_1_discrete_nu #define __pyx_kp_s_missing_ranges_max_1_range_value __pyx_mstate_global->__pyx_kp_s_missing_ranges_max_1_range_value #define __pyx_kp_s_missing_ranges_max_3_discrete_nu __pyx_mstate_global->__pyx_kp_s_missing_ranges_max_3_discrete_nu #define __pyx_kp_s_missing_ranges_max_3_string_valu __pyx_mstate_global->__pyx_kp_s_missing_ranges_max_3_string_valu #define __pyx_kp_s_missing_ranges_string_values_len __pyx_mstate_global->__pyx_kp_s_missing_ranges_string_values_len #define __pyx_kp_s_missing_ranges_values_in_diction __pyx_mstate_global->__pyx_kp_s_missing_ranges_values_in_diction #define __pyx_kp_s_missing_ranges_values_must_be_bo __pyx_mstate_global->__pyx_kp_s_missing_ranges_values_must_be_bo #define __pyx_kp_s_missing_user_values_not_allowed __pyx_mstate_global->__pyx_kp_s_missing_user_values_not_allowed #define __pyx_kp_s_missing_user_values_supports_val __pyx_mstate_global->__pyx_kp_s_missing_user_values_supports_val #define __pyx_kp_s_missing_user_values_values_in_di __pyx_mstate_global->__pyx_kp_s_missing_user_values_values_in_di #define __pyx_n_s_name __pyx_mstate_global->__pyx_n_s_name #define __pyx_n_s_name_2 __pyx_mstate_global->__pyx_n_s_name_2 #define __pyx_n_s_nan __pyx_mstate_global->__pyx_n_s_nan #define __pyx_n_s_nominal __pyx_mstate_global->__pyx_n_s_nominal #define __pyx_n_s_np __pyx_mstate_global->__pyx_n_s_np #define __pyx_n_s_nt __pyx_mstate_global->__pyx_n_s_nt #define __pyx_kp_s_numeric_missing_ranges_value_giv __pyx_mstate_global->__pyx_kp_s_numeric_missing_ranges_value_giv #define __pyx_n_s_numpy __pyx_mstate_global->__pyx_n_s_numpy #define __pyx_n_s_object __pyx_mstate_global->__pyx_n_s_object #define __pyx_n_s_ordinal __pyx_mstate_global->__pyx_n_s_ordinal #define __pyx_n_s_os __pyx_mstate_global->__pyx_n_s_os #define __pyx_n_s_pandas __pyx_mstate_global->__pyx_n_s_pandas #define __pyx_n_s_pandas_api_types __pyx_mstate_global->__pyx_n_s_pandas_api_types #define __pyx_n_s_path __pyx_mstate_global->__pyx_n_s_path #define __pyx_kp_s_path_must_be_either_str_or_bytes __pyx_mstate_global->__pyx_kp_s_path_must_be_either_str_or_bytes #define __pyx_n_s_pd __pyx_mstate_global->__pyx_n_s_pd #define __pyx_n_s_range __pyx_mstate_global->__pyx_n_s_range #define __pyx_n_s_readstat_parser __pyx_mstate_global->__pyx_n_s_readstat_parser #define __pyx_n_s_replace __pyx_mstate_global->__pyx_n_s_replace #define __pyx_n_s_reset_index __pyx_mstate_global->__pyx_n_s_reset_index #define __pyx_n_s_right __pyx_mstate_global->__pyx_n_s_right #define __pyx_n_s_round __pyx_mstate_global->__pyx_n_s_round #define __pyx_n_s_scale __pyx_mstate_global->__pyx_n_s_scale #define __pyx_n_s_spec __pyx_mstate_global->__pyx_n_s_spec #define __pyx_n_s_startswith __pyx_mstate_global->__pyx_n_s_startswith #define __pyx_n_s_string __pyx_mstate_global->__pyx_n_s_string #define __pyx_n_s_surrogateescape __pyx_mstate_global->__pyx_n_s_surrogateescape #define __pyx_n_s_sys __pyx_mstate_global->__pyx_n_s_sys #define __pyx_n_s_test __pyx_mstate_global->__pyx_n_s_test #define __pyx_n_s_time __pyx_mstate_global->__pyx_n_s_time #define __pyx_n_s_timegm __pyx_mstate_global->__pyx_n_s_timegm #define __pyx_n_s_timestamps __pyx_mstate_global->__pyx_n_s_timestamps #define __pyx_n_s_timetuple __pyx_mstate_global->__pyx_n_s_timetuple #define __pyx_n_s_timezone __pyx_mstate_global->__pyx_n_s_timezone #define __pyx_n_s_timezone_2 __pyx_mstate_global->__pyx_n_s_timezone_2 #define __pyx_n_s_tolist __pyx_mstate_global->__pyx_n_s_tolist #define __pyx_n_s_total_seconds __pyx_mstate_global->__pyx_n_s_total_seconds #define __pyx_n_s_tslibs __pyx_mstate_global->__pyx_n_s_tslibs #define __pyx_n_s_tzinfo __pyx_mstate_global->__pyx_n_s_tzinfo #define __pyx_n_s_uint16 __pyx_mstate_global->__pyx_n_s_uint16 #define __pyx_n_s_uint32 __pyx_mstate_global->__pyx_n_s_uint32 #define __pyx_n_s_uint64 __pyx_mstate_global->__pyx_n_s_uint64 #define __pyx_n_s_uint8 __pyx_mstate_global->__pyx_n_s_uint8 #define __pyx_n_s_union __pyx_mstate_global->__pyx_n_s_union #define __pyx_n_s_unknown __pyx_mstate_global->__pyx_n_s_unknown #define __pyx_kp_s_unknown_file_format __pyx_mstate_global->__pyx_kp_s_unknown_file_format #define __pyx_n_s_upper __pyx_mstate_global->__pyx_n_s_upper #define __pyx_n_s_utc __pyx_mstate_global->__pyx_n_s_utc #define __pyx_kp_s_utf_8 __pyx_mstate_global->__pyx_kp_s_utf_8 #define __pyx_n_s_values __pyx_mstate_global->__pyx_n_s_values #define __pyx_kp_s_variable_name_s_contains_a_space __pyx_mstate_global->__pyx_kp_s_variable_name_s_contains_a_space #define __pyx_kp_s_variable_name_s_is_of_type_s_and __pyx_mstate_global->__pyx_kp_s_variable_name_s_is_of_type_s_and #define __pyx_kp_s_variable_name_s_starts_with_an_i __pyx_mstate_global->__pyx_kp_s_variable_name_s_starts_with_an_i #define __pyx_kp_s_variable_value_labels_type_of_La __pyx_mstate_global->__pyx_kp_s_variable_value_labels_type_of_La #define __pyx_kp_s_variable_value_labels_type_of_Va __pyx_mstate_global->__pyx_kp_s_variable_value_labels_type_of_Va #define __pyx_kp_s_variable_value_labels_type_of_Va_2 __pyx_mstate_global->__pyx_kp_s_variable_value_labels_type_of_Va_2 #define __pyx_kp_s_variable_value_labels_type_of_Va_3 __pyx_mstate_global->__pyx_kp_s_variable_value_labels_type_of_Va_3 #define __pyx_kp_s_variable_value_labels_type_of_Va_4 __pyx_mstate_global->__pyx_kp_s_variable_value_labels_type_of_Va_4 #define __pyx_kp_s_variable_value_labels_value_for __pyx_mstate_global->__pyx_kp_s_variable_value_labels_value_for #define __pyx_n_s_warn __pyx_mstate_global->__pyx_n_s_warn #define __pyx_n_s_warnings __pyx_mstate_global->__pyx_n_s_warnings #define __pyx_n_s_x __pyx_mstate_global->__pyx_n_s_x #define __pyx_n_s_zip __pyx_mstate_global->__pyx_n_s_zip #define __pyx_float_1e6 __pyx_mstate_global->__pyx_float_1e6 #define __pyx_float_1e9 __pyx_mstate_global->__pyx_float_1e9 #define __pyx_int_0 __pyx_mstate_global->__pyx_int_0 #define __pyx_int_1 __pyx_mstate_global->__pyx_int_1 #define __pyx_int_65 __pyx_mstate_global->__pyx_int_65 #define __pyx_int_97 __pyx_mstate_global->__pyx_int_97 #define __pyx_int_1970 __pyx_mstate_global->__pyx_int_1970 #define __pyx_int_neg_9223056417655 __pyx_mstate_global->__pyx_int_neg_9223056417655 #define __pyx_slice_ __pyx_mstate_global->__pyx_slice_ #define __pyx_tuple__3 __pyx_mstate_global->__pyx_tuple__3 #define __pyx_tuple__6 __pyx_mstate_global->__pyx_tuple__6 #define __pyx_tuple__7 __pyx_mstate_global->__pyx_tuple__7 #define __pyx_tuple__8 __pyx_mstate_global->__pyx_tuple__8 #define __pyx_tuple__9 __pyx_mstate_global->__pyx_tuple__9 #define __pyx_tuple__10 __pyx_mstate_global->__pyx_tuple__10 #define __pyx_tuple__11 __pyx_mstate_global->__pyx_tuple__11 #define __pyx_tuple__12 __pyx_mstate_global->__pyx_tuple__12 #define __pyx_tuple__13 __pyx_mstate_global->__pyx_tuple__13 #define __pyx_tuple__14 __pyx_mstate_global->__pyx_tuple__14 #define __pyx_tuple__15 __pyx_mstate_global->__pyx_tuple__15 #define __pyx_tuple__16 __pyx_mstate_global->__pyx_tuple__16 /* #### Code section: module_code ### */ /* "pyreadstat/_readstat_writer.pyx":62 * * * cdef double convert_datetimelike_to_number(dst_file_format file_format, pywriter_variable_type curtype, object curval) except *: # <<<<<<<<<<<<<< * """ * converts a datime like python/pandas object to a float */ static double __pyx_f_10pyreadstat_16_readstat_writer_convert_datetimelike_to_number(__pyx_t_10pyreadstat_16_readstat_writer_dst_file_format __pyx_v_file_format, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __pyx_v_curtype, PyObject *__pyx_v_curval) { double __pyx_v_offset_days; double __pyx_v_tstamp; double __pyx_v_offset_secs; PyObject *__pyx_v_days = NULL; PyObject *__pyx_v_tdelta = NULL; double __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; int __pyx_t_9; double __pyx_t_10; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("convert_datetimelike_to_number", 0); __Pyx_INCREF(__pyx_v_curval); /* "pyreadstat/_readstat_writer.pyx":69 * cdef double offset_days, tstamp * * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * offset_days = spss_offset_days * offset_secs = spss_offset_secs */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAV: case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_POR: /* "pyreadstat/_readstat_writer.pyx":70 * * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: * offset_days = spss_offset_days # <<<<<<<<<<<<<< * offset_secs = spss_offset_secs * else: */ __pyx_v_offset_days = __pyx_v_10pyreadstat_16_readstat_writer_spss_offset_days; /* "pyreadstat/_readstat_writer.pyx":71 * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: * offset_days = spss_offset_days * offset_secs = spss_offset_secs # <<<<<<<<<<<<<< * else: * offset_days = sas_offset_days */ __pyx_v_offset_secs = __pyx_v_10pyreadstat_16_readstat_writer_spss_offset_secs; /* "pyreadstat/_readstat_writer.pyx":69 * cdef double offset_days, tstamp * * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * offset_days = spss_offset_days * offset_secs = spss_offset_secs */ break; default: /* "pyreadstat/_readstat_writer.pyx":73 * offset_secs = spss_offset_secs * else: * offset_days = sas_offset_days # <<<<<<<<<<<<<< * offset_secs = sas_offset_secs * */ __pyx_v_offset_days = __pyx_v_10pyreadstat_16_readstat_writer_sas_offset_days; /* "pyreadstat/_readstat_writer.pyx":74 * else: * offset_days = sas_offset_days * offset_secs = sas_offset_secs # <<<<<<<<<<<<<< * * if curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS: */ __pyx_v_offset_secs = __pyx_v_10pyreadstat_16_readstat_writer_sas_offset_secs; break; } /* "pyreadstat/_readstat_writer.pyx":76 * offset_secs = sas_offset_secs * * if curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS: # <<<<<<<<<<<<<< * # get timestamp in seconds * if type(curval) == pd._libs.tslibs.timestamps.Timestamp: */ switch (__pyx_v_curtype) { case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS: /* "pyreadstat/_readstat_writer.pyx":78 * if curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS: * # get timestamp in seconds * if type(curval) == pd._libs.tslibs.timestamps.Timestamp: # <<<<<<<<<<<<<< * curval = curval.asm8 * */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_libs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tslibs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timestamps); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Timestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_curval)), __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":79 * # get timestamp in seconds * if type(curval) == pd._libs.tslibs.timestamps.Timestamp: * curval = curval.asm8 # <<<<<<<<<<<<<< * * if type(curval) == datetime.datetime: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_asm8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_curval, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":78 * if curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS: * # get timestamp in seconds * if type(curval) == pd._libs.tslibs.timestamps.Timestamp: # <<<<<<<<<<<<<< * curval = curval.asm8 * */ } /* "pyreadstat/_readstat_writer.pyx":81 * curval = curval.asm8 * * if type(curval) == datetime.datetime: # <<<<<<<<<<<<<< * #tstamp = curval.replace(tzinfo=timezone.utc).timestamp() # works only in python 3 * tstamp = calendar.timegm(curval.replace(tzinfo=_timezone.utc).timetuple()) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_curval)), __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":83 * if type(curval) == datetime.datetime: * #tstamp = curval.replace(tzinfo=timezone.utc).timestamp() # works only in python 3 * tstamp = calendar.timegm(curval.replace(tzinfo=_timezone.utc).timetuple()) # <<<<<<<<<<<<<< * elif type(curval) == np.datetime64: * if curval.dtype.name == "datetime64[ns]": */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_calendar); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_timegm); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_replace); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_timezone); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_utc); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_tzinfo, __pyx_t_8) < 0) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_timetuple); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_1}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_tstamp = __pyx_t_10; /* "pyreadstat/_readstat_writer.pyx":81 * curval = curval.asm8 * * if type(curval) == datetime.datetime: # <<<<<<<<<<<<<< * #tstamp = curval.replace(tzinfo=timezone.utc).timestamp() # works only in python 3 * tstamp = calendar.timegm(curval.replace(tzinfo=_timezone.utc).timetuple()) */ goto __pyx_L4; } /* "pyreadstat/_readstat_writer.pyx":84 * #tstamp = curval.replace(tzinfo=timezone.utc).timestamp() # works only in python 3 * tstamp = calendar.timegm(curval.replace(tzinfo=_timezone.utc).timetuple()) * elif type(curval) == np.datetime64: # <<<<<<<<<<<<<< * if curval.dtype.name == "datetime64[ns]": * tstamp = round(curval.astype(float)/1e9) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_datetime64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_curval)), __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":85 * tstamp = calendar.timegm(curval.replace(tzinfo=_timezone.utc).timetuple()) * elif type(curval) == np.datetime64: * if curval.dtype.name == "datetime64[ns]": # <<<<<<<<<<<<<< * tstamp = round(curval.astype(float)/1e9) * elif curval.dtype.name == "datetime64[us]": */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_kp_s_datetime64_ns, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 85, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":86 * elif type(curval) == np.datetime64: * if curval.dtype.name == "datetime64[ns]": * tstamp = round(curval.astype(float)/1e9) # <<<<<<<<<<<<<< * elif curval.dtype.name == "datetime64[us]": * tstamp = round(curval.astype(float)/1e6) */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, ((PyObject *)(&PyFloat_Type))}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_tstamp = round((((double)__pyx_t_10) / 1e9)); /* "pyreadstat/_readstat_writer.pyx":85 * tstamp = calendar.timegm(curval.replace(tzinfo=_timezone.utc).timetuple()) * elif type(curval) == np.datetime64: * if curval.dtype.name == "datetime64[ns]": # <<<<<<<<<<<<<< * tstamp = round(curval.astype(float)/1e9) * elif curval.dtype.name == "datetime64[us]": */ goto __pyx_L5; } /* "pyreadstat/_readstat_writer.pyx":87 * if curval.dtype.name == "datetime64[ns]": * tstamp = round(curval.astype(float)/1e9) * elif curval.dtype.name == "datetime64[us]": # <<<<<<<<<<<<<< * tstamp = round(curval.astype(float)/1e6) * elif curval.dtype.name == "datetime64[ms]": */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_kp_s_datetime64_us, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 87, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":88 * tstamp = round(curval.astype(float)/1e9) * elif curval.dtype.name == "datetime64[us]": * tstamp = round(curval.astype(float)/1e6) # <<<<<<<<<<<<<< * elif curval.dtype.name == "datetime64[ms]": * tstamp = round(curval.astype(float)/1e3) */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, ((PyObject *)(&PyFloat_Type))}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_tstamp = round((((double)__pyx_t_10) / 1e6)); /* "pyreadstat/_readstat_writer.pyx":87 * if curval.dtype.name == "datetime64[ns]": * tstamp = round(curval.astype(float)/1e9) * elif curval.dtype.name == "datetime64[us]": # <<<<<<<<<<<<<< * tstamp = round(curval.astype(float)/1e6) * elif curval.dtype.name == "datetime64[ms]": */ goto __pyx_L5; } /* "pyreadstat/_readstat_writer.pyx":89 * elif curval.dtype.name == "datetime64[us]": * tstamp = round(curval.astype(float)/1e6) * elif curval.dtype.name == "datetime64[ms]": # <<<<<<<<<<<<<< * tstamp = round(curval.astype(float)/1e3) * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_kp_s_datetime64_ms, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 89, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":90 * tstamp = round(curval.astype(float)/1e6) * elif curval.dtype.name == "datetime64[ms]": * tstamp = round(curval.astype(float)/1e3) # <<<<<<<<<<<<<< * * tstamp += offset_secs */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, ((PyObject *)(&PyFloat_Type))}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_tstamp = round((((double)__pyx_t_10) / 1e3)); /* "pyreadstat/_readstat_writer.pyx":89 * elif curval.dtype.name == "datetime64[us]": * tstamp = round(curval.astype(float)/1e6) * elif curval.dtype.name == "datetime64[ms]": # <<<<<<<<<<<<<< * tstamp = round(curval.astype(float)/1e3) * */ } __pyx_L5:; /* "pyreadstat/_readstat_writer.pyx":84 * #tstamp = curval.replace(tzinfo=timezone.utc).timestamp() # works only in python 3 * tstamp = calendar.timegm(curval.replace(tzinfo=_timezone.utc).timetuple()) * elif type(curval) == np.datetime64: # <<<<<<<<<<<<<< * if curval.dtype.name == "datetime64[ns]": * tstamp = round(curval.astype(float)/1e9) */ } __pyx_L4:; /* "pyreadstat/_readstat_writer.pyx":92 * tstamp = round(curval.astype(float)/1e3) * * tstamp += offset_secs # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * # stata stores in milliseconds */ __pyx_v_tstamp = (__pyx_v_tstamp + __pyx_v_offset_secs); /* "pyreadstat/_readstat_writer.pyx":93 * * tstamp += offset_secs * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * # stata stores in milliseconds * tstamp *= 1000 */ __pyx_t_3 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA); if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":95 * if file_format == FILE_FORMAT_DTA: * # stata stores in milliseconds * tstamp *= 1000 # <<<<<<<<<<<<<< * * elif curtype == PYWRITER_DATE: */ __pyx_v_tstamp = (__pyx_v_tstamp * 1000.0); /* "pyreadstat/_readstat_writer.pyx":93 * * tstamp += offset_secs * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * # stata stores in milliseconds * tstamp *= 1000 */ } /* "pyreadstat/_readstat_writer.pyx":76 * offset_secs = sas_offset_secs * * if curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS: # <<<<<<<<<<<<<< * # get timestamp in seconds * if type(curval) == pd._libs.tslibs.timestamps.Timestamp: */ break; case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE: /* "pyreadstat/_readstat_writer.pyx":98 * * elif curtype == PYWRITER_DATE: * if type(curval) == datetime.date: # <<<<<<<<<<<<<< * days = curval - date_0 * tstamp = days.days */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_curval)), __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":99 * elif curtype == PYWRITER_DATE: * if type(curval) == datetime.date: * days = curval - date_0 # <<<<<<<<<<<<<< * tstamp = days.days * tstamp += offset_days */ __pyx_t_4 = PyNumber_Subtract(__pyx_v_curval, __pyx_v_10pyreadstat_16_readstat_writer_date_0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_days = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":100 * if type(curval) == datetime.date: * days = curval - date_0 * tstamp = days.days # <<<<<<<<<<<<<< * tstamp += offset_days * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_days, __pyx_n_s_days); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_tstamp = __pyx_t_10; /* "pyreadstat/_readstat_writer.pyx":101 * days = curval - date_0 * tstamp = days.days * tstamp += offset_days # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: * # spss stores in seconds */ __pyx_v_tstamp = (__pyx_v_tstamp + __pyx_v_offset_days); /* "pyreadstat/_readstat_writer.pyx":102 * tstamp = days.days * tstamp += offset_days * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * # spss stores in seconds * tstamp *= 86400 */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAV: case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_POR: /* "pyreadstat/_readstat_writer.pyx":104 * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: * # spss stores in seconds * tstamp *= 86400 # <<<<<<<<<<<<<< * * elif curtype == PYWRITER_TIME: */ __pyx_v_tstamp = (__pyx_v_tstamp * 86400.0); /* "pyreadstat/_readstat_writer.pyx":102 * tstamp = days.days * tstamp += offset_days * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * # spss stores in seconds * tstamp *= 86400 */ break; default: break; } /* "pyreadstat/_readstat_writer.pyx":98 * * elif curtype == PYWRITER_DATE: * if type(curval) == datetime.date: # <<<<<<<<<<<<<< * days = curval - date_0 * tstamp = days.days */ } /* "pyreadstat/_readstat_writer.pyx":97 * tstamp *= 1000 * * elif curtype == PYWRITER_DATE: # <<<<<<<<<<<<<< * if type(curval) == datetime.date: * days = curval - date_0 */ break; case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME: /* "pyreadstat/_readstat_writer.pyx":107 * * elif curtype == PYWRITER_TIME: * if type(curval) == datetime.time: # <<<<<<<<<<<<<< * tdelta = datetime.datetime.combine(datetime.date.min, curval) - datetime.datetime.min * tstamp = tdelta.total_seconds() */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_curval)), __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":108 * elif curtype == PYWRITER_TIME: * if type(curval) == datetime.time: * tdelta = datetime.datetime.combine(datetime.date.min, curval) - datetime.datetime.min # <<<<<<<<<<<<<< * tstamp = tdelta.total_seconds() * #tstamp += offset * 86400 */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_combine); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_date); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_min); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_1, __pyx_v_curval}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 2+__pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_min); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Subtract(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_tdelta = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":109 * if type(curval) == datetime.time: * tdelta = datetime.datetime.combine(datetime.date.min, curval) - datetime.datetime.min * tstamp = tdelta.total_seconds() # <<<<<<<<<<<<<< * #tstamp += offset * 86400 * if file_format == FILE_FORMAT_DTA: */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_tdelta, __pyx_n_s_total_seconds); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_tstamp = __pyx_t_10; /* "pyreadstat/_readstat_writer.pyx":111 * tstamp = tdelta.total_seconds() * #tstamp += offset * 86400 * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * # stata stores in milliseconds * tstamp *= 1000 */ __pyx_t_3 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA); if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":113 * if file_format == FILE_FORMAT_DTA: * # stata stores in milliseconds * tstamp *= 1000 # <<<<<<<<<<<<<< * * return tstamp */ __pyx_v_tstamp = (__pyx_v_tstamp * 1000.0); /* "pyreadstat/_readstat_writer.pyx":111 * tstamp = tdelta.total_seconds() * #tstamp += offset * 86400 * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * # stata stores in milliseconds * tstamp *= 1000 */ } /* "pyreadstat/_readstat_writer.pyx":107 * * elif curtype == PYWRITER_TIME: * if type(curval) == datetime.time: # <<<<<<<<<<<<<< * tdelta = datetime.datetime.combine(datetime.date.min, curval) - datetime.datetime.min * tstamp = tdelta.total_seconds() */ } /* "pyreadstat/_readstat_writer.pyx":106 * tstamp *= 86400 * * elif curtype == PYWRITER_TIME: # <<<<<<<<<<<<<< * if type(curval) == datetime.time: * tdelta = datetime.datetime.combine(datetime.date.min, curval) - datetime.datetime.min */ break; default: break; } /* "pyreadstat/_readstat_writer.pyx":115 * tstamp *= 1000 * * return tstamp # <<<<<<<<<<<<<< * * cdef char * get_datetimelike_format_for_readstat(dst_file_format file_format, pywriter_variable_type curtype): */ __pyx_r = __pyx_v_tstamp; goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":62 * * * cdef double convert_datetimelike_to_number(dst_file_format file_format, pywriter_variable_type curtype, object curval) except *: # <<<<<<<<<<<<<< * """ * converts a datime like python/pandas object to a float */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("pyreadstat._readstat_writer.convert_datetimelike_to_number", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_days); __Pyx_XDECREF(__pyx_v_tdelta); __Pyx_XDECREF(__pyx_v_curval); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":117 * return tstamp * * cdef char * get_datetimelike_format_for_readstat(dst_file_format file_format, pywriter_variable_type curtype): # <<<<<<<<<<<<<< * """ * gives back a string with the format of the variable (according to the final application) to be used by readstat */ static char *__pyx_f_10pyreadstat_16_readstat_writer_get_datetimelike_format_for_readstat(__pyx_t_10pyreadstat_16_readstat_writer_dst_file_format __pyx_v_file_format, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __pyx_v_curtype) { char *__pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_datetimelike_format_for_readstat", 1); /* "pyreadstat/_readstat_writer.pyx":122 * """ * * if curtype == PYWRITER_DATE: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * return "%td" */ switch (__pyx_v_curtype) { case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE: /* "pyreadstat/_readstat_writer.pyx":123 * * if curtype == PYWRITER_DATE: * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * return "%td" * #elif file_format == FILE_FORMAT_SAV: */ __pyx_t_1 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA); if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":124 * if curtype == PYWRITER_DATE: * if file_format == FILE_FORMAT_DTA: * return "%td" # <<<<<<<<<<<<<< * #elif file_format == FILE_FORMAT_SAV: * # return "DATE11" */ __pyx_r = ((char *)"%td"); goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":123 * * if curtype == PYWRITER_DATE: * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * return "%td" * #elif file_format == FILE_FORMAT_SAV: */ } /* "pyreadstat/_readstat_writer.pyx":128 * # return "DATE11" * else: * return "DATE" # <<<<<<<<<<<<<< * elif curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: * if file_format == FILE_FORMAT_DTA: */ /*else*/ { __pyx_r = ((char *)"DATE"); goto __pyx_L0; } /* "pyreadstat/_readstat_writer.pyx":122 * """ * * if curtype == PYWRITER_DATE: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * return "%td" */ break; case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME: /* "pyreadstat/_readstat_writer.pyx":129 * else: * return "DATE" * elif curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * return "%tc" */ case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US: /* "pyreadstat/_readstat_writer.pyx":130 * return "DATE" * elif curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * return "%tc" * #elif file_format == FILE_FORMAT_SAV: */ __pyx_t_1 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA); if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":131 * elif curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: * if file_format == FILE_FORMAT_DTA: * return "%tc" # <<<<<<<<<<<<<< * #elif file_format == FILE_FORMAT_SAV: * # return "DATETIME20" */ __pyx_r = ((char *)"%tc"); goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":130 * return "DATE" * elif curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * return "%tc" * #elif file_format == FILE_FORMAT_SAV: */ } /* "pyreadstat/_readstat_writer.pyx":135 * # return "DATETIME20" * else: * return "DATETIME" # <<<<<<<<<<<<<< * elif curtype == PYWRITER_TIME: * if file_format == FILE_FORMAT_DTA: */ /*else*/ { __pyx_r = ((char *)"DATETIME"); goto __pyx_L0; } /* "pyreadstat/_readstat_writer.pyx":129 * else: * return "DATE" * elif curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * return "%tc" */ break; case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME: /* "pyreadstat/_readstat_writer.pyx":137 * return "DATETIME" * elif curtype == PYWRITER_TIME: * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * return "%tcHH:MM:SS" * else: */ __pyx_t_1 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA); if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":138 * elif curtype == PYWRITER_TIME: * if file_format == FILE_FORMAT_DTA: * return "%tcHH:MM:SS" # <<<<<<<<<<<<<< * else: * return "TIME" */ __pyx_r = ((char *)"%tcHH:MM:SS"); goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":137 * return "DATETIME" * elif curtype == PYWRITER_TIME: * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * return "%tcHH:MM:SS" * else: */ } /* "pyreadstat/_readstat_writer.pyx":140 * return "%tcHH:MM:SS" * else: * return "TIME" # <<<<<<<<<<<<<< * else: * raise PyreadstatError("Unknown pywriter variable format") */ /*else*/ { __pyx_r = ((char *)"TIME"); goto __pyx_L0; } /* "pyreadstat/_readstat_writer.pyx":136 * else: * return "DATETIME" * elif curtype == PYWRITER_TIME: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * return "%tcHH:MM:SS" */ break; default: /* "pyreadstat/_readstat_writer.pyx":142 * return "TIME" * else: * raise PyreadstatError("Unknown pywriter variable format") # <<<<<<<<<<<<<< * * */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_kp_s_Unknown_pywriter_variable_format}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 142, __pyx_L1_error) break; } /* "pyreadstat/_readstat_writer.pyx":117 * return tstamp * * cdef char * get_datetimelike_format_for_readstat(dst_file_format file_format, pywriter_variable_type curtype): # <<<<<<<<<<<<<< * """ * gives back a string with the format of the variable (according to the final application) to be used by readstat */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_writer.get_datetimelike_format_for_readstat", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":145 * * * cdef int get_pandas_str_series_max_length(object series, dict value_labels): # <<<<<<<<<<<<<< * """ For a pandas string series get the max length of the strings. Assumes there is no NaN among the elements. * """ */ static int __pyx_f_10pyreadstat_16_readstat_writer_get_pandas_str_series_max_length(PyObject *__pyx_v_series, PyObject *__pyx_v_value_labels) { PyObject *__pyx_v_values = NULL; PyObject *__pyx_v_val = 0; PyObject *__pyx_v_temp = 0; int __pyx_v_max_length; int __pyx_v_curlen; PyObject *__pyx_v_labels = 0; PyObject *__pyx_v_lab = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *(*__pyx_t_3)(PyObject *); PyObject *__pyx_t_4 = NULL; Py_ssize_t __pyx_t_5; int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_pandas_str_series_max_length", 1); /* "pyreadstat/_readstat_writer.pyx":148 * """ For a pandas string series get the max length of the strings. Assumes there is no NaN among the elements. * """ * values = series.values # <<<<<<<<<<<<<< * cdef str val * cdef bytes temp */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_series, __pyx_n_s_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_values = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":151 * cdef str val * cdef bytes temp * cdef int max_length = 1 # <<<<<<<<<<<<<< * cdef int curlen * cdef list labels */ __pyx_v_max_length = 1; /* "pyreadstat/_readstat_writer.pyx":154 * cdef int curlen * cdef list labels * for val in values: # <<<<<<<<<<<<<< * temp = val.encode("utf-8") * curlen = len(temp) */ if (likely(PyList_CheckExact(__pyx_v_values)) || PyTuple_CheckExact(__pyx_v_values)) { __pyx_t_1 = __pyx_v_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 154, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 154, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 154, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 154, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 154, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 154, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } if (!(likely(PyString_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_4))) __PYX_ERR(0, 154, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_val, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":155 * cdef list labels * for val in values: * temp = val.encode("utf-8") # <<<<<<<<<<<<<< * curlen = len(temp) * if curlen > max_length: */ __pyx_t_4 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyString_Type_encode, __pyx_v_val, __pyx_kp_s_utf_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_4))) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_temp, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":156 * for val in values: * temp = val.encode("utf-8") * curlen = len(temp) # <<<<<<<<<<<<<< * if curlen > max_length: * max_length = curlen */ if (unlikely(__pyx_v_temp == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 156, __pyx_L1_error) } __pyx_t_5 = __Pyx_PyBytes_GET_SIZE(__pyx_v_temp); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 156, __pyx_L1_error) __pyx_v_curlen = __pyx_t_5; /* "pyreadstat/_readstat_writer.pyx":157 * temp = val.encode("utf-8") * curlen = len(temp) * if curlen > max_length: # <<<<<<<<<<<<<< * max_length = curlen * if value_labels: */ __pyx_t_6 = (__pyx_v_curlen > __pyx_v_max_length); if (__pyx_t_6) { /* "pyreadstat/_readstat_writer.pyx":158 * curlen = len(temp) * if curlen > max_length: * max_length = curlen # <<<<<<<<<<<<<< * if value_labels: * labels = list(value_labels.keys()) */ __pyx_v_max_length = __pyx_v_curlen; /* "pyreadstat/_readstat_writer.pyx":157 * temp = val.encode("utf-8") * curlen = len(temp) * if curlen > max_length: # <<<<<<<<<<<<<< * max_length = curlen * if value_labels: */ } /* "pyreadstat/_readstat_writer.pyx":154 * cdef int curlen * cdef list labels * for val in values: # <<<<<<<<<<<<<< * temp = val.encode("utf-8") * curlen = len(temp) */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":159 * if curlen > max_length: * max_length = curlen * if value_labels: # <<<<<<<<<<<<<< * labels = list(value_labels.keys()) * for lab in labels: */ __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_value_labels); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 159, __pyx_L1_error) if (__pyx_t_6) { /* "pyreadstat/_readstat_writer.pyx":160 * max_length = curlen * if value_labels: * labels = list(value_labels.keys()) # <<<<<<<<<<<<<< * for lab in labels: * curlen = len(str(lab)) */ if (unlikely(__pyx_v_value_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "keys"); __PYX_ERR(0, 160, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyDict_Keys(__pyx_v_value_labels); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_labels = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":161 * if value_labels: * labels = list(value_labels.keys()) * for lab in labels: # <<<<<<<<<<<<<< * curlen = len(str(lab)) * if curlen > max_length: */ __pyx_t_4 = __pyx_v_labels; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 161, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 161, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_v_lab, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":162 * labels = list(value_labels.keys()) * for lab in labels: * curlen = len(str(lab)) # <<<<<<<<<<<<<< * if curlen > max_length: * max_length = curlen */ __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_lab); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 162, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_curlen = __pyx_t_5; /* "pyreadstat/_readstat_writer.pyx":163 * for lab in labels: * curlen = len(str(lab)) * if curlen > max_length: # <<<<<<<<<<<<<< * max_length = curlen * */ __pyx_t_6 = (__pyx_v_curlen > __pyx_v_max_length); if (__pyx_t_6) { /* "pyreadstat/_readstat_writer.pyx":164 * curlen = len(str(lab)) * if curlen > max_length: * max_length = curlen # <<<<<<<<<<<<<< * * return max_length */ __pyx_v_max_length = __pyx_v_curlen; /* "pyreadstat/_readstat_writer.pyx":163 * for lab in labels: * curlen = len(str(lab)) * if curlen > max_length: # <<<<<<<<<<<<<< * max_length = curlen * */ } /* "pyreadstat/_readstat_writer.pyx":161 * if value_labels: * labels = list(value_labels.keys()) * for lab in labels: # <<<<<<<<<<<<<< * curlen = len(str(lab)) * if curlen > max_length: */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":159 * if curlen > max_length: * max_length = curlen * if value_labels: # <<<<<<<<<<<<<< * labels = list(value_labels.keys()) * for lab in labels: */ } /* "pyreadstat/_readstat_writer.pyx":166 * max_length = curlen * * return max_length # <<<<<<<<<<<<<< * * */ __pyx_r = __pyx_v_max_length; goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":145 * * * cdef int get_pandas_str_series_max_length(object series, dict value_labels): # <<<<<<<<<<<<<< * """ For a pandas string series get the max length of the strings. Assumes there is no NaN among the elements. * """ */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_writer.get_pandas_str_series_max_length", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_values); __Pyx_XDECREF(__pyx_v_val); __Pyx_XDECREF(__pyx_v_temp); __Pyx_XDECREF(__pyx_v_labels); __Pyx_XDECREF(__pyx_v_lab); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":169 * * * cdef int check_series_all_same_types(object series, object type_to_check): # <<<<<<<<<<<<<< * """ * 1 if all elements in a series are of type type_to_check, 0 otherwise */ static int __pyx_f_10pyreadstat_16_readstat_writer_check_series_all_same_types(PyObject *__pyx_v_series, PyObject *__pyx_v_type_to_check) { PyObject *__pyx_v_values = NULL; PyObject *__pyx_v_val = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *(*__pyx_t_3)(PyObject *); PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("check_series_all_same_types", 1); /* "pyreadstat/_readstat_writer.pyx":174 * """ * * values = series.values # <<<<<<<<<<<<<< * for val in values: * if type(val) != type_to_check: */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_series, __pyx_n_s_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 174, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_values = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":175 * * values = series.values * for val in values: # <<<<<<<<<<<<<< * if type(val) != type_to_check: * return 0 */ if (likely(PyList_CheckExact(__pyx_v_values)) || PyTuple_CheckExact(__pyx_v_values)) { __pyx_t_1 = __pyx_v_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 175, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 175, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 175, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 175, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 175, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":176 * values = series.values * for val in values: * if type(val) != type_to_check: # <<<<<<<<<<<<<< * return 0 * return 1 */ __pyx_t_4 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_val)), __pyx_v_type_to_check, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 176, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":177 * for val in values: * if type(val) != type_to_check: * return 0 # <<<<<<<<<<<<<< * return 1 * */ __pyx_r = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":176 * values = series.values * for val in values: * if type(val) != type_to_check: # <<<<<<<<<<<<<< * return 0 * return 1 */ } /* "pyreadstat/_readstat_writer.pyx":175 * * values = series.values * for val in values: # <<<<<<<<<<<<<< * if type(val) != type_to_check: * return 0 */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":178 * if type(val) != type_to_check: * return 0 * return 1 # <<<<<<<<<<<<<< * * */ __pyx_r = 1; goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":169 * * * cdef int check_series_all_same_types(object series, object type_to_check): # <<<<<<<<<<<<<< * """ * 1 if all elements in a series are of type type_to_check, 0 otherwise */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_writer.check_series_all_same_types", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_values); __Pyx_XDECREF(__pyx_v_val); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":181 * * * cdef list get_pandas_column_types(object df, dict missing_user_values, dict variable_value_labels): # <<<<<<<<<<<<<< * """ * From a pandas data frame, get a list with tuples column types as first element, max_length as second and is_missing */ static PyObject *__pyx_f_10pyreadstat_16_readstat_writer_get_pandas_column_types(PyObject *__pyx_v_df, PyObject *__pyx_v_missing_user_values, PyObject *__pyx_v_variable_value_labels) { int __pyx_v_max_length; PyObject *__pyx_v_types = 0; PyObject *__pyx_v_columns = 0; PyObject *__pyx_v_result = 0; int __pyx_v_equal; int __pyx_v_is_missing; PyObject *__pyx_v_indx = NULL; PyObject *__pyx_v_col_name = NULL; PyObject *__pyx_v_col_type = NULL; PyObject *__pyx_v_curseries = NULL; PyObject *__pyx_v_curuser_missing = NULL; PyObject *__pyx_v_col = NULL; PyTypeObject *__pyx_v_curtype = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; Py_ssize_t __pyx_t_6; PyObject *(*__pyx_t_7)(PyObject *); PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *(*__pyx_t_11)(PyObject *); int __pyx_t_12; PyObject *__pyx_t_13 = NULL; int __pyx_t_14; int __pyx_t_15; Py_ssize_t __pyx_t_16; long __pyx_t_17; long __pyx_t_18; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_pandas_column_types", 0); __Pyx_INCREF(__pyx_v_variable_value_labels); /* "pyreadstat/_readstat_writer.pyx":191 * cdef int max_length * * cdef list types = df.dtypes.values.tolist() # <<<<<<<<<<<<<< * cdef list columns = df.columns.values.tolist() * */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_1))) __PYX_ERR(0, 191, __pyx_L1_error) __pyx_v_types = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":192 * * cdef list types = df.dtypes.values.tolist() * cdef list columns = df.columns.values.tolist() # <<<<<<<<<<<<<< * * cdef list result = list() */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_1))) __PYX_ERR(0, 192, __pyx_L1_error) __pyx_v_columns = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":194 * cdef list columns = df.columns.values.tolist() * * cdef list result = list() # <<<<<<<<<<<<<< * cdef int equal, is_missing * if variable_value_labels is None: */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_result = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":196 * cdef list result = list() * cdef int equal, is_missing * if variable_value_labels is None: # <<<<<<<<<<<<<< * variable_value_labels = dict() * */ __pyx_t_5 = (__pyx_v_variable_value_labels == ((PyObject*)Py_None)); if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":197 * cdef int equal, is_missing * if variable_value_labels is None: * variable_value_labels = dict() # <<<<<<<<<<<<<< * * for indx, (col_name, col_type) in enumerate(zip(columns, types)): */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_variable_value_labels, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":196 * cdef list result = list() * cdef int equal, is_missing * if variable_value_labels is None: # <<<<<<<<<<<<<< * variable_value_labels = dict() * */ } /* "pyreadstat/_readstat_writer.pyx":199 * variable_value_labels = dict() * * for indx, (col_name, col_type) in enumerate(zip(columns, types)): # <<<<<<<<<<<<<< * * max_length = 0 */ __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_columns); __Pyx_GIVEREF(__pyx_v_columns); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_columns)) __PYX_ERR(0, 199, __pyx_L1_error); __Pyx_INCREF(__pyx_v_types); __Pyx_GIVEREF(__pyx_v_types); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_types)) __PYX_ERR(0, 199, __pyx_L1_error); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 199, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 199, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 199, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 199, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 199, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 199, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 199, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_8 = PyList_GET_ITEM(sequence, 0); __pyx_t_9 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); #else __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); index = 0; __pyx_t_8 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 199, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 199, __pyx_L1_error) __pyx_L7_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_col_name, __pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_col_type, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_indx, __pyx_t_1); __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":201 * for indx, (col_name, col_type) in enumerate(zip(columns, types)): * * max_length = 0 # <<<<<<<<<<<<<< * curseries = df.iloc[:, indx] * curuser_missing = None */ __pyx_v_max_length = 0; /* "pyreadstat/_readstat_writer.pyx":202 * * max_length = 0 * curseries = df.iloc[:, indx] # <<<<<<<<<<<<<< * curuser_missing = None * if missing_user_values: */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_iloc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice_)) __PYX_ERR(0, 202, __pyx_L1_error); __Pyx_INCREF(__pyx_v_indx); __Pyx_GIVEREF(__pyx_v_indx); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_indx)) __PYX_ERR(0, 202, __pyx_L1_error); __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF_SET(__pyx_v_curseries, __pyx_t_8); __pyx_t_8 = 0; /* "pyreadstat/_readstat_writer.pyx":203 * max_length = 0 * curseries = df.iloc[:, indx] * curuser_missing = None # <<<<<<<<<<<<<< * if missing_user_values: * curuser_missing = missing_user_values.get(col_name) */ __Pyx_INCREF(Py_None); __Pyx_XDECREF_SET(__pyx_v_curuser_missing, Py_None); /* "pyreadstat/_readstat_writer.pyx":204 * curseries = df.iloc[:, indx] * curuser_missing = None * if missing_user_values: # <<<<<<<<<<<<<< * curuser_missing = missing_user_values.get(col_name) * */ __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_missing_user_values); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 204, __pyx_L1_error) if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":205 * curuser_missing = None * if missing_user_values: * curuser_missing = missing_user_values.get(col_name) # <<<<<<<<<<<<<< * * # recover original type for categories */ if (unlikely(__pyx_v_missing_user_values == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 205, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyDict_GetItemDefault(__pyx_v_missing_user_values, __pyx_v_col_name, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_curuser_missing, __pyx_t_8); __pyx_t_8 = 0; /* "pyreadstat/_readstat_writer.pyx":204 * curseries = df.iloc[:, indx] * curuser_missing = None * if missing_user_values: # <<<<<<<<<<<<<< * curuser_missing = missing_user_values.get(col_name) * */ } /* "pyreadstat/_readstat_writer.pyx":208 * * # recover original type for categories * if type(col_type) is pd.core.dtypes.dtypes.CategoricalDtype: # <<<<<<<<<<<<<< * col_type = np.asarray(curseries).dtype * if col_type in int_types: */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_pd); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_core); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtypes); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_CategoricalDtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_5 = (((PyObject *)Py_TYPE(__pyx_v_col_type)) == __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":209 * # recover original type for categories * if type(col_type) is pd.core.dtypes.dtypes.CategoricalDtype: * col_type = np.asarray(curseries).dtype # <<<<<<<<<<<<<< * if col_type in int_types: * result.append((PYWRITER_INTEGER, 0,0)) */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_curseries}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_col_type, __pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":208 * * # recover original type for categories * if type(col_type) is pd.core.dtypes.dtypes.CategoricalDtype: # <<<<<<<<<<<<<< * col_type = np.asarray(curseries).dtype * if col_type in int_types: */ } /* "pyreadstat/_readstat_writer.pyx":210 * if type(col_type) is pd.core.dtypes.dtypes.CategoricalDtype: * col_type = np.asarray(curseries).dtype * if col_type in int_types: # <<<<<<<<<<<<<< * result.append((PYWRITER_INTEGER, 0,0)) * elif col_type in float_types: */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_int_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 210, __pyx_L1_error) } __pyx_t_5 = (__Pyx_PySet_ContainsTF(__pyx_v_col_type, __pyx_v_10pyreadstat_16_readstat_writer_int_types, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 210, __pyx_L1_error) if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":211 * col_type = np.asarray(curseries).dtype * if col_type in int_types: * result.append((PYWRITER_INTEGER, 0,0)) # <<<<<<<<<<<<<< * elif col_type in float_types: * if np.any(pd.isna(curseries)): */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_INTEGER); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_0)) __PYX_ERR(0, 211, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_0)) __PYX_ERR(0, 211, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_8); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 211, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "pyreadstat/_readstat_writer.pyx":210 * if type(col_type) is pd.core.dtypes.dtypes.CategoricalDtype: * col_type = np.asarray(curseries).dtype * if col_type in int_types: # <<<<<<<<<<<<<< * result.append((PYWRITER_INTEGER, 0,0)) * elif col_type in float_types: */ goto __pyx_L10; } /* "pyreadstat/_readstat_writer.pyx":212 * if col_type in int_types: * result.append((PYWRITER_INTEGER, 0,0)) * elif col_type in float_types: # <<<<<<<<<<<<<< * if np.any(pd.isna(curseries)): * result.append((PYWRITER_DOUBLE, 0, 1)) */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_float_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 212, __pyx_L1_error) } __pyx_t_5 = (__Pyx_PySet_ContainsTF(__pyx_v_col_type, __pyx_v_10pyreadstat_16_readstat_writer_float_types, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 212, __pyx_L1_error) if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":213 * result.append((PYWRITER_INTEGER, 0,0)) * elif col_type in float_types: * if np.any(pd.isna(curseries)): # <<<<<<<<<<<<<< * result.append((PYWRITER_DOUBLE, 0, 1)) * else: */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_any); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_pd); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_isna); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_curseries}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_t_13 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_t_3}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 213, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":214 * elif col_type in float_types: * if np.any(pd.isna(curseries)): * result.append((PYWRITER_DOUBLE, 0, 1)) # <<<<<<<<<<<<<< * else: * result.append((PYWRITER_DOUBLE, 0, 0)) */ __pyx_t_8 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DOUBLE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8)) __PYX_ERR(0, 214, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_int_0)) __PYX_ERR(0, 214, __pyx_L1_error); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_int_1)) __PYX_ERR(0, 214, __pyx_L1_error); __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_9); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 214, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/_readstat_writer.pyx":213 * result.append((PYWRITER_INTEGER, 0,0)) * elif col_type in float_types: * if np.any(pd.isna(curseries)): # <<<<<<<<<<<<<< * result.append((PYWRITER_DOUBLE, 0, 1)) * else: */ goto __pyx_L11; } /* "pyreadstat/_readstat_writer.pyx":216 * result.append((PYWRITER_DOUBLE, 0, 1)) * else: * result.append((PYWRITER_DOUBLE, 0, 0)) # <<<<<<<<<<<<<< * elif col_type == bool: * result.append((PYWRITER_LOGICAL, 0,0)) */ /*else*/ { __pyx_t_9 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DOUBLE); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_0)) __PYX_ERR(0, 216, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_int_0)) __PYX_ERR(0, 216, __pyx_L1_error); __pyx_t_9 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_8); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 216, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_L11:; /* "pyreadstat/_readstat_writer.pyx":212 * if col_type in int_types: * result.append((PYWRITER_INTEGER, 0,0)) * elif col_type in float_types: # <<<<<<<<<<<<<< * if np.any(pd.isna(curseries)): * result.append((PYWRITER_DOUBLE, 0, 1)) */ goto __pyx_L10; } /* "pyreadstat/_readstat_writer.pyx":217 * else: * result.append((PYWRITER_DOUBLE, 0, 0)) * elif col_type == bool: # <<<<<<<<<<<<<< * result.append((PYWRITER_LOGICAL, 0,0)) * # np.datetime64[ns] */ __pyx_t_8 = PyObject_RichCompare(__pyx_v_col_type, ((PyObject*)&PyBool_Type), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 217, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":218 * result.append((PYWRITER_DOUBLE, 0, 0)) * elif col_type == bool: * result.append((PYWRITER_LOGICAL, 0,0)) # <<<<<<<<<<<<<< * # np.datetime64[ns] * elif is_datetime64_ns_dtype(df[col_name]): */ __pyx_t_8 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_LOGICAL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8)) __PYX_ERR(0, 218, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_int_0)) __PYX_ERR(0, 218, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_int_0)) __PYX_ERR(0, 218, __pyx_L1_error); __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_9); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 218, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/_readstat_writer.pyx":217 * else: * result.append((PYWRITER_DOUBLE, 0, 0)) * elif col_type == bool: # <<<<<<<<<<<<<< * result.append((PYWRITER_LOGICAL, 0,0)) * # np.datetime64[ns] */ goto __pyx_L10; } /* "pyreadstat/_readstat_writer.pyx":220 * result.append((PYWRITER_LOGICAL, 0,0)) * # np.datetime64[ns] * elif is_datetime64_ns_dtype(df[col_name]): # <<<<<<<<<<<<<< * if np.any(pd.isna(curseries)): * result.append((PYWRITER_DATETIME64_NS, 0,1)) */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_is_datetime64_ns_dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_df, __pyx_v_col_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_t_3}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 220, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":221 * # np.datetime64[ns] * elif is_datetime64_ns_dtype(df[col_name]): * if np.any(pd.isna(curseries)): # <<<<<<<<<<<<<< * result.append((PYWRITER_DATETIME64_NS, 0,1)) * else: */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_pd); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_isna); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_v_curseries}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_8}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":222 * elif is_datetime64_ns_dtype(df[col_name]): * if np.any(pd.isna(curseries)): * result.append((PYWRITER_DATETIME64_NS, 0,1)) # <<<<<<<<<<<<<< * else: * result.append((PYWRITER_DATETIME64_NS, 0,0)) */ __pyx_t_9 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9)) __PYX_ERR(0, 222, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0)) __PYX_ERR(0, 222, __pyx_L1_error); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_1)) __PYX_ERR(0, 222, __pyx_L1_error); __pyx_t_9 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 222, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":221 * # np.datetime64[ns] * elif is_datetime64_ns_dtype(df[col_name]): * if np.any(pd.isna(curseries)): # <<<<<<<<<<<<<< * result.append((PYWRITER_DATETIME64_NS, 0,1)) * else: */ goto __pyx_L12; } /* "pyreadstat/_readstat_writer.pyx":224 * result.append((PYWRITER_DATETIME64_NS, 0,1)) * else: * result.append((PYWRITER_DATETIME64_NS, 0,0)) # <<<<<<<<<<<<<< * elif col_type == np.dtype(' __pyx_t_17); if (__pyx_t_5) { __pyx_t_18 = __pyx_t_4; } else { __pyx_t_18 = __pyx_t_17; } __pyx_v_max_length = __pyx_t_18; /* "pyreadstat/_readstat_writer.pyx":278 * result.append((PYWRITER_LOGICAL, 0, is_missing)) * elif curtype == str: * if is_missing: # <<<<<<<<<<<<<< * col = curseries.dropna().reset_index(drop=True) * max_length = get_pandas_str_series_max_length(col, variable_value_labels.get(col_name)) */ goto __pyx_L30; } /* "pyreadstat/_readstat_writer.pyx":283 * max_length = max(1, max_length) * else: * max_length = get_pandas_str_series_max_length(curseries, variable_value_labels.get(col_name)) # <<<<<<<<<<<<<< * result.append((PYWRITER_CHARACTER, max_length, is_missing)) * elif curtype == datetime.date: */ /*else*/ { if (unlikely(__pyx_v_variable_value_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 283, __pyx_L1_error) } __pyx_t_9 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_value_labels, __pyx_v_col_name, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (!(likely(PyDict_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("dict", __pyx_t_9))) __PYX_ERR(0, 283, __pyx_L1_error) __pyx_t_4 = __pyx_f_10pyreadstat_16_readstat_writer_get_pandas_str_series_max_length(__pyx_v_curseries, ((PyObject*)__pyx_t_9)); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 283, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_max_length = __pyx_t_4; } __pyx_L30:; /* "pyreadstat/_readstat_writer.pyx":284 * else: * max_length = get_pandas_str_series_max_length(curseries, variable_value_labels.get(col_name)) * result.append((PYWRITER_CHARACTER, max_length, is_missing)) # <<<<<<<<<<<<<< * elif curtype == datetime.date: * result.append((PYWRITER_DATE, 0, is_missing)) */ __pyx_t_9 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_max_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_is_missing); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9)) __PYX_ERR(0, 284, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3)) __PYX_ERR(0, 284, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_8)) __PYX_ERR(0, 284, __pyx_L1_error); __pyx_t_9 = 0; __pyx_t_3 = 0; __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_10); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":277 * elif curtype == bool: * result.append((PYWRITER_LOGICAL, 0, is_missing)) * elif curtype == str: # <<<<<<<<<<<<<< * if is_missing: * col = curseries.dropna().reset_index(drop=True) */ goto __pyx_L29; } /* "pyreadstat/_readstat_writer.pyx":285 * max_length = get_pandas_str_series_max_length(curseries, variable_value_labels.get(col_name)) * result.append((PYWRITER_CHARACTER, max_length, is_missing)) * elif curtype == datetime.date: # <<<<<<<<<<<<<< * result.append((PYWRITER_DATE, 0, is_missing)) * elif curtype == datetime.datetime: */ __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_datetime); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_date); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 285, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = PyObject_RichCompare(((PyObject *)__pyx_v_curtype), __pyx_t_8, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 285, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 285, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":286 * result.append((PYWRITER_CHARACTER, max_length, is_missing)) * elif curtype == datetime.date: * result.append((PYWRITER_DATE, 0, is_missing)) # <<<<<<<<<<<<<< * elif curtype == datetime.datetime: * result.append((PYWRITER_DATETIME, 0, is_missing)) */ __pyx_t_10 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_is_missing); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10)) __PYX_ERR(0, 286, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0)) __PYX_ERR(0, 286, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_8)) __PYX_ERR(0, 286, __pyx_L1_error); __pyx_t_10 = 0; __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":285 * max_length = get_pandas_str_series_max_length(curseries, variable_value_labels.get(col_name)) * result.append((PYWRITER_CHARACTER, max_length, is_missing)) * elif curtype == datetime.date: # <<<<<<<<<<<<<< * result.append((PYWRITER_DATE, 0, is_missing)) * elif curtype == datetime.datetime: */ goto __pyx_L29; } /* "pyreadstat/_readstat_writer.pyx":287 * elif curtype == datetime.date: * result.append((PYWRITER_DATE, 0, is_missing)) * elif curtype == datetime.datetime: # <<<<<<<<<<<<<< * result.append((PYWRITER_DATETIME, 0, is_missing)) * elif curtype == datetime.time: */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_curtype), __pyx_t_8, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":288 * result.append((PYWRITER_DATE, 0, is_missing)) * elif curtype == datetime.datetime: * result.append((PYWRITER_DATETIME, 0, is_missing)) # <<<<<<<<<<<<<< * elif curtype == datetime.time: * result.append((PYWRITER_TIME, 0, is_missing)) */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_is_missing); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3)) __PYX_ERR(0, 288, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_int_0)) __PYX_ERR(0, 288, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_8)) __PYX_ERR(0, 288, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_10); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 288, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":287 * elif curtype == datetime.date: * result.append((PYWRITER_DATE, 0, is_missing)) * elif curtype == datetime.datetime: # <<<<<<<<<<<<<< * result.append((PYWRITER_DATETIME, 0, is_missing)) * elif curtype == datetime.time: */ goto __pyx_L29; } /* "pyreadstat/_readstat_writer.pyx":289 * elif curtype == datetime.datetime: * result.append((PYWRITER_DATETIME, 0, is_missing)) * elif curtype == datetime.time: # <<<<<<<<<<<<<< * result.append((PYWRITER_TIME, 0, is_missing)) * else: */ __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_datetime); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_time); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = PyObject_RichCompare(((PyObject *)__pyx_v_curtype), __pyx_t_8, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":290 * result.append((PYWRITER_DATETIME, 0, is_missing)) * elif curtype == datetime.time: * result.append((PYWRITER_TIME, 0, is_missing)) # <<<<<<<<<<<<<< * else: * curseries = curseries.astype(str) */ __pyx_t_10 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_is_missing); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10)) __PYX_ERR(0, 290, __pyx_L1_error); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0)) __PYX_ERR(0, 290, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_8)) __PYX_ERR(0, 290, __pyx_L1_error); __pyx_t_10 = 0; __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 290, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":289 * elif curtype == datetime.datetime: * result.append((PYWRITER_DATETIME, 0, is_missing)) * elif curtype == datetime.time: # <<<<<<<<<<<<<< * result.append((PYWRITER_TIME, 0, is_missing)) * else: */ goto __pyx_L29; } /* "pyreadstat/_readstat_writer.pyx":292 * result.append((PYWRITER_TIME, 0, is_missing)) * else: * curseries = curseries.astype(str) # <<<<<<<<<<<<<< * if is_missing: * col = curseries.dropna().reset_index(drop=True) */ /*else*/ { __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_curseries, __pyx_n_s_astype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, ((PyObject *)(&PyString_Type))}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF_SET(__pyx_v_curseries, __pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":293 * else: * curseries = curseries.astype(str) * if is_missing: # <<<<<<<<<<<<<< * col = curseries.dropna().reset_index(drop=True) * max_length = get_pandas_str_series_max_length(col.astype(str), variable_value_labels.get(col_name)) */ __pyx_t_5 = (__pyx_v_is_missing != 0); if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":294 * curseries = curseries.astype(str) * if is_missing: * col = curseries.dropna().reset_index(drop=True) # <<<<<<<<<<<<<< * max_length = get_pandas_str_series_max_length(col.astype(str), variable_value_labels.get(col_name)) * else: */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_curseries, __pyx_n_s_dropna); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reset_index); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_drop, Py_True) < 0) __PYX_ERR(0, 294, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_col, __pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":295 * if is_missing: * col = curseries.dropna().reset_index(drop=True) * max_length = get_pandas_str_series_max_length(col.astype(str), variable_value_labels.get(col_name)) # <<<<<<<<<<<<<< * else: * max_length = get_pandas_str_series_max_length(curseries.astype(str), variable_value_labels.get(col_name)) */ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_col, __pyx_n_s_astype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, ((PyObject *)(&PyString_Type))}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (unlikely(__pyx_v_variable_value_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 295, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_value_labels, __pyx_v_col_name, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (!(likely(PyDict_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None) || __Pyx_RaiseUnexpectedTypeError("dict", __pyx_t_3))) __PYX_ERR(0, 295, __pyx_L1_error) __pyx_t_4 = __pyx_f_10pyreadstat_16_readstat_writer_get_pandas_str_series_max_length(__pyx_t_10, ((PyObject*)__pyx_t_3)); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 295, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_max_length = __pyx_t_4; /* "pyreadstat/_readstat_writer.pyx":293 * else: * curseries = curseries.astype(str) * if is_missing: # <<<<<<<<<<<<<< * col = curseries.dropna().reset_index(drop=True) * max_length = get_pandas_str_series_max_length(col.astype(str), variable_value_labels.get(col_name)) */ goto __pyx_L31; } /* "pyreadstat/_readstat_writer.pyx":297 * max_length = get_pandas_str_series_max_length(col.astype(str), variable_value_labels.get(col_name)) * else: * max_length = get_pandas_str_series_max_length(curseries.astype(str), variable_value_labels.get(col_name)) # <<<<<<<<<<<<<< * result.append((PYWRITER_OBJECT, max_length, is_missing)) * */ /*else*/ { __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_curseries, __pyx_n_s_astype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, ((PyObject *)(&PyString_Type))}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } if (unlikely(__pyx_v_variable_value_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 297, __pyx_L1_error) } __pyx_t_10 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_value_labels, __pyx_v_col_name, Py_None); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (!(likely(PyDict_CheckExact(__pyx_t_10))||((__pyx_t_10) == Py_None) || __Pyx_RaiseUnexpectedTypeError("dict", __pyx_t_10))) __PYX_ERR(0, 297, __pyx_L1_error) __pyx_t_4 = __pyx_f_10pyreadstat_16_readstat_writer_get_pandas_str_series_max_length(__pyx_t_3, ((PyObject*)__pyx_t_10)); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 297, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_v_max_length = __pyx_t_4; } __pyx_L31:; /* "pyreadstat/_readstat_writer.pyx":298 * else: * max_length = get_pandas_str_series_max_length(curseries.astype(str), variable_value_labels.get(col_name)) * result.append((PYWRITER_OBJECT, max_length, is_missing)) # <<<<<<<<<<<<<< * * else: */ __pyx_t_10 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_max_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_is_missing); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10)) __PYX_ERR(0, 298, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_8)) __PYX_ERR(0, 298, __pyx_L1_error); __pyx_t_10 = 0; __pyx_t_3 = 0; __pyx_t_8 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_9); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 298, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_L29:; /* "pyreadstat/_readstat_writer.pyx":231 * else: * result.append((PYWRITER_DATETIME, 0, is_missing)) * elif col_type == object or col_type == 'string' or col_type in int_mixed_types: # <<<<<<<<<<<<<< * is_missing = 0 * if curuser_missing: */ goto __pyx_L10; } /* "pyreadstat/_readstat_writer.pyx":302 * else: * # generic object * max_length = get_pandas_str_series_max_length(curseries.astype(str), variable_value_labels.get(col_name)) # <<<<<<<<<<<<<< * is_missing = 0 * if np.any(pd.isna(curseries)): */ /*else*/ { __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_curseries, __pyx_n_s_astype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, ((PyObject *)(&PyString_Type))}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } if (unlikely(__pyx_v_variable_value_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 302, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_value_labels, __pyx_v_col_name, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (!(likely(PyDict_CheckExact(__pyx_t_8))||((__pyx_t_8) == Py_None) || __Pyx_RaiseUnexpectedTypeError("dict", __pyx_t_8))) __PYX_ERR(0, 302, __pyx_L1_error) __pyx_t_4 = __pyx_f_10pyreadstat_16_readstat_writer_get_pandas_str_series_max_length(__pyx_t_9, ((PyObject*)__pyx_t_8)); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_max_length = __pyx_t_4; /* "pyreadstat/_readstat_writer.pyx":303 * # generic object * max_length = get_pandas_str_series_max_length(curseries.astype(str), variable_value_labels.get(col_name)) * is_missing = 0 # <<<<<<<<<<<<<< * if np.any(pd.isna(curseries)): * is_missing = 1 */ __pyx_v_is_missing = 0; /* "pyreadstat/_readstat_writer.pyx":304 * max_length = get_pandas_str_series_max_length(curseries.astype(str), variable_value_labels.get(col_name)) * is_missing = 0 * if np.any(pd.isna(curseries)): # <<<<<<<<<<<<<< * is_missing = 1 * result.append((PYWRITER_OBJECT, max_length, is_missing)) */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_pd); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_isna); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_13))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_curseries}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_t_13 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_t_9}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_5) { /* "pyreadstat/_readstat_writer.pyx":305 * is_missing = 0 * if np.any(pd.isna(curseries)): * is_missing = 1 # <<<<<<<<<<<<<< * result.append((PYWRITER_OBJECT, max_length, is_missing)) * return result */ __pyx_v_is_missing = 1; /* "pyreadstat/_readstat_writer.pyx":304 * max_length = get_pandas_str_series_max_length(curseries.astype(str), variable_value_labels.get(col_name)) * is_missing = 0 * if np.any(pd.isna(curseries)): # <<<<<<<<<<<<<< * is_missing = 1 * result.append((PYWRITER_OBJECT, max_length, is_missing)) */ } /* "pyreadstat/_readstat_writer.pyx":306 * if np.any(pd.isna(curseries)): * is_missing = 1 * result.append((PYWRITER_OBJECT, max_length, is_missing)) # <<<<<<<<<<<<<< * return result * */ __pyx_t_8 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_max_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_is_missing); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_8)) __PYX_ERR(0, 306, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_3)) __PYX_ERR(0, 306, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_9)) __PYX_ERR(0, 306, __pyx_L1_error); __pyx_t_8 = 0; __pyx_t_3 = 0; __pyx_t_9 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_result, __pyx_t_13); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 306, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_L10:; /* "pyreadstat/_readstat_writer.pyx":199 * variable_value_labels = dict() * * for indx, (col_name, col_type) in enumerate(zip(columns, types)): # <<<<<<<<<<<<<< * * max_length = 0 */ __pyx_L4_continue:; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":307 * is_missing = 1 * result.append((PYWRITER_OBJECT, max_length, is_missing)) * return result # <<<<<<<<<<<<<< * * cdef readstat_label_set_t *set_value_label(readstat_writer_t *writer, dict value_labels, str labelset_name, */ __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_result); __pyx_r = __pyx_v_result; goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":181 * * * cdef list get_pandas_column_types(object df, dict missing_user_values, dict variable_value_labels): # <<<<<<<<<<<<<< * """ * From a pandas data frame, get a list with tuples column types as first element, max_length as second and is_missing */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("pyreadstat._readstat_writer.get_pandas_column_types", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_types); __Pyx_XDECREF(__pyx_v_columns); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_indx); __Pyx_XDECREF(__pyx_v_col_name); __Pyx_XDECREF(__pyx_v_col_type); __Pyx_XDECREF(__pyx_v_curseries); __Pyx_XDECREF(__pyx_v_curuser_missing); __Pyx_XDECREF(__pyx_v_col); __Pyx_XDECREF((PyObject *)__pyx_v_curtype); __Pyx_XDECREF(__pyx_v_variable_value_labels); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":309 * return result * * cdef readstat_label_set_t *set_value_label(readstat_writer_t *writer, dict value_labels, str labelset_name, # <<<<<<<<<<<<<< * pywriter_variable_type curpytype, dst_file_format file_format, str variable_name, * list user_missing_tags) except *: */ static readstat_label_set_t *__pyx_f_10pyreadstat_16_readstat_writer_set_value_label(readstat_writer_t *__pyx_v_writer, PyObject *__pyx_v_value_labels, PyObject *__pyx_v_labelset_name, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __pyx_v_curpytype, __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format __pyx_v_file_format, PyObject *__pyx_v_variable_name, PyObject *__pyx_v_user_missing_tags) { readstat_label_set_t *__pyx_v_label_set; readstat_type_t __pyx_v_curtype; double __pyx_v_double_val; PyObject *__pyx_v_value = NULL; PyObject *__pyx_v_label = NULL; PyObject *__pyx_v_msg = NULL; readstat_label_set_t *__pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; readstat_type_t __pyx_t_3; char const *__pyx_t_4; Py_ssize_t __pyx_t_5; PyObject *(*__pyx_t_6)(PyObject *); PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *(*__pyx_t_10)(PyObject *); int __pyx_t_11; int __pyx_t_12; int __pyx_t_13; long __pyx_t_14; char const *__pyx_t_15; double __pyx_t_16; char const *__pyx_t_17; int32_t __pyx_t_18; char const *__pyx_t_19; char const *__pyx_t_20; char const *__pyx_t_21; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_value_label", 1); /* "pyreadstat/_readstat_writer.pyx":320 * cdef double double_val * * curtype = pandas_to_readstat_types[curpytype] # <<<<<<<<<<<<<< * label_set = readstat_add_label_set(writer, curtype, labelset_name.encode("utf-8")) * */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_pandas_to_readstat_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 320, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_v_curpytype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_10pyreadstat_16_readstat_writer_pandas_to_readstat_types, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = ((readstat_type_t)__Pyx_PyInt_As_readstat_type_t(__pyx_t_2)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_curtype = __pyx_t_3; /* "pyreadstat/_readstat_writer.pyx":321 * * curtype = pandas_to_readstat_types[curpytype] * label_set = readstat_add_label_set(writer, curtype, labelset_name.encode("utf-8")) # <<<<<<<<<<<<<< * * for value, label in value_labels.items(): */ __pyx_t_2 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyString_Type_encode, __pyx_v_labelset_name, __pyx_kp_s_utf_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_AsString(__pyx_t_2); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 321, __pyx_L1_error) __pyx_v_label_set = readstat_add_label_set(__pyx_v_writer, __pyx_v_curtype, __pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":323 * label_set = readstat_add_label_set(writer, curtype, labelset_name.encode("utf-8")) * * for value, label in value_labels.items(): # <<<<<<<<<<<<<< * * if type(label) != str: */ if (unlikely(__pyx_v_value_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 323, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_value_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 323, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 323, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 323, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 323, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 323, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_6(__pyx_t_1); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 323, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 323, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_7 = PyList_GET_ITEM(sequence, 0); __pyx_t_8 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); #else __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 323, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 323, __pyx_L1_error) __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_label, __pyx_t_8); __pyx_t_8 = 0; /* "pyreadstat/_readstat_writer.pyx":325 * for value, label in value_labels.items(): * * if type(label) != str: # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Label %s in variable %s must be string" % (str(label), variable_name) * raise PyreadstatError(msg) */ __pyx_t_2 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_label)), ((PyObject *)(&PyString_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 325, __pyx_L1_error) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 325, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__pyx_t_11)) { /* "pyreadstat/_readstat_writer.pyx":326 * * if type(label) != str: * msg = "variable_value_labels: type of Label %s in variable %s must be string" % (str(label), variable_name) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_label); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error); __Pyx_INCREF(__pyx_v_variable_name); __Pyx_GIVEREF(__pyx_v_variable_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_variable_name)) __PYX_ERR(0, 326, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_variable_value_labels_type_of_La, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_msg = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":327 * if type(label) != str: * msg = "variable_value_labels: type of Label %s in variable %s must be string" % (str(label), variable_name) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * if user_missing_tags and value in user_missing_tags: */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 327, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":325 * for value, label in value_labels.items(): * * if type(label) != str: # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Label %s in variable %s must be string" % (str(label), variable_name) * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":329 * raise PyreadstatError(msg) * * if user_missing_tags and value in user_missing_tags: # <<<<<<<<<<<<<< * if curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: * msg = "missing_user_values not allowed for character variable %s" % variable_name */ __pyx_t_13 = (__pyx_v_user_missing_tags != Py_None)&&(PyList_GET_SIZE(__pyx_v_user_missing_tags) != 0); if (__pyx_t_13) { } else { __pyx_t_11 = __pyx_t_13; goto __pyx_L9_bool_binop_done; } __pyx_t_13 = (__Pyx_PySequence_ContainsTF(__pyx_v_value, __pyx_v_user_missing_tags, Py_EQ)); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 329, __pyx_L1_error) __pyx_t_11 = __pyx_t_13; __pyx_L9_bool_binop_done:; if (__pyx_t_11) { /* "pyreadstat/_readstat_writer.pyx":330 * * if user_missing_tags and value in user_missing_tags: * if curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: # <<<<<<<<<<<<<< * msg = "missing_user_values not allowed for character variable %s" % variable_name * raise PyreadstatError(msg) */ switch (__pyx_v_curpytype) { case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT: /* "pyreadstat/_readstat_writer.pyx":331 * if user_missing_tags and value in user_missing_tags: * if curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: * msg = "missing_user_values not allowed for character variable %s" % variable_name # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_missing_user_values_not_allowed, __pyx_v_variable_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 331, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_msg = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":332 * if curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: * msg = "missing_user_values not allowed for character variable %s" % variable_name * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * readstat_label_tagged_value(label_set, ord(value), label.encode("utf-8")) */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 332, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":330 * * if user_missing_tags and value in user_missing_tags: * if curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: # <<<<<<<<<<<<<< * msg = "missing_user_values not allowed for character variable %s" % variable_name * raise PyreadstatError(msg) */ break; default: break; } /* "pyreadstat/_readstat_writer.pyx":334 * raise PyreadstatError(msg) * * readstat_label_tagged_value(label_set, ord(value), label.encode("utf-8")) # <<<<<<<<<<<<<< * continue * */ __pyx_t_14 = __Pyx_PyObject_Ord(__pyx_v_value); if (unlikely(__pyx_t_14 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 334, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_label, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_s_utf_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_15 = __Pyx_PyObject_AsString(__pyx_t_2); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) __PYX_ERR(0, 334, __pyx_L1_error) readstat_label_tagged_value(__pyx_v_label_set, __pyx_t_14, __pyx_t_15); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":335 * * readstat_label_tagged_value(label_set, ord(value), label.encode("utf-8")) * continue # <<<<<<<<<<<<<< * * */ goto __pyx_L3_continue; /* "pyreadstat/_readstat_writer.pyx":329 * raise PyreadstatError(msg) * * if user_missing_tags and value in user_missing_tags: # <<<<<<<<<<<<<< * if curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: * msg = "missing_user_values not allowed for character variable %s" % variable_name */ } /* "pyreadstat/_readstat_writer.pyx":338 * * * if curpytype == PYWRITER_DOUBLE: # <<<<<<<<<<<<<< * if type(value) not in numeric_types: * msg = "variable_value_labels: type of Value %s in variable %s must be numeric" % (str(value), variable_name) */ switch (__pyx_v_curpytype) { case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DOUBLE: /* "pyreadstat/_readstat_writer.pyx":339 * * if curpytype == PYWRITER_DOUBLE: * if type(value) not in numeric_types: # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Value %s in variable %s must be numeric" % (str(value), variable_name) * raise PyreadstatError(msg) */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_numeric_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 339, __pyx_L1_error) } __pyx_t_11 = (__Pyx_PySet_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_value)), __pyx_v_10pyreadstat_16_readstat_writer_numeric_types, Py_NE)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 339, __pyx_L1_error) if (unlikely(__pyx_t_11)) { /* "pyreadstat/_readstat_writer.pyx":340 * if curpytype == PYWRITER_DOUBLE: * if type(value) not in numeric_types: * msg = "variable_value_labels: type of Value %s in variable %s must be numeric" % (str(value), variable_name) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * readstat_label_double_value(label_set, value, label.encode("utf-8")) */ __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2)) __PYX_ERR(0, 340, __pyx_L1_error); __Pyx_INCREF(__pyx_v_variable_name); __Pyx_GIVEREF(__pyx_v_variable_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_variable_name)) __PYX_ERR(0, 340, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_variable_value_labels_type_of_Va, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_msg = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":341 * if type(value) not in numeric_types: * msg = "variable_value_labels: type of Value %s in variable %s must be numeric" % (str(value), variable_name) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * readstat_label_double_value(label_set, value, label.encode("utf-8")) * */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 341, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 341, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":339 * * if curpytype == PYWRITER_DOUBLE: * if type(value) not in numeric_types: # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Value %s in variable %s must be numeric" % (str(value), variable_name) * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":342 * msg = "variable_value_labels: type of Value %s in variable %s must be numeric" % (str(value), variable_name) * raise PyreadstatError(msg) * readstat_label_double_value(label_set, value, label.encode("utf-8")) # <<<<<<<<<<<<<< * * elif curpytype == PYWRITER_INTEGER: */ __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_16 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 342, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_label, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_s_utf_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_17 = __Pyx_PyObject_AsString(__pyx_t_2); if (unlikely((!__pyx_t_17) && PyErr_Occurred())) __PYX_ERR(0, 342, __pyx_L1_error) readstat_label_double_value(__pyx_v_label_set, __pyx_t_16, __pyx_t_17); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":338 * * * if curpytype == PYWRITER_DOUBLE: # <<<<<<<<<<<<<< * if type(value) not in numeric_types: * msg = "variable_value_labels: type of Value %s in variable %s must be numeric" % (str(value), variable_name) */ break; case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_INTEGER: /* "pyreadstat/_readstat_writer.pyx":345 * * elif curpytype == PYWRITER_INTEGER: * if type(value) not in int_types: # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Value %s in variable %s must be int" % (str(value), variable_name) * raise PyreadstatError(msg) */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_int_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 345, __pyx_L1_error) } __pyx_t_11 = (__Pyx_PySet_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_value)), __pyx_v_10pyreadstat_16_readstat_writer_int_types, Py_NE)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 345, __pyx_L1_error) if (unlikely(__pyx_t_11)) { /* "pyreadstat/_readstat_writer.pyx":346 * elif curpytype == PYWRITER_INTEGER: * if type(value) not in int_types: * msg = "variable_value_labels: type of Value %s in variable %s must be int" % (str(value), variable_name) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * readstat_label_int32_value(label_set, value, label.encode("utf-8")) */ __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error); __Pyx_INCREF(__pyx_v_variable_name); __Pyx_GIVEREF(__pyx_v_variable_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_variable_name)) __PYX_ERR(0, 346, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_variable_value_labels_type_of_Va_2, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 346, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_msg = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":347 * if type(value) not in int_types: * msg = "variable_value_labels: type of Value %s in variable %s must be int" % (str(value), variable_name) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * readstat_label_int32_value(label_set, value, label.encode("utf-8")) * */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 347, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":345 * * elif curpytype == PYWRITER_INTEGER: * if type(value) not in int_types: # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Value %s in variable %s must be int" % (str(value), variable_name) * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":348 * msg = "variable_value_labels: type of Value %s in variable %s must be int" % (str(value), variable_name) * raise PyreadstatError(msg) * readstat_label_int32_value(label_set, value, label.encode("utf-8")) # <<<<<<<<<<<<<< * * elif curpytype == PYWRITER_LOGICAL: */ __pyx_t_18 = __Pyx_PyInt_As_int32_t(__pyx_v_value); if (unlikely((__pyx_t_18 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 348, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_label, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_s_utf_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_19 = __Pyx_PyObject_AsString(__pyx_t_2); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) __PYX_ERR(0, 348, __pyx_L1_error) readstat_label_int32_value(__pyx_v_label_set, __pyx_t_18, __pyx_t_19); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":344 * readstat_label_double_value(label_set, value, label.encode("utf-8")) * * elif curpytype == PYWRITER_INTEGER: # <<<<<<<<<<<<<< * if type(value) not in int_types: * msg = "variable_value_labels: type of Value %s in variable %s must be int" % (str(value), variable_name) */ break; case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_LOGICAL: /* "pyreadstat/_readstat_writer.pyx":351 * * elif curpytype == PYWRITER_LOGICAL: * if type(value) != bool and (value != 0 and value != 1): # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Value %s in variable %s must be boolean or be 1 or 0" % (str(value), variable_name) * raise PyreadstatError(msg) */ __pyx_t_2 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_value)), ((PyObject*)&PyBool_Type), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 351, __pyx_L1_error) __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 351, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_13) { } else { __pyx_t_11 = __pyx_t_13; goto __pyx_L14_bool_binop_done; } __pyx_t_13 = (__Pyx_PyInt_BoolNeObjC(__pyx_v_value, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 351, __pyx_L1_error) if (__pyx_t_13) { } else { __pyx_t_11 = __pyx_t_13; goto __pyx_L14_bool_binop_done; } __pyx_t_13 = (__Pyx_PyInt_BoolNeObjC(__pyx_v_value, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 351, __pyx_L1_error) __pyx_t_11 = __pyx_t_13; __pyx_L14_bool_binop_done:; if (unlikely(__pyx_t_11)) { /* "pyreadstat/_readstat_writer.pyx":352 * elif curpytype == PYWRITER_LOGICAL: * if type(value) != bool and (value != 0 and value != 1): * msg = "variable_value_labels: type of Value %s in variable %s must be boolean or be 1 or 0" % (str(value), variable_name) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * readstat_label_int32_value(label_set, int(value), label.encode("utf-8")) */ __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error); __Pyx_INCREF(__pyx_v_variable_name); __Pyx_GIVEREF(__pyx_v_variable_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_variable_name)) __PYX_ERR(0, 352, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_variable_value_labels_type_of_Va_3, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_msg = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":353 * if type(value) != bool and (value != 0 and value != 1): * msg = "variable_value_labels: type of Value %s in variable %s must be boolean or be 1 or 0" % (str(value), variable_name) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * readstat_label_int32_value(label_set, int(value), label.encode("utf-8")) * */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 353, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 353, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":351 * * elif curpytype == PYWRITER_LOGICAL: * if type(value) != bool and (value != 0 and value != 1): # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Value %s in variable %s must be boolean or be 1 or 0" % (str(value), variable_name) * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":354 * msg = "variable_value_labels: type of Value %s in variable %s must be boolean or be 1 or 0" % (str(value), variable_name) * raise PyreadstatError(msg) * readstat_label_int32_value(label_set, int(value), label.encode("utf-8")) # <<<<<<<<<<<<<< * * elif curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: */ __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_18 = __Pyx_PyInt_As_int32_t(__pyx_t_2); if (unlikely((__pyx_t_18 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 354, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_label, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_s_utf_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 354, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_19 = __Pyx_PyObject_AsString(__pyx_t_2); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) __PYX_ERR(0, 354, __pyx_L1_error) readstat_label_int32_value(__pyx_v_label_set, __pyx_t_18, __pyx_t_19); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":350 * readstat_label_int32_value(label_set, value, label.encode("utf-8")) * * elif curpytype == PYWRITER_LOGICAL: # <<<<<<<<<<<<<< * if type(value) != bool and (value != 0 and value != 1): * msg = "variable_value_labels: type of Value %s in variable %s must be boolean or be 1 or 0" % (str(value), variable_name) */ break; case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER: /* "pyreadstat/_readstat_writer.pyx":356 * readstat_label_int32_value(label_set, int(value), label.encode("utf-8")) * * elif curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: # <<<<<<<<<<<<<< * value = str(value) * readstat_label_string_value(label_set, value.encode("utf-8"), label.encode("utf-8")) */ case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT: /* "pyreadstat/_readstat_writer.pyx":357 * * elif curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: * value = str(value) # <<<<<<<<<<<<<< * readstat_label_string_value(label_set, value.encode("utf-8"), label.encode("utf-8")) * */ __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":358 * elif curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: * value = str(value) * readstat_label_string_value(label_set, value.encode("utf-8"), label.encode("utf-8")) # <<<<<<<<<<<<<< * * elif curpytype in (PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US): */ __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_s_utf_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_20 = __Pyx_PyObject_AsString(__pyx_t_2); if (unlikely((!__pyx_t_20) && PyErr_Occurred())) __PYX_ERR(0, 358, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_label, __pyx_n_s_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_kp_s_utf_8}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 358, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_21 = __Pyx_PyObject_AsString(__pyx_t_8); if (unlikely((!__pyx_t_21) && PyErr_Occurred())) __PYX_ERR(0, 358, __pyx_L1_error) readstat_label_string_value(__pyx_v_label_set, __pyx_t_20, __pyx_t_21); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "pyreadstat/_readstat_writer.pyx":356 * readstat_label_int32_value(label_set, int(value), label.encode("utf-8")) * * elif curpytype == PYWRITER_CHARACTER or curpytype == PYWRITER_OBJECT: # <<<<<<<<<<<<<< * value = str(value) * readstat_label_string_value(label_set, value.encode("utf-8"), label.encode("utf-8")) */ break; case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE: /* "pyreadstat/_readstat_writer.pyx":360 * readstat_label_string_value(label_set, value.encode("utf-8"), label.encode("utf-8")) * * elif curpytype in (PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US): # <<<<<<<<<<<<<< * if type(value) not in nat_types: * msg = "variable_value_labels: type of Value %s in variable %s must match the type of the column in pandas and be of type date, datetime or time" % (str(value), variable_name) */ case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US: /* "pyreadstat/_readstat_writer.pyx":361 * * elif curpytype in (PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US): * if type(value) not in nat_types: # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Value %s in variable %s must match the type of the column in pandas and be of type date, datetime or time" % (str(value), variable_name) * raise PyreadstatError(msg) */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_nat_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 361, __pyx_L1_error) } __pyx_t_11 = (__Pyx_PySet_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_value)), __pyx_v_10pyreadstat_16_readstat_writer_nat_types, Py_NE)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 361, __pyx_L1_error) if (unlikely(__pyx_t_11)) { /* "pyreadstat/_readstat_writer.pyx":362 * elif curpytype in (PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US): * if type(value) not in nat_types: * msg = "variable_value_labels: type of Value %s in variable %s must match the type of the column in pandas and be of type date, datetime or time" % (str(value), variable_name) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * double_val = convert_datetimelike_to_number(file_format, curpytype, value) */ __pyx_t_8 = __Pyx_PyObject_Str(__pyx_v_value); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8)) __PYX_ERR(0, 362, __pyx_L1_error); __Pyx_INCREF(__pyx_v_variable_name); __Pyx_GIVEREF(__pyx_v_variable_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_variable_name)) __PYX_ERR(0, 362, __pyx_L1_error); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_variable_value_labels_type_of_Va_4, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_msg = __pyx_t_8; __pyx_t_8 = 0; /* "pyreadstat/_readstat_writer.pyx":363 * if type(value) not in nat_types: * msg = "variable_value_labels: type of Value %s in variable %s must match the type of the column in pandas and be of type date, datetime or time" % (str(value), variable_name) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * double_val = convert_datetimelike_to_number(file_format, curpytype, value) * readstat_label_double_value(label_set, double_val, label.encode("utf-8")) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 363, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_msg}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 363, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(0, 363, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":361 * * elif curpytype in (PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US): * if type(value) not in nat_types: # <<<<<<<<<<<<<< * msg = "variable_value_labels: type of Value %s in variable %s must match the type of the column in pandas and be of type date, datetime or time" % (str(value), variable_name) * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":364 * msg = "variable_value_labels: type of Value %s in variable %s must match the type of the column in pandas and be of type date, datetime or time" % (str(value), variable_name) * raise PyreadstatError(msg) * double_val = convert_datetimelike_to_number(file_format, curpytype, value) # <<<<<<<<<<<<<< * readstat_label_double_value(label_set, double_val, label.encode("utf-8")) * */ __pyx_t_16 = __pyx_f_10pyreadstat_16_readstat_writer_convert_datetimelike_to_number(__pyx_v_file_format, __pyx_v_curpytype, __pyx_v_value); if (unlikely(__pyx_t_16 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 364, __pyx_L1_error) __pyx_v_double_val = __pyx_t_16; /* "pyreadstat/_readstat_writer.pyx":365 * raise PyreadstatError(msg) * double_val = convert_datetimelike_to_number(file_format, curpytype, value) * readstat_label_double_value(label_set, double_val, label.encode("utf-8")) # <<<<<<<<<<<<<< * * return label_set */ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_label, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_s_utf_8}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_17 = __Pyx_PyObject_AsString(__pyx_t_8); if (unlikely((!__pyx_t_17) && PyErr_Occurred())) __PYX_ERR(0, 365, __pyx_L1_error) readstat_label_double_value(__pyx_v_label_set, __pyx_v_double_val, __pyx_t_17); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* "pyreadstat/_readstat_writer.pyx":360 * readstat_label_string_value(label_set, value.encode("utf-8"), label.encode("utf-8")) * * elif curpytype in (PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US): # <<<<<<<<<<<<<< * if type(value) not in nat_types: * msg = "variable_value_labels: type of Value %s in variable %s must match the type of the column in pandas and be of type date, datetime or time" % (str(value), variable_name) */ break; default: break; } /* "pyreadstat/_readstat_writer.pyx":323 * label_set = readstat_add_label_set(writer, curtype, labelset_name.encode("utf-8")) * * for value, label in value_labels.items(): # <<<<<<<<<<<<<< * * if type(label) != str: */ __pyx_L3_continue:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":367 * readstat_label_double_value(label_set, double_val, label.encode("utf-8")) * * return label_set # <<<<<<<<<<<<<< * * cdef void add_missing_ranges(list cur_ranges, readstat_variable_t *variable, pywriter_variable_type vartype, str variablename) except *: */ __pyx_r = __pyx_v_label_set; goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":309 * return result * * cdef readstat_label_set_t *set_value_label(readstat_writer_t *writer, dict value_labels, str labelset_name, # <<<<<<<<<<<<<< * pywriter_variable_type curpytype, dst_file_format file_format, str variable_name, * list user_missing_tags) except *: */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("pyreadstat._readstat_writer.set_value_label", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_value); __Pyx_XDECREF(__pyx_v_label); __Pyx_XDECREF(__pyx_v_msg); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":369 * return label_set * * cdef void add_missing_ranges(list cur_ranges, readstat_variable_t *variable, pywriter_variable_type vartype, str variablename) except *: # <<<<<<<<<<<<<< * """ * Adding missing ranges, user defined missing discrete values both numeric and character, */ static void __pyx_f_10pyreadstat_16_readstat_writer_add_missing_ranges(PyObject *__pyx_v_cur_ranges, readstat_variable_t *__pyx_v_variable, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __pyx_v_vartype, PyObject *__pyx_v_variablename) { int __pyx_v_range_values; int __pyx_v_discrete_values; int __pyx_v_discrete_strings; PyObject *__pyx_v_cur_range = NULL; PyObject *__pyx_v_hi = NULL; PyObject *__pyx_v_lo = NULL; PyObject *__pyx_v_msg = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_t_8; double __pyx_t_9; double __pyx_t_10; Py_ssize_t __pyx_t_11; char const *__pyx_t_12; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("add_missing_ranges", 1); /* "pyreadstat/_readstat_writer.pyx":375 * """ * * cdef int range_values = 0 # <<<<<<<<<<<<<< * cdef int discrete_values = 0 * cdef int discrete_strings = 0 */ __pyx_v_range_values = 0; /* "pyreadstat/_readstat_writer.pyx":376 * * cdef int range_values = 0 * cdef int discrete_values = 0 # <<<<<<<<<<<<<< * cdef int discrete_strings = 0 * */ __pyx_v_discrete_values = 0; /* "pyreadstat/_readstat_writer.pyx":377 * cdef int range_values = 0 * cdef int discrete_values = 0 * cdef int discrete_strings = 0 # <<<<<<<<<<<<<< * * for cur_range in cur_ranges: */ __pyx_v_discrete_strings = 0; /* "pyreadstat/_readstat_writer.pyx":379 * cdef int discrete_strings = 0 * * for cur_range in cur_ranges: # <<<<<<<<<<<<<< * if isinstance(cur_range, dict): * hi = cur_range.get("hi") */ if (unlikely(__pyx_v_cur_ranges == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 379, __pyx_L1_error) } __pyx_t_1 = __pyx_v_cur_ranges; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 379, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 379, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_cur_range, __pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":380 * * for cur_range in cur_ranges: * if isinstance(cur_range, dict): # <<<<<<<<<<<<<< * hi = cur_range.get("hi") * lo = cur_range.get("lo") */ __pyx_t_4 = PyDict_Check(__pyx_v_cur_range); if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":381 * for cur_range in cur_ranges: * if isinstance(cur_range, dict): * hi = cur_range.get("hi") # <<<<<<<<<<<<<< * lo = cur_range.get("lo") * if hi is None or lo is None: */ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_cur_range, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 381, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_n_s_hi}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 381, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_XDECREF_SET(__pyx_v_hi, __pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":382 * if isinstance(cur_range, dict): * hi = cur_range.get("hi") * lo = cur_range.get("lo") # <<<<<<<<<<<<<< * if hi is None or lo is None: * msg = "dictionaries in missing_ranges must have the keys hi and lo" */ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_cur_range, __pyx_n_s_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_n_s_lo}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_XDECREF_SET(__pyx_v_lo, __pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":383 * hi = cur_range.get("hi") * lo = cur_range.get("lo") * if hi is None or lo is None: # <<<<<<<<<<<<<< * msg = "dictionaries in missing_ranges must have the keys hi and lo" * raise PyreadstatError(msg) */ __pyx_t_8 = (__pyx_v_hi == Py_None); if (!__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L7_bool_binop_done; } __pyx_t_8 = (__pyx_v_lo == Py_None); __pyx_t_4 = __pyx_t_8; __pyx_L7_bool_binop_done:; if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":384 * lo = cur_range.get("lo") * if hi is None or lo is None: * msg = "dictionaries in missing_ranges must have the keys hi and lo" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * if type(hi) in numeric_types and type(lo) in numeric_types: */ __Pyx_INCREF(__pyx_kp_s_dictionaries_in_missing_ranges_m); __pyx_v_msg = __pyx_kp_s_dictionaries_in_missing_ranges_m; /* "pyreadstat/_readstat_writer.pyx":385 * if hi is None or lo is None: * msg = "dictionaries in missing_ranges must have the keys hi and lo" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * if type(hi) in numeric_types and type(lo) in numeric_types: * if vartype not in pywriter_numeric_types: */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 385, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 385, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":383 * hi = cur_range.get("hi") * lo = cur_range.get("lo") * if hi is None or lo is None: # <<<<<<<<<<<<<< * msg = "dictionaries in missing_ranges must have the keys hi and lo" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":386 * msg = "dictionaries in missing_ranges must have the keys hi and lo" * raise PyreadstatError(msg) * if type(hi) in numeric_types and type(lo) in numeric_types: # <<<<<<<<<<<<<< * if vartype not in pywriter_numeric_types: * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename */ if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_numeric_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 386, __pyx_L1_error) } __pyx_t_8 = (__Pyx_PySet_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_hi)), __pyx_v_10pyreadstat_16_readstat_writer_numeric_types, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 386, __pyx_L1_error) if (__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L10_bool_binop_done; } if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_numeric_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 386, __pyx_L1_error) } __pyx_t_8 = (__Pyx_PySet_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_lo)), __pyx_v_10pyreadstat_16_readstat_writer_numeric_types, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 386, __pyx_L1_error) __pyx_t_4 = __pyx_t_8; __pyx_L10_bool_binop_done:; if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":387 * raise PyreadstatError(msg) * if type(hi) in numeric_types and type(lo) in numeric_types: * if vartype not in pywriter_numeric_types: # <<<<<<<<<<<<<< * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_v_vartype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 387, __pyx_L1_error) } __pyx_t_4 = (__Pyx_PySet_ContainsTF(__pyx_t_3, __pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types, Py_NE)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 387, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":388 * if type(hi) in numeric_types and type(lo) in numeric_types: * if vartype not in pywriter_numeric_types: * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * if hi == lo: */ __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_numeric_missing_ranges_value_giv, __pyx_v_variablename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_msg = __pyx_t_3; __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":389 * if vartype not in pywriter_numeric_types: * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * if hi == lo: * check_exit_status(readstat_variable_add_missing_double_value(variable, hi)) */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 389, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":387 * raise PyreadstatError(msg) * if type(hi) in numeric_types and type(lo) in numeric_types: * if vartype not in pywriter_numeric_types: # <<<<<<<<<<<<<< * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":390 * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) * if hi == lo: # <<<<<<<<<<<<<< * check_exit_status(readstat_variable_add_missing_double_value(variable, hi)) * discrete_values += 1 */ __pyx_t_3 = PyObject_RichCompare(__pyx_v_hi, __pyx_v_lo, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 390, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 390, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":391 * raise PyreadstatError(msg) * if hi == lo: * check_exit_status(readstat_variable_add_missing_double_value(variable, hi)) # <<<<<<<<<<<<<< * discrete_values += 1 * else: */ __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_hi); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 391, __pyx_L1_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_variable_add_missing_double_value(__pyx_v_variable, __pyx_t_9)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 391, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":392 * if hi == lo: * check_exit_status(readstat_variable_add_missing_double_value(variable, hi)) * discrete_values += 1 # <<<<<<<<<<<<<< * else: * check_exit_status(readstat_variable_add_missing_double_range(variable, lo, hi)) */ __pyx_v_discrete_values = (__pyx_v_discrete_values + 1); /* "pyreadstat/_readstat_writer.pyx":390 * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) * if hi == lo: # <<<<<<<<<<<<<< * check_exit_status(readstat_variable_add_missing_double_value(variable, hi)) * discrete_values += 1 */ goto __pyx_L13; } /* "pyreadstat/_readstat_writer.pyx":394 * discrete_values += 1 * else: * check_exit_status(readstat_variable_add_missing_double_range(variable, lo, hi)) # <<<<<<<<<<<<<< * range_values += 1 * elif type(hi) == str and type(lo) == str: */ /*else*/ { __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_v_lo); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 394, __pyx_L1_error) __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_hi); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 394, __pyx_L1_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_variable_add_missing_double_range(__pyx_v_variable, __pyx_t_9, __pyx_t_10)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 394, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":395 * else: * check_exit_status(readstat_variable_add_missing_double_range(variable, lo, hi)) * range_values += 1 # <<<<<<<<<<<<<< * elif type(hi) == str and type(lo) == str: * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: */ __pyx_v_range_values = (__pyx_v_range_values + 1); } __pyx_L13:; /* "pyreadstat/_readstat_writer.pyx":386 * msg = "dictionaries in missing_ranges must have the keys hi and lo" * raise PyreadstatError(msg) * if type(hi) in numeric_types and type(lo) in numeric_types: # <<<<<<<<<<<<<< * if vartype not in pywriter_numeric_types: * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename */ goto __pyx_L9; } /* "pyreadstat/_readstat_writer.pyx":396 * check_exit_status(readstat_variable_add_missing_double_range(variable, lo, hi)) * range_values += 1 * elif type(hi) == str and type(lo) == str: # <<<<<<<<<<<<<< * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: * msg = "character missing_ranges value given for non character variable %s" %variablename */ __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_hi)), ((PyObject *)(&PyString_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 396, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 396, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_8) { } else { __pyx_t_4 = __pyx_t_8; goto __pyx_L14_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_lo)), ((PyObject *)(&PyString_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 396, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 396, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __pyx_t_8; __pyx_L14_bool_binop_done:; if (likely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":397 * range_values += 1 * elif type(hi) == str and type(lo) == str: * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: # <<<<<<<<<<<<<< * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) */ switch (__pyx_v_vartype) { case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT: __pyx_t_4 = 0; break; default: __pyx_t_4 = 1; break; } if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":398 * elif type(hi) == str and type(lo) == str: * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: * msg = "character missing_ranges value given for non character variable %s" %variablename # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * if hi == lo: */ __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_character_missing_ranges_value_g, __pyx_v_variablename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_msg = __pyx_t_3; __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":399 * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * if hi == lo: * if len(hi) > 8: */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 399, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":397 * range_values += 1 * elif type(hi) == str and type(lo) == str: * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: # <<<<<<<<<<<<<< * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":400 * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) * if hi == lo: # <<<<<<<<<<<<<< * if len(hi) > 8: * msg = "missing_ranges: string values length must not be larger than 8" */ __pyx_t_3 = PyObject_RichCompare(__pyx_v_hi, __pyx_v_lo, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 400, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 400, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":401 * raise PyreadstatError(msg) * if hi == lo: * if len(hi) > 8: # <<<<<<<<<<<<<< * msg = "missing_ranges: string values length must not be larger than 8" * raise PyreadstatError(msg) */ __pyx_t_11 = PyObject_Length(__pyx_v_hi); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 401, __pyx_L1_error) __pyx_t_4 = (__pyx_t_11 > 8); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":402 * if hi == lo: * if len(hi) > 8: * msg = "missing_ranges: string values length must not be larger than 8" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_string_value(variable, hi))#.encode("utf-8"))) */ __Pyx_INCREF(__pyx_kp_s_missing_ranges_string_values_len); __pyx_v_msg = __pyx_kp_s_missing_ranges_string_values_len; /* "pyreadstat/_readstat_writer.pyx":403 * if len(hi) > 8: * msg = "missing_ranges: string values length must not be larger than 8" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * check_exit_status(readstat_variable_add_missing_string_value(variable, hi))#.encode("utf-8"))) * discrete_strings += 1 */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 403, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":401 * raise PyreadstatError(msg) * if hi == lo: * if len(hi) > 8: # <<<<<<<<<<<<<< * msg = "missing_ranges: string values length must not be larger than 8" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":404 * msg = "missing_ranges: string values length must not be larger than 8" * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_string_value(variable, hi))#.encode("utf-8"))) # <<<<<<<<<<<<<< * discrete_strings += 1 * else: */ __pyx_t_12 = __Pyx_PyObject_AsString(__pyx_v_hi); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 404, __pyx_L1_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_variable_add_missing_string_value(__pyx_v_variable, __pyx_t_12)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 404, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":405 * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_string_value(variable, hi))#.encode("utf-8"))) * discrete_strings += 1 # <<<<<<<<<<<<<< * else: * #check_exit_status(readstat_variable_add_missing_string_range(variable, lo, hi)) */ __pyx_v_discrete_strings = (__pyx_v_discrete_strings + 1); /* "pyreadstat/_readstat_writer.pyx":400 * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) * if hi == lo: # <<<<<<<<<<<<<< * if len(hi) > 8: * msg = "missing_ranges: string values length must not be larger than 8" */ goto __pyx_L17; } /* "pyreadstat/_readstat_writer.pyx":408 * else: * #check_exit_status(readstat_variable_add_missing_string_range(variable, lo, hi)) * msg = "missing_ranges: hi and lo values must be both the same for string type" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * else: */ /*else*/ { __Pyx_INCREF(__pyx_kp_s_missing_ranges_hi_and_lo_values); __pyx_v_msg = __pyx_kp_s_missing_ranges_hi_and_lo_values; /* "pyreadstat/_readstat_writer.pyx":409 * #check_exit_status(readstat_variable_add_missing_string_range(variable, lo, hi)) * msg = "missing_ranges: hi and lo values must be both the same for string type" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * else: * msg = "missing_ranges: hi and lo values must be both either of numeric or string type" */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 409, __pyx_L1_error) } __pyx_L17:; /* "pyreadstat/_readstat_writer.pyx":396 * check_exit_status(readstat_variable_add_missing_double_range(variable, lo, hi)) * range_values += 1 * elif type(hi) == str and type(lo) == str: # <<<<<<<<<<<<<< * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: * msg = "character missing_ranges value given for non character variable %s" %variablename */ goto __pyx_L9; } /* "pyreadstat/_readstat_writer.pyx":411 * raise PyreadstatError(msg) * else: * msg = "missing_ranges: hi and lo values must be both either of numeric or string type" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * else: */ /*else*/ { __Pyx_INCREF(__pyx_kp_s_missing_ranges_hi_and_lo_values_2); __pyx_v_msg = __pyx_kp_s_missing_ranges_hi_and_lo_values_2; /* "pyreadstat/_readstat_writer.pyx":412 * else: * msg = "missing_ranges: hi and lo values must be both either of numeric or string type" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * else: * if type(cur_range) in numeric_types: */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 412, __pyx_L1_error) } __pyx_L9:; /* "pyreadstat/_readstat_writer.pyx":380 * * for cur_range in cur_ranges: * if isinstance(cur_range, dict): # <<<<<<<<<<<<<< * hi = cur_range.get("hi") * lo = cur_range.get("lo") */ goto __pyx_L5; } /* "pyreadstat/_readstat_writer.pyx":414 * raise PyreadstatError(msg) * else: * if type(cur_range) in numeric_types: # <<<<<<<<<<<<<< * if vartype not in pywriter_numeric_types: * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename */ /*else*/ { if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_numeric_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 414, __pyx_L1_error) } __pyx_t_4 = (__Pyx_PySet_ContainsTF(((PyObject *)Py_TYPE(__pyx_v_cur_range)), __pyx_v_10pyreadstat_16_readstat_writer_numeric_types, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 414, __pyx_L1_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":415 * else: * if type(cur_range) in numeric_types: * if vartype not in pywriter_numeric_types: # <<<<<<<<<<<<<< * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_v_vartype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 415, __pyx_L1_error) } __pyx_t_4 = (__Pyx_PySet_ContainsTF(__pyx_t_3, __pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types, Py_NE)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":416 * if type(cur_range) in numeric_types: * if vartype not in pywriter_numeric_types: * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_double_value(variable, cur_range)) */ __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_numeric_missing_ranges_value_giv, __pyx_v_variablename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_msg = __pyx_t_3; __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":417 * if vartype not in pywriter_numeric_types: * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * check_exit_status(readstat_variable_add_missing_double_value(variable, cur_range)) * discrete_values += 1 */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 417, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":415 * else: * if type(cur_range) in numeric_types: * if vartype not in pywriter_numeric_types: # <<<<<<<<<<<<<< * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":418 * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_double_value(variable, cur_range)) # <<<<<<<<<<<<<< * discrete_values += 1 * elif type(cur_range) == str: */ __pyx_t_10 = __pyx_PyFloat_AsDouble(__pyx_v_cur_range); if (unlikely((__pyx_t_10 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 418, __pyx_L1_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_variable_add_missing_double_value(__pyx_v_variable, __pyx_t_10)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 418, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":419 * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_double_value(variable, cur_range)) * discrete_values += 1 # <<<<<<<<<<<<<< * elif type(cur_range) == str: * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: */ __pyx_v_discrete_values = (__pyx_v_discrete_values + 1); /* "pyreadstat/_readstat_writer.pyx":414 * raise PyreadstatError(msg) * else: * if type(cur_range) in numeric_types: # <<<<<<<<<<<<<< * if vartype not in pywriter_numeric_types: * msg = "numeric missing_ranges value given for non numeric variable %s" %variablename */ goto __pyx_L19; } /* "pyreadstat/_readstat_writer.pyx":420 * check_exit_status(readstat_variable_add_missing_double_value(variable, cur_range)) * discrete_values += 1 * elif type(cur_range) == str: # <<<<<<<<<<<<<< * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: * msg = "character missing_ranges value given for non character variable %s" %variablename */ __pyx_t_3 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_cur_range)), ((PyObject *)(&PyString_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 420, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":421 * discrete_values += 1 * elif type(cur_range) == str: * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: # <<<<<<<<<<<<<< * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) */ switch (__pyx_v_vartype) { case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT: __pyx_t_4 = 0; break; default: __pyx_t_4 = 1; break; } if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":422 * elif type(cur_range) == str: * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: * msg = "character missing_ranges value given for non character variable %s" %variablename # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * if len(cur_range) > 8: */ __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_character_missing_ranges_value_g, __pyx_v_variablename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_msg = __pyx_t_3; __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":423 * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * if len(cur_range) > 8: * msg = "missing_ranges: string values length must not be larger than 8" */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 423, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":421 * discrete_values += 1 * elif type(cur_range) == str: * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: # <<<<<<<<<<<<<< * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":424 * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) * if len(cur_range) > 8: # <<<<<<<<<<<<<< * msg = "missing_ranges: string values length must not be larger than 8" * raise PyreadstatError(msg) */ __pyx_t_11 = PyObject_Length(__pyx_v_cur_range); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 424, __pyx_L1_error) __pyx_t_4 = (__pyx_t_11 > 8); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":425 * raise PyreadstatError(msg) * if len(cur_range) > 8: * msg = "missing_ranges: string values length must not be larger than 8" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_string_value(variable, cur_range))#.encode("utf-8"))) */ __Pyx_INCREF(__pyx_kp_s_missing_ranges_string_values_len); __pyx_v_msg = __pyx_kp_s_missing_ranges_string_values_len; /* "pyreadstat/_readstat_writer.pyx":426 * if len(cur_range) > 8: * msg = "missing_ranges: string values length must not be larger than 8" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * check_exit_status(readstat_variable_add_missing_string_value(variable, cur_range))#.encode("utf-8"))) * discrete_strings += 1 */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 426, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 426, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":424 * msg = "character missing_ranges value given for non character variable %s" %variablename * raise PyreadstatError(msg) * if len(cur_range) > 8: # <<<<<<<<<<<<<< * msg = "missing_ranges: string values length must not be larger than 8" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":427 * msg = "missing_ranges: string values length must not be larger than 8" * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_string_value(variable, cur_range))#.encode("utf-8"))) # <<<<<<<<<<<<<< * discrete_strings += 1 * else: */ __pyx_t_12 = __Pyx_PyObject_AsString(__pyx_v_cur_range); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) __PYX_ERR(0, 427, __pyx_L1_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_variable_add_missing_string_value(__pyx_v_variable, __pyx_t_12)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 427, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":428 * raise PyreadstatError(msg) * check_exit_status(readstat_variable_add_missing_string_value(variable, cur_range))#.encode("utf-8"))) * discrete_strings += 1 # <<<<<<<<<<<<<< * else: * msg = "missing_ranges: values must be both either of numeric or string type" */ __pyx_v_discrete_strings = (__pyx_v_discrete_strings + 1); /* "pyreadstat/_readstat_writer.pyx":420 * check_exit_status(readstat_variable_add_missing_double_value(variable, cur_range)) * discrete_values += 1 * elif type(cur_range) == str: # <<<<<<<<<<<<<< * if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: * msg = "character missing_ranges value given for non character variable %s" %variablename */ goto __pyx_L19; } /* "pyreadstat/_readstat_writer.pyx":430 * discrete_strings += 1 * else: * msg = "missing_ranges: values must be both either of numeric or string type" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ /*else*/ { __Pyx_INCREF(__pyx_kp_s_missing_ranges_values_must_be_bo); __pyx_v_msg = __pyx_kp_s_missing_ranges_values_must_be_bo; /* "pyreadstat/_readstat_writer.pyx":431 * else: * msg = "missing_ranges: values must be both either of numeric or string type" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * if discrete_strings > 3: */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 431, __pyx_L1_error) } __pyx_L19:; } __pyx_L5:; /* "pyreadstat/_readstat_writer.pyx":433 * raise PyreadstatError(msg) * * if discrete_strings > 3: # <<<<<<<<<<<<<< * msg = "missing_ranges: max 3 string values per variable allowed" * raise PyreadstatError(msg) */ __pyx_t_4 = (__pyx_v_discrete_strings > 3); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":434 * * if discrete_strings > 3: * msg = "missing_ranges: max 3 string values per variable allowed" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * if range_values: */ __Pyx_INCREF(__pyx_kp_s_missing_ranges_max_3_string_valu); __pyx_v_msg = __pyx_kp_s_missing_ranges_max_3_string_valu; /* "pyreadstat/_readstat_writer.pyx":435 * if discrete_strings > 3: * msg = "missing_ranges: max 3 string values per variable allowed" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * if range_values: * if range_values > 1: */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 435, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":433 * raise PyreadstatError(msg) * * if discrete_strings > 3: # <<<<<<<<<<<<<< * msg = "missing_ranges: max 3 string values per variable allowed" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":436 * msg = "missing_ranges: max 3 string values per variable allowed" * raise PyreadstatError(msg) * if range_values: # <<<<<<<<<<<<<< * if range_values > 1: * msg = "missing_ranges: max 1 range value per variable allowed" */ __pyx_t_4 = (__pyx_v_range_values != 0); if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":437 * raise PyreadstatError(msg) * if range_values: * if range_values > 1: # <<<<<<<<<<<<<< * msg = "missing_ranges: max 1 range value per variable allowed" * raise PyreadstatError(msg) */ __pyx_t_4 = (__pyx_v_range_values > 1); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":438 * if range_values: * if range_values > 1: * msg = "missing_ranges: max 1 range value per variable allowed" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * if discrete_values > 1: */ __Pyx_INCREF(__pyx_kp_s_missing_ranges_max_1_range_value); __pyx_v_msg = __pyx_kp_s_missing_ranges_max_1_range_value; /* "pyreadstat/_readstat_writer.pyx":439 * if range_values > 1: * msg = "missing_ranges: max 1 range value per variable allowed" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * if discrete_values > 1: * msg = "missing_ranges: max 1 discrete numeric value if combined with 1 range value per variable allowed" */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 439, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":437 * raise PyreadstatError(msg) * if range_values: * if range_values > 1: # <<<<<<<<<<<<<< * msg = "missing_ranges: max 1 range value per variable allowed" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":440 * msg = "missing_ranges: max 1 range value per variable allowed" * raise PyreadstatError(msg) * if discrete_values > 1: # <<<<<<<<<<<<<< * msg = "missing_ranges: max 1 discrete numeric value if combined with 1 range value per variable allowed" * raise PyreadstatError(msg) */ __pyx_t_4 = (__pyx_v_discrete_values > 1); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":441 * raise PyreadstatError(msg) * if discrete_values > 1: * msg = "missing_ranges: max 1 discrete numeric value if combined with 1 range value per variable allowed" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * if discrete_values >3: */ __Pyx_INCREF(__pyx_kp_s_missing_ranges_max_1_discrete_nu); __pyx_v_msg = __pyx_kp_s_missing_ranges_max_1_discrete_nu; /* "pyreadstat/_readstat_writer.pyx":442 * if discrete_values > 1: * msg = "missing_ranges: max 1 discrete numeric value if combined with 1 range value per variable allowed" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * if discrete_values >3: * msg = "missing_ranges: max 3 discrete numeric values per variable allowed" */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 442, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":440 * msg = "missing_ranges: max 1 range value per variable allowed" * raise PyreadstatError(msg) * if discrete_values > 1: # <<<<<<<<<<<<<< * msg = "missing_ranges: max 1 discrete numeric value if combined with 1 range value per variable allowed" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":436 * msg = "missing_ranges: max 3 string values per variable allowed" * raise PyreadstatError(msg) * if range_values: # <<<<<<<<<<<<<< * if range_values > 1: * msg = "missing_ranges: max 1 range value per variable allowed" */ } /* "pyreadstat/_readstat_writer.pyx":443 * msg = "missing_ranges: max 1 discrete numeric value if combined with 1 range value per variable allowed" * raise PyreadstatError(msg) * if discrete_values >3: # <<<<<<<<<<<<<< * msg = "missing_ranges: max 3 discrete numeric values per variable allowed" * raise PyreadstatError(msg) */ __pyx_t_4 = (__pyx_v_discrete_values > 3); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":444 * raise PyreadstatError(msg) * if discrete_values >3: * msg = "missing_ranges: max 3 discrete numeric values per variable allowed" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ __Pyx_INCREF(__pyx_kp_s_missing_ranges_max_3_discrete_nu); __pyx_v_msg = __pyx_kp_s_missing_ranges_max_3_discrete_nu; /* "pyreadstat/_readstat_writer.pyx":445 * if discrete_values >3: * msg = "missing_ranges: max 3 discrete numeric values per variable allowed" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * cdef void set_variable_alignment(readstat_variable_t *variable, str alignment_str, str var_name) except *: */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 445, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":443 * msg = "missing_ranges: max 1 discrete numeric value if combined with 1 range value per variable allowed" * raise PyreadstatError(msg) * if discrete_values >3: # <<<<<<<<<<<<<< * msg = "missing_ranges: max 3 discrete numeric values per variable allowed" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":379 * cdef int discrete_strings = 0 * * for cur_range in cur_ranges: # <<<<<<<<<<<<<< * if isinstance(cur_range, dict): * hi = cur_range.get("hi") */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":369 * return label_set * * cdef void add_missing_ranges(list cur_ranges, readstat_variable_t *variable, pywriter_variable_type vartype, str variablename) except *: # <<<<<<<<<<<<<< * """ * Adding missing ranges, user defined missing discrete values both numeric and character, */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("pyreadstat._readstat_writer.add_missing_ranges", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_v_cur_range); __Pyx_XDECREF(__pyx_v_hi); __Pyx_XDECREF(__pyx_v_lo); __Pyx_XDECREF(__pyx_v_msg); __Pyx_RefNannyFinishContext(); } /* "pyreadstat/_readstat_writer.pyx":447 * raise PyreadstatError(msg) * * cdef void set_variable_alignment(readstat_variable_t *variable, str alignment_str, str var_name) except *: # <<<<<<<<<<<<<< * """ * Sets the variable alignment, ineffective on SPSS, STATA and XPORT (what about SAS7bdat?) */ static void __pyx_f_10pyreadstat_16_readstat_writer_set_variable_alignment(readstat_variable_t *__pyx_v_variable, PyObject *__pyx_v_alignment_str, PyObject *__pyx_v_var_name) { readstat_alignment_t __pyx_v_alignment; PyObject *__pyx_v_msg = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_variable_alignment", 1); /* "pyreadstat/_readstat_writer.pyx":454 * cdef readstat_alignment_t alignment * * if alignment_str == "right": # <<<<<<<<<<<<<< * alignment = READSTAT_ALIGNMENT_RIGHT * elif alignment_str == "left": */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_alignment_str, __pyx_n_s_right, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 454, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":455 * * if alignment_str == "right": * alignment = READSTAT_ALIGNMENT_RIGHT # <<<<<<<<<<<<<< * elif alignment_str == "left": * alignment = READSTAT_ALIGNMENT_LEFT */ __pyx_v_alignment = READSTAT_ALIGNMENT_RIGHT; /* "pyreadstat/_readstat_writer.pyx":454 * cdef readstat_alignment_t alignment * * if alignment_str == "right": # <<<<<<<<<<<<<< * alignment = READSTAT_ALIGNMENT_RIGHT * elif alignment_str == "left": */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":456 * if alignment_str == "right": * alignment = READSTAT_ALIGNMENT_RIGHT * elif alignment_str == "left": # <<<<<<<<<<<<<< * alignment = READSTAT_ALIGNMENT_LEFT * elif alignment_str == "center": */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_alignment_str, __pyx_n_s_left, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 456, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":457 * alignment = READSTAT_ALIGNMENT_RIGHT * elif alignment_str == "left": * alignment = READSTAT_ALIGNMENT_LEFT # <<<<<<<<<<<<<< * elif alignment_str == "center": * alignment = READSTAT_ALIGNMENT_CENTER */ __pyx_v_alignment = READSTAT_ALIGNMENT_LEFT; /* "pyreadstat/_readstat_writer.pyx":456 * if alignment_str == "right": * alignment = READSTAT_ALIGNMENT_RIGHT * elif alignment_str == "left": # <<<<<<<<<<<<<< * alignment = READSTAT_ALIGNMENT_LEFT * elif alignment_str == "center": */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":458 * elif alignment_str == "left": * alignment = READSTAT_ALIGNMENT_LEFT * elif alignment_str == "center": # <<<<<<<<<<<<<< * alignment = READSTAT_ALIGNMENT_CENTER * elif alignment_str == "unknown": */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_alignment_str, __pyx_n_s_center, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 458, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":459 * alignment = READSTAT_ALIGNMENT_LEFT * elif alignment_str == "center": * alignment = READSTAT_ALIGNMENT_CENTER # <<<<<<<<<<<<<< * elif alignment_str == "unknown": * alignment = READSTAT_ALIGNMENT_UNKNOWN */ __pyx_v_alignment = READSTAT_ALIGNMENT_CENTER; /* "pyreadstat/_readstat_writer.pyx":458 * elif alignment_str == "left": * alignment = READSTAT_ALIGNMENT_LEFT * elif alignment_str == "center": # <<<<<<<<<<<<<< * alignment = READSTAT_ALIGNMENT_CENTER * elif alignment_str == "unknown": */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":460 * elif alignment_str == "center": * alignment = READSTAT_ALIGNMENT_CENTER * elif alignment_str == "unknown": # <<<<<<<<<<<<<< * alignment = READSTAT_ALIGNMENT_UNKNOWN * else: */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_alignment_str, __pyx_n_s_unknown, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 460, __pyx_L1_error) if (likely(__pyx_t_1)) { /* "pyreadstat/_readstat_writer.pyx":461 * alignment = READSTAT_ALIGNMENT_CENTER * elif alignment_str == "unknown": * alignment = READSTAT_ALIGNMENT_UNKNOWN # <<<<<<<<<<<<<< * else: * msg = "alignment for variable %s must be either right, center, left or unknown got %s instead" % (var_name, alignment_str) */ __pyx_v_alignment = READSTAT_ALIGNMENT_UNKNOWN; /* "pyreadstat/_readstat_writer.pyx":460 * elif alignment_str == "center": * alignment = READSTAT_ALIGNMENT_CENTER * elif alignment_str == "unknown": # <<<<<<<<<<<<<< * alignment = READSTAT_ALIGNMENT_UNKNOWN * else: */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":463 * alignment = READSTAT_ALIGNMENT_UNKNOWN * else: * msg = "alignment for variable %s must be either right, center, left or unknown got %s instead" % (var_name, alignment_str) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ /*else*/ { __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_var_name); __Pyx_GIVEREF(__pyx_v_var_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_var_name)) __PYX_ERR(0, 463, __pyx_L1_error); __Pyx_INCREF(__pyx_v_alignment_str); __Pyx_GIVEREF(__pyx_v_alignment_str); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_alignment_str)) __PYX_ERR(0, 463, __pyx_L1_error); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_alignment_for_variable_s_must_be, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":464 * else: * msg = "alignment for variable %s must be either right, center, left or unknown got %s instead" % (var_name, alignment_str) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * readstat_variable_set_alignment(variable, alignment) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 464, __pyx_L1_error) } __pyx_L3:; /* "pyreadstat/_readstat_writer.pyx":466 * raise PyreadstatError(msg) * * readstat_variable_set_alignment(variable, alignment) # <<<<<<<<<<<<<< * * cdef void set_variable_display_width(readstat_variable_t *variable, int display_width, str var_name) except *: */ readstat_variable_set_alignment(__pyx_v_variable, __pyx_v_alignment); /* "pyreadstat/_readstat_writer.pyx":447 * raise PyreadstatError(msg) * * cdef void set_variable_alignment(readstat_variable_t *variable, str alignment_str, str var_name) except *: # <<<<<<<<<<<<<< * """ * Sets the variable alignment, ineffective on SPSS, STATA and XPORT (what about SAS7bdat?) */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_writer.set_variable_alignment", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_v_msg); __Pyx_RefNannyFinishContext(); } /* "pyreadstat/_readstat_writer.pyx":468 * readstat_variable_set_alignment(variable, alignment) * * cdef void set_variable_display_width(readstat_variable_t *variable, int display_width, str var_name) except *: # <<<<<<<<<<<<<< * """ * Sets the variable display width (SPSS). Not effective on STATA. (what about SAS7BDAT?) */ static void __pyx_f_10pyreadstat_16_readstat_writer_set_variable_display_width(readstat_variable_t *__pyx_v_variable, int __pyx_v_display_width, CYTHON_UNUSED PyObject *__pyx_v_var_name) { /* "pyreadstat/_readstat_writer.pyx":473 * """ * * readstat_variable_set_display_width(variable, display_width) # <<<<<<<<<<<<<< * * cdef void set_variable_measure(readstat_variable_t *variable, str measure_str, str var_name) except *: */ readstat_variable_set_display_width(__pyx_v_variable, __pyx_v_display_width); /* "pyreadstat/_readstat_writer.pyx":468 * readstat_variable_set_alignment(variable, alignment) * * cdef void set_variable_display_width(readstat_variable_t *variable, int display_width, str var_name) except *: # <<<<<<<<<<<<<< * """ * Sets the variable display width (SPSS). Not effective on STATA. (what about SAS7BDAT?) */ /* function exit code */ } /* "pyreadstat/_readstat_writer.pyx":475 * readstat_variable_set_display_width(variable, display_width) * * cdef void set_variable_measure(readstat_variable_t *variable, str measure_str, str var_name) except *: # <<<<<<<<<<<<<< * """ * sets the variable measure type (SPSS). Not effective on STATA. */ static void __pyx_f_10pyreadstat_16_readstat_writer_set_variable_measure(readstat_variable_t *__pyx_v_variable, PyObject *__pyx_v_measure_str, PyObject *__pyx_v_var_name) { readstat_measure_t __pyx_v_measure; PyObject *__pyx_v_msg = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_variable_measure", 1); /* "pyreadstat/_readstat_writer.pyx":482 * cdef readstat_measure_t measure * * if measure_str == "nominal": # <<<<<<<<<<<<<< * measure = READSTAT_MEASURE_NOMINAL * elif measure_str == "ordinal": */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_measure_str, __pyx_n_s_nominal, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 482, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":483 * * if measure_str == "nominal": * measure = READSTAT_MEASURE_NOMINAL # <<<<<<<<<<<<<< * elif measure_str == "ordinal": * measure = READSTAT_MEASURE_ORDINAL */ __pyx_v_measure = READSTAT_MEASURE_NOMINAL; /* "pyreadstat/_readstat_writer.pyx":482 * cdef readstat_measure_t measure * * if measure_str == "nominal": # <<<<<<<<<<<<<< * measure = READSTAT_MEASURE_NOMINAL * elif measure_str == "ordinal": */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":484 * if measure_str == "nominal": * measure = READSTAT_MEASURE_NOMINAL * elif measure_str == "ordinal": # <<<<<<<<<<<<<< * measure = READSTAT_MEASURE_ORDINAL * elif measure_str == "scale": */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_measure_str, __pyx_n_s_ordinal, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 484, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":485 * measure = READSTAT_MEASURE_NOMINAL * elif measure_str == "ordinal": * measure = READSTAT_MEASURE_ORDINAL # <<<<<<<<<<<<<< * elif measure_str == "scale": * measure = READSTAT_MEASURE_SCALE */ __pyx_v_measure = READSTAT_MEASURE_ORDINAL; /* "pyreadstat/_readstat_writer.pyx":484 * if measure_str == "nominal": * measure = READSTAT_MEASURE_NOMINAL * elif measure_str == "ordinal": # <<<<<<<<<<<<<< * measure = READSTAT_MEASURE_ORDINAL * elif measure_str == "scale": */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":486 * elif measure_str == "ordinal": * measure = READSTAT_MEASURE_ORDINAL * elif measure_str == "scale": # <<<<<<<<<<<<<< * measure = READSTAT_MEASURE_SCALE * elif measure_str == "unknown": */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_measure_str, __pyx_n_s_scale, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 486, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/_readstat_writer.pyx":487 * measure = READSTAT_MEASURE_ORDINAL * elif measure_str == "scale": * measure = READSTAT_MEASURE_SCALE # <<<<<<<<<<<<<< * elif measure_str == "unknown": * measure = READSTAT_MEASURE_UNKNOWN */ __pyx_v_measure = READSTAT_MEASURE_SCALE; /* "pyreadstat/_readstat_writer.pyx":486 * elif measure_str == "ordinal": * measure = READSTAT_MEASURE_ORDINAL * elif measure_str == "scale": # <<<<<<<<<<<<<< * measure = READSTAT_MEASURE_SCALE * elif measure_str == "unknown": */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":488 * elif measure_str == "scale": * measure = READSTAT_MEASURE_SCALE * elif measure_str == "unknown": # <<<<<<<<<<<<<< * measure = READSTAT_MEASURE_UNKNOWN * else: */ __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_measure_str, __pyx_n_s_unknown, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 488, __pyx_L1_error) if (likely(__pyx_t_1)) { /* "pyreadstat/_readstat_writer.pyx":489 * measure = READSTAT_MEASURE_SCALE * elif measure_str == "unknown": * measure = READSTAT_MEASURE_UNKNOWN # <<<<<<<<<<<<<< * else: * msg = "measure for variable %s must be either nominal, ordinal, scale or unknown got %s instead" % (var_name, measure_str) */ __pyx_v_measure = READSTAT_MEASURE_UNKNOWN; /* "pyreadstat/_readstat_writer.pyx":488 * elif measure_str == "scale": * measure = READSTAT_MEASURE_SCALE * elif measure_str == "unknown": # <<<<<<<<<<<<<< * measure = READSTAT_MEASURE_UNKNOWN * else: */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":491 * measure = READSTAT_MEASURE_UNKNOWN * else: * msg = "measure for variable %s must be either nominal, ordinal, scale or unknown got %s instead" % (var_name, measure_str) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ /*else*/ { __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_var_name); __Pyx_GIVEREF(__pyx_v_var_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_var_name)) __PYX_ERR(0, 491, __pyx_L1_error); __Pyx_INCREF(__pyx_v_measure_str); __Pyx_GIVEREF(__pyx_v_measure_str); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_measure_str)) __PYX_ERR(0, 491, __pyx_L1_error); __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_measure_for_variable_s_must_be_e, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":492 * else: * msg = "measure for variable %s must be either nominal, ordinal, scale or unknown got %s instead" % (var_name, measure_str) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * readstat_variable_set_measure(variable, measure); */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 492, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 492, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 492, __pyx_L1_error) } __pyx_L3:; /* "pyreadstat/_readstat_writer.pyx":494 * raise PyreadstatError(msg) * * readstat_variable_set_measure(variable, measure); # <<<<<<<<<<<<<< * * */ readstat_variable_set_measure(__pyx_v_variable, __pyx_v_measure); /* "pyreadstat/_readstat_writer.pyx":475 * readstat_variable_set_display_width(variable, display_width) * * cdef void set_variable_measure(readstat_variable_t *variable, str measure_str, str var_name) except *: # <<<<<<<<<<<<<< * """ * sets the variable measure type (SPSS). Not effective on STATA. */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_writer.set_variable_measure", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_v_msg); __Pyx_RefNannyFinishContext(); } /* "pyreadstat/_readstat_writer.pyx":497 * * * cdef ssize_t write_bytes(const void *data, size_t _len, void *ctx) noexcept: # <<<<<<<<<<<<<< * """ * for the writer an explicit function to write must be defined */ static Py_ssize_t __pyx_f_10pyreadstat_16_readstat_writer_write_bytes(void const *__pyx_v_data, size_t __pyx_v__len, void *__pyx_v_ctx) { int __pyx_v_fd; Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_bytes", 1); /* "pyreadstat/_readstat_writer.pyx":502 * """ * cdef int fd * fd = (ctx)[0] # <<<<<<<<<<<<<< * if os.name=='nt': * return _write(fd, data, _len) */ __pyx_v_fd = (((int *)__pyx_v_ctx)[0]); /* "pyreadstat/_readstat_writer.pyx":503 * cdef int fd * fd = (ctx)[0] * if os.name=='nt': # <<<<<<<<<<<<<< * return _write(fd, data, _len) * else: */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_nt, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 503, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":504 * fd = (ctx)[0] * if os.name=='nt': * return _write(fd, data, _len) # <<<<<<<<<<<<<< * else: * return write(fd, data, _len) */ __pyx_r = _write(__pyx_v_fd, __pyx_v_data, __pyx_v__len); goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":503 * cdef int fd * fd = (ctx)[0] * if os.name=='nt': # <<<<<<<<<<<<<< * return _write(fd, data, _len) * else: */ } /* "pyreadstat/_readstat_writer.pyx":506 * return _write(fd, data, _len) * else: * return write(fd, data, _len) # <<<<<<<<<<<<<< * * cdef void _check_exit_status(readstat_error_t retcode) except *: */ /*else*/ { __pyx_r = write(__pyx_v_fd, __pyx_v_data, __pyx_v__len); goto __pyx_L0; } /* "pyreadstat/_readstat_writer.pyx":497 * * * cdef ssize_t write_bytes(const void *data, size_t _len, void *ctx) noexcept: # <<<<<<<<<<<<<< * """ * for the writer an explicit function to write must be defined */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_WriteUnraisable("pyreadstat._readstat_writer.write_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_r = 0; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":508 * return write(fd, data, _len) * * cdef void _check_exit_status(readstat_error_t retcode) except *: # <<<<<<<<<<<<<< * """ * transforms a readstat exit status to a python error if status is not READSTAT OK */ static void __pyx_f_10pyreadstat_16_readstat_writer__check_exit_status(readstat_error_t __pyx_v_retcode) { char *__pyx_v_err_readstat; PyObject *__pyx_v_err_message = 0; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_check_exit_status", 1); /* "pyreadstat/_readstat_writer.pyx":515 * cdef char * err_readstat * cdef str err_message * if retcode != READSTAT_OK: # <<<<<<<<<<<<<< * err_readstat = readstat_error_message(retcode) * err_message = err_readstat */ __pyx_t_1 = (__pyx_v_retcode != READSTAT_OK); if (unlikely(__pyx_t_1)) { /* "pyreadstat/_readstat_writer.pyx":516 * cdef str err_message * if retcode != READSTAT_OK: * err_readstat = readstat_error_message(retcode) # <<<<<<<<<<<<<< * err_message = err_readstat * raise ReadstatError(err_message) */ __pyx_v_err_readstat = readstat_error_message(__pyx_v_retcode); /* "pyreadstat/_readstat_writer.pyx":517 * if retcode != READSTAT_OK: * err_readstat = readstat_error_message(retcode) * err_message = err_readstat # <<<<<<<<<<<<<< * raise ReadstatError(err_message) * */ __pyx_t_2 = __Pyx_PyStr_FromString(__pyx_v_err_readstat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 517, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_err_message = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":518 * err_readstat = readstat_error_message(retcode) * err_message = err_readstat * raise ReadstatError(err_message) # <<<<<<<<<<<<<< * * cdef int open_file(bytes filename_path): */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ReadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_err_message}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 518, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":515 * cdef char * err_readstat * cdef str err_message * if retcode != READSTAT_OK: # <<<<<<<<<<<<<< * err_readstat = readstat_error_message(retcode) * err_message = err_readstat */ } /* "pyreadstat/_readstat_writer.pyx":508 * return write(fd, data, _len) * * cdef void _check_exit_status(readstat_error_t retcode) except *: # <<<<<<<<<<<<<< * """ * transforms a readstat exit status to a python error if status is not READSTAT OK */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_writer._check_exit_status", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_v_err_message); __Pyx_RefNannyFinishContext(); } /* "pyreadstat/_readstat_writer.pyx":520 * raise ReadstatError(err_message) * * cdef int open_file(bytes filename_path): # <<<<<<<<<<<<<< * * cdef int fd */ static int __pyx_f_10pyreadstat_16_readstat_writer_open_file(PyObject *__pyx_v_filename_path) { int __pyx_v_fd; int __pyx_v_flags; Py_ssize_t __pyx_v_length; char *__pyx_v_path; PyObject *__pyx_v_filename_str = NULL; wchar_t *__pyx_v_u16_path; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; int __pyx_t_5; wchar_t *__pyx_t_6; char *__pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("open_file", 1); /* "pyreadstat/_readstat_writer.pyx":529 * cdef char *path * * if os.name == "nt": # <<<<<<<<<<<<<< * filename_str = os.fsdecode(filename_path) * u16_path = PyUnicode_AsWideCharString(filename_str, &length) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_nt, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":530 * * if os.name == "nt": * filename_str = os.fsdecode(filename_path) # <<<<<<<<<<<<<< * u16_path = PyUnicode_AsWideCharString(filename_str, &length) * flags = _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_fsdecode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_filename_path}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_filename_str = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":531 * if os.name == "nt": * filename_str = os.fsdecode(filename_path) * u16_path = PyUnicode_AsWideCharString(filename_str, &length) # <<<<<<<<<<<<<< * flags = _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC * fd = _wsopen(u16_path, flags, _SH_DENYRW, _S_IREAD | _S_IWRITE) */ __pyx_t_6 = PyUnicode_AsWideCharString(__pyx_v_filename_str, (&__pyx_v_length)); if (unlikely(__pyx_t_6 == ((wchar_t *)NULL))) __PYX_ERR(0, 531, __pyx_L1_error) __pyx_v_u16_path = __pyx_t_6; /* "pyreadstat/_readstat_writer.pyx":532 * filename_str = os.fsdecode(filename_path) * u16_path = PyUnicode_AsWideCharString(filename_str, &length) * flags = _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC # <<<<<<<<<<<<<< * fd = _wsopen(u16_path, flags, _SH_DENYRW, _S_IREAD | _S_IWRITE) * else: */ __pyx_v_flags = (((_O_WRONLY | _O_CREAT) | _O_BINARY) | _O_TRUNC); /* "pyreadstat/_readstat_writer.pyx":533 * u16_path = PyUnicode_AsWideCharString(filename_str, &length) * flags = _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC * fd = _wsopen(u16_path, flags, _SH_DENYRW, _S_IREAD | _S_IWRITE) # <<<<<<<<<<<<<< * else: * #filename_bytes = filename_path.encode("utf-8") */ __pyx_v_fd = _wsopen(__pyx_v_u16_path, __pyx_v_flags, _SH_DENYRW, (_S_IREAD | _S_IWRITE)); /* "pyreadstat/_readstat_writer.pyx":529 * cdef char *path * * if os.name == "nt": # <<<<<<<<<<<<<< * filename_str = os.fsdecode(filename_path) * u16_path = PyUnicode_AsWideCharString(filename_str, &length) */ goto __pyx_L3; } /* "pyreadstat/_readstat_writer.pyx":536 * else: * #filename_bytes = filename_path.encode("utf-8") * path = filename_path # <<<<<<<<<<<<<< * flags = O_WRONLY | O_CREAT | O_TRUNC * fd = open(path, flags, 0644) */ /*else*/ { if (unlikely(__pyx_v_filename_path == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 536, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_filename_path); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 536, __pyx_L1_error) __pyx_v_path = ((char *)__pyx_t_7); /* "pyreadstat/_readstat_writer.pyx":537 * #filename_bytes = filename_path.encode("utf-8") * path = filename_path * flags = O_WRONLY | O_CREAT | O_TRUNC # <<<<<<<<<<<<<< * fd = open(path, flags, 0644) * */ __pyx_v_flags = ((O_WRONLY | O_CREAT) | O_TRUNC); /* "pyreadstat/_readstat_writer.pyx":538 * path = filename_path * flags = O_WRONLY | O_CREAT | O_TRUNC * fd = open(path, flags, 0644) # <<<<<<<<<<<<<< * * return fd */ __pyx_v_fd = open(__pyx_v_path, __pyx_v_flags, 0644); } __pyx_L3:; /* "pyreadstat/_readstat_writer.pyx":540 * fd = open(path, flags, 0644) * * return fd # <<<<<<<<<<<<<< * * cdef int close_file(int fd): */ __pyx_r = __pyx_v_fd; goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":520 * raise ReadstatError(err_message) * * cdef int open_file(bytes filename_path): # <<<<<<<<<<<<<< * * cdef int fd */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat._readstat_writer.open_file", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_filename_str); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":542 * return fd * * cdef int close_file(int fd): # <<<<<<<<<<<<<< * if os.name == "nt": * return _close(fd) */ static int __pyx_f_10pyreadstat_16_readstat_writer_close_file(int __pyx_v_fd) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("close_file", 1); /* "pyreadstat/_readstat_writer.pyx":543 * * cdef int close_file(int fd): * if os.name == "nt": # <<<<<<<<<<<<<< * return _close(fd) * else: */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_n_s_nt, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 543, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":544 * cdef int close_file(int fd): * if os.name == "nt": * return _close(fd) # <<<<<<<<<<<<<< * else: * return close(fd) */ __pyx_r = _close(__pyx_v_fd); goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":543 * * cdef int close_file(int fd): * if os.name == "nt": # <<<<<<<<<<<<<< * return _close(fd) * else: */ } /* "pyreadstat/_readstat_writer.pyx":546 * return _close(fd) * else: * return close(fd) # <<<<<<<<<<<<<< * * cdef int run_write(df, object filename_path, dst_file_format file_format, str file_label, object column_labels, */ /*else*/ { __pyx_r = close(__pyx_v_fd); goto __pyx_L0; } /* "pyreadstat/_readstat_writer.pyx":542 * return fd * * cdef int close_file(int fd): # <<<<<<<<<<<<<< * if os.name == "nt": * return _close(fd) */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("pyreadstat._readstat_writer.close_file", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/_readstat_writer.pyx":548 * return close(fd) * * cdef int run_write(df, object filename_path, dst_file_format file_format, str file_label, object column_labels, # <<<<<<<<<<<<<< * int file_format_version, str note, str table_name, dict variable_value_labels, * dict missing_ranges, dict missing_user_values, dict variable_alignment, */ static int __pyx_f_10pyreadstat_16_readstat_writer_run_write(PyObject *__pyx_v_df, PyObject *__pyx_v_filename_path, __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format __pyx_v_file_format, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, int __pyx_v_file_format_version, PyObject *__pyx_v_note, PyObject *__pyx_v_table_name, PyObject *__pyx_v_variable_value_labels, PyObject *__pyx_v_missing_ranges, PyObject *__pyx_v_missing_user_values, PyObject *__pyx_v_variable_alignment, PyObject *__pyx_v_variable_display_width, PyObject *__pyx_v_variable_measure, PyObject *__pyx_v_variable_format, int __pyx_v_row_compression) { PyObject *__pyx_v_k = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_msg = NULL; PyObject *__pyx_v_valid_user_missing = NULL; CYTHON_UNUSED PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_missing_values = NULL; PyObject *__pyx_v_val = NULL; readstat_writer_t *__pyx_v_writer; PyObject *__pyx_v_file_label_bytes = 0; char *__pyx_v_file_labl; PyObject *__pyx_v_col_names = 0; PyObject *__pyx_v_variable_name = NULL; PyObject *__pyx_v_col_types = 0; int __pyx_v_row_count; int __pyx_v_col_count; PyObject *__pyx_v_col_names_to_types = 0; readstat_variable_t *__pyx_v_variable; __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __pyx_v_curtype; int __pyx_v_max_length; char *__pyx_v_curformat; PyObject *__pyx_v_tempformat = 0; int __pyx_v_col_indx; PyObject *__pyx_v_cur_col_label = 0; int __pyx_v_col_label_count; readstat_variable_t *__pyx_v_tempvar; PyObject *__pyx_v_curvalstr = 0; double __pyx_v_dtimelikeval; PyObject *__pyx_v_value_labels = 0; int __pyx_v_lblset_cnt; readstat_label_set_t *__pyx_v_label_set; PyObject *__pyx_v_col_label_temp = 0; int __pyx_v_hasdatetime64; PyObject *__pyx_v_pywriter_types = 0; PyObject *__pyx_v_df2 = 0; float __pyx_v_mulfac; CYTHON_UNUSED PyObject *__pyx_v_filename_bytes = NULL; int __pyx_v_fd; PyObject *__pyx_v_table_name_bytes = NULL; char *__pyx_v_tab_name; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_v_labelset_name = NULL; PyObject *__pyx_v_curuser_missing = NULL; PyObject *__pyx_v_cur_ranges = NULL; PyObject *__pyx_v_cur_alignment = NULL; PyObject *__pyx_v_cur_display_width = NULL; PyObject *__pyx_v_cur_measure = NULL; double __pyx_v_offset_secs; PyObject *__pyx_v_rowcnt = NULL; PyObject *__pyx_v_row = NULL; PyObject *__pyx_v_curval = NULL; PyObject *__pyx_v_is_missing = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_7genexpr__pyx_v_k = NULL; PyObject *__pyx_7genexpr__pyx_v_v = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; int __pyx_t_4; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; Py_ssize_t __pyx_t_7; PyObject *(*__pyx_t_8)(PyObject *); PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *(*__pyx_t_11)(PyObject *); Py_ssize_t __pyx_t_12; PyObject *(*__pyx_t_13)(PyObject *); long __pyx_t_14; PyObject *__pyx_t_15 = NULL; PyObject *__pyx_t_16 = NULL; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; PyObject *__pyx_t_20 = NULL; char *__pyx_t_21; char const *__pyx_t_22; int __pyx_t_23; int __pyx_t_24; int __pyx_t_25; int __pyx_t_26; __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __pyx_t_27; char const *__pyx_t_28; readstat_type_t __pyx_t_29; char const *__pyx_t_30; char const *__pyx_t_31; readstat_label_set_t *__pyx_t_32; double __pyx_t_33; int32_t __pyx_t_34; char const *__pyx_t_35; char const *__pyx_t_36; PyObject *__pyx_t_37 = NULL; PyObject *__pyx_t_38 = NULL; PyObject *__pyx_t_39 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("run_write", 0); __Pyx_INCREF(__pyx_v_filename_path); __Pyx_INCREF(__pyx_v_column_labels); /* "pyreadstat/_readstat_writer.pyx":558 * """ * * if not isinstance(df, pd.DataFrame): # <<<<<<<<<<<<<< * raise PyreadstatError("first argument must be a pandas data frame") * */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_df, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 558, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (!__pyx_t_3); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":559 * * if not isinstance(df, pd.DataFrame): * raise PyreadstatError("first argument must be a pandas data frame") # <<<<<<<<<<<<<< * * if variable_value_labels: */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 559, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_kp_s_first_argument_must_be_a_pandas}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 559, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 559, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":558 * """ * * if not isinstance(df, pd.DataFrame): # <<<<<<<<<<<<<< * raise PyreadstatError("first argument must be a pandas data frame") * */ } /* "pyreadstat/_readstat_writer.pyx":561 * raise PyreadstatError("first argument must be a pandas data frame") * * if variable_value_labels: # <<<<<<<<<<<<<< * for k,v in variable_value_labels.items(): * if type(v) != dict: */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_variable_value_labels); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 561, __pyx_L1_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":562 * * if variable_value_labels: * for k,v in variable_value_labels.items(): # <<<<<<<<<<<<<< * if type(v) != dict: * msg = "variable_value_labels: value for key %s must be dict, got %s" % (k, str(type(v))) */ if (unlikely(__pyx_v_variable_value_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 562, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_variable_value_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 562, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 562, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 562, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 562, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 562, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_8(__pyx_t_1); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 562, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 562, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_9 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 562, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L8_unpacking_done; __pyx_L7_unpacking_failed:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 562, __pyx_L1_error) __pyx_L8_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/_readstat_writer.pyx":563 * if variable_value_labels: * for k,v in variable_value_labels.items(): * if type(v) != dict: # <<<<<<<<<<<<<< * msg = "variable_value_labels: value for key %s must be dict, got %s" % (k, str(type(v))) * raise PyreadstatError(msg) */ __pyx_t_2 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_v)), ((PyObject *)(&PyDict_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 563, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 563, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":564 * for k,v in variable_value_labels.items(): * if type(v) != dict: * msg = "variable_value_labels: value for key %s must be dict, got %s" % (k, str(type(v))) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ __pyx_t_2 = __Pyx_PyObject_Str(((PyObject *)Py_TYPE(__pyx_v_v))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_k); __Pyx_GIVEREF(__pyx_v_k); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_k)) __PYX_ERR(0, 564, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2)) __PYX_ERR(0, 564, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_variable_value_labels_value_for, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_msg = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":565 * if type(v) != dict: * msg = "variable_value_labels: value for key %s must be dict, got %s" % (k, str(type(v))) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * if missing_user_values: */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 565, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":563 * if variable_value_labels: * for k,v in variable_value_labels.items(): * if type(v) != dict: # <<<<<<<<<<<<<< * msg = "variable_value_labels: value for key %s must be dict, got %s" % (k, str(type(v))) * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":562 * * if variable_value_labels: * for k,v in variable_value_labels.items(): # <<<<<<<<<<<<<< * if type(v) != dict: * msg = "variable_value_labels: value for key %s must be dict, got %s" % (k, str(type(v))) */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":561 * raise PyreadstatError("first argument must be a pandas data frame") * * if variable_value_labels: # <<<<<<<<<<<<<< * for k,v in variable_value_labels.items(): * if type(v) != dict: */ } /* "pyreadstat/_readstat_writer.pyx":567 * raise PyreadstatError(msg) * * if missing_user_values: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * valid_user_missing = valid_user_missing_stata */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_missing_user_values); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 567, __pyx_L1_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":568 * * if missing_user_values: * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * valid_user_missing = valid_user_missing_stata * elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA: /* "pyreadstat/_readstat_writer.pyx":569 * if missing_user_values: * if file_format == FILE_FORMAT_DTA: * valid_user_missing = valid_user_missing_stata # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: * valid_user_missing = valid_user_missing_sas */ __Pyx_INCREF(__pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_stata); __pyx_v_valid_user_missing = __pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_stata; /* "pyreadstat/_readstat_writer.pyx":568 * * if missing_user_values: * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * valid_user_missing = valid_user_missing_stata * elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: */ break; case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAS7BDAT: /* "pyreadstat/_readstat_writer.pyx":570 * if file_format == FILE_FORMAT_DTA: * valid_user_missing = valid_user_missing_stata * elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: # <<<<<<<<<<<<<< * valid_user_missing = valid_user_missing_sas * for key, missing_values in missing_user_values.items(): */ case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAS7BCAT: /* "pyreadstat/_readstat_writer.pyx":571 * valid_user_missing = valid_user_missing_stata * elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: * valid_user_missing = valid_user_missing_sas # <<<<<<<<<<<<<< * for key, missing_values in missing_user_values.items(): * if not isinstance(missing_values, list): */ __Pyx_INCREF(__pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_sas); __pyx_v_valid_user_missing = __pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_sas; /* "pyreadstat/_readstat_writer.pyx":570 * if file_format == FILE_FORMAT_DTA: * valid_user_missing = valid_user_missing_stata * elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: # <<<<<<<<<<<<<< * valid_user_missing = valid_user_missing_sas * for key, missing_values in missing_user_values.items(): */ break; default: break; } /* "pyreadstat/_readstat_writer.pyx":572 * elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: * valid_user_missing = valid_user_missing_sas * for key, missing_values in missing_user_values.items(): # <<<<<<<<<<<<<< * if not isinstance(missing_values, list): * msg = "missing_user_values: values in dictionary must be list" */ if (unlikely(__pyx_v_missing_user_values == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 572, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyDict_Items(__pyx_v_missing_user_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 572, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 572, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 572, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 572, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 572, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_8(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 572, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 572, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_9 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); index = 0; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); index = 1; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 572, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L15_unpacking_done; __pyx_L14_unpacking_failed:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 572, __pyx_L1_error) __pyx_L15_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF_SET(__pyx_v_missing_values, __pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/_readstat_writer.pyx":573 * valid_user_missing = valid_user_missing_sas * for key, missing_values in missing_user_values.items(): * if not isinstance(missing_values, list): # <<<<<<<<<<<<<< * msg = "missing_user_values: values in dictionary must be list" * raise PyreadstatError(msg) */ __pyx_t_4 = PyList_Check(__pyx_v_missing_values); __pyx_t_3 = (!__pyx_t_4); if (unlikely(__pyx_t_3)) { /* "pyreadstat/_readstat_writer.pyx":574 * for key, missing_values in missing_user_values.items(): * if not isinstance(missing_values, list): * msg = "missing_user_values: values in dictionary must be list" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * for val in missing_values: */ __Pyx_INCREF(__pyx_kp_s_missing_user_values_values_in_di); __pyx_v_msg = __pyx_kp_s_missing_user_values_values_in_di; /* "pyreadstat/_readstat_writer.pyx":575 * if not isinstance(missing_values, list): * msg = "missing_user_values: values in dictionary must be list" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * for val in missing_values: * if val not in valid_user_missing: */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_msg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 575, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":573 * valid_user_missing = valid_user_missing_sas * for key, missing_values in missing_user_values.items(): * if not isinstance(missing_values, list): # <<<<<<<<<<<<<< * msg = "missing_user_values: values in dictionary must be list" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":576 * msg = "missing_user_values: values in dictionary must be list" * raise PyreadstatError(msg) * for val in missing_values: # <<<<<<<<<<<<<< * if val not in valid_user_missing: * msg = "missing_user_values supports values a to z for Stata and A to Z and _ for SAS, got %s instead" % str(val) */ if (likely(PyList_CheckExact(__pyx_v_missing_values)) || PyTuple_CheckExact(__pyx_v_missing_values)) { __pyx_t_1 = __pyx_v_missing_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0; __pyx_t_13 = NULL; } else { __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_missing_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 576, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 576, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 576, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 576, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 576, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 576, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 576, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_val, __pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/_readstat_writer.pyx":577 * raise PyreadstatError(msg) * for val in missing_values: * if val not in valid_user_missing: # <<<<<<<<<<<<<< * msg = "missing_user_values supports values a to z for Stata and A to Z and _ for SAS, got %s instead" % str(val) * raise PyreadstatError(msg) */ if (unlikely(!__pyx_v_valid_user_missing)) { __Pyx_RaiseUnboundLocalError("valid_user_missing"); __PYX_ERR(0, 577, __pyx_L1_error) } __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_val, __pyx_v_valid_user_missing, Py_NE)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 577, __pyx_L1_error) if (unlikely(__pyx_t_3)) { /* "pyreadstat/_readstat_writer.pyx":578 * for val in missing_values: * if val not in valid_user_missing: * msg = "missing_user_values supports values a to z for Stata and A to Z and _ for SAS, got %s instead" % str(val) # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ __pyx_t_5 = __Pyx_PyObject_Str(__pyx_v_val); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 578, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyString_FormatSafe(__pyx_kp_s_missing_user_values_supports_val, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 578, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_msg = __pyx_t_9; __pyx_t_9 = 0; /* "pyreadstat/_readstat_writer.pyx":579 * if val not in valid_user_missing: * msg = "missing_user_values supports values a to z for Stata and A to Z and _ for SAS, got %s instead" % str(val) * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * cdef readstat_error_t retcode */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_msg}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 579, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 579, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":577 * raise PyreadstatError(msg) * for val in missing_values: * if val not in valid_user_missing: # <<<<<<<<<<<<<< * msg = "missing_user_values supports values a to z for Stata and A to Z and _ for SAS, got %s instead" % str(val) * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":576 * msg = "missing_user_values: values in dictionary must be list" * raise PyreadstatError(msg) * for val in missing_values: # <<<<<<<<<<<<<< * if val not in valid_user_missing: * msg = "missing_user_values supports values a to z for Stata and A to Z and _ for SAS, got %s instead" % str(val) */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":572 * elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: * valid_user_missing = valid_user_missing_sas * for key, missing_values in missing_user_values.items(): # <<<<<<<<<<<<<< * if not isinstance(missing_values, list): * msg = "missing_user_values: values in dictionary must be list" */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":567 * raise PyreadstatError(msg) * * if missing_user_values: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * valid_user_missing = valid_user_missing_stata */ } /* "pyreadstat/_readstat_writer.pyx":590 * cdef char *file_labl * * cdef list col_names = df.columns.values.tolist() # <<<<<<<<<<<<<< * if len(col_names) != len(set(col_names)): * msg = "Non unique column names detected in the dataframe!" */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_values); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_2))) __PYX_ERR(0, 590, __pyx_L1_error) __pyx_v_col_names = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":591 * * cdef list col_names = df.columns.values.tolist() * if len(col_names) != len(set(col_names)): # <<<<<<<<<<<<<< * msg = "Non unique column names detected in the dataframe!" * raise PyreadstatError(msg) */ if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 591, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyList_GET_SIZE(__pyx_v_col_names); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 591, __pyx_L1_error) __pyx_t_2 = PySet_New(__pyx_v_col_names); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = __Pyx_PySet_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 591, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = (__pyx_t_7 != __pyx_t_12); if (unlikely(__pyx_t_3)) { /* "pyreadstat/_readstat_writer.pyx":592 * cdef list col_names = df.columns.values.tolist() * if len(col_names) != len(set(col_names)): * msg = "Non unique column names detected in the dataframe!" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * */ __Pyx_INCREF(__pyx_kp_s_Non_unique_column_names_detected); __pyx_v_msg = __pyx_kp_s_Non_unique_column_names_detected; /* "pyreadstat/_readstat_writer.pyx":593 * if len(col_names) != len(set(col_names)): * msg = "Non unique column names detected in the dataframe!" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * * for variable_name in col_names: */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 593, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":591 * * cdef list col_names = df.columns.values.tolist() * if len(col_names) != len(set(col_names)): # <<<<<<<<<<<<<< * msg = "Non unique column names detected in the dataframe!" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":595 * raise PyreadstatError(msg) * * for variable_name in col_names: # <<<<<<<<<<<<<< * if type(variable_name) != str: * raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) */ if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 595, __pyx_L1_error) } __pyx_t_2 = __pyx_v_col_names; __Pyx_INCREF(__pyx_t_2); __pyx_t_12 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 595, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_12); __Pyx_INCREF(__pyx_t_1); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 595, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 595, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_v_variable_name, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":596 * * for variable_name in col_names: * if type(variable_name) != str: # <<<<<<<<<<<<<< * raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) * if not variable_name[0].isalpha(): */ __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_variable_name)), ((PyObject *)(&PyString_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_3)) { /* "pyreadstat/_readstat_writer.pyx":597 * for variable_name in col_names: * if type(variable_name) != str: * raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) # <<<<<<<<<<<<<< * if not variable_name[0].isalpha(): * raise PyreadstatError("variable name '%s' starts with an illegal (non-alphabetic) character: '%s' (ordinal %s)" % (variable_name, variable_name[0], ord(variable_name[0]))) */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = __Pyx_PyObject_Str(((PyObject *)Py_TYPE(__pyx_v_variable_name))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_v_variable_name); __Pyx_GIVEREF(__pyx_v_variable_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_variable_name)) __PYX_ERR(0, 597, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5)) __PYX_ERR(0, 597, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_variable_name_s_is_of_type_s_and, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_5}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 597, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":596 * * for variable_name in col_names: * if type(variable_name) != str: # <<<<<<<<<<<<<< * raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) * if not variable_name[0].isalpha(): */ } /* "pyreadstat/_readstat_writer.pyx":598 * if type(variable_name) != str: * raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) * if not variable_name[0].isalpha(): # <<<<<<<<<<<<<< * raise PyreadstatError("variable name '%s' starts with an illegal (non-alphabetic) character: '%s' (ordinal %s)" % (variable_name, variable_name[0], ord(variable_name[0]))) * if " " in variable_name: */ __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_variable_name, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isalpha); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 598, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = (!__pyx_t_3); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":599 * raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) * if not variable_name[0].isalpha(): * raise PyreadstatError("variable name '%s' starts with an illegal (non-alphabetic) character: '%s' (ordinal %s)" % (variable_name, variable_name[0], ord(variable_name[0]))) # <<<<<<<<<<<<<< * if " " in variable_name: * raise PyreadstatError("variable name '%s' contains a space, which is not allowed" % variable_name) */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 599, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_variable_name, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 599, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_variable_name, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 599, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_14 = __Pyx_PyObject_Ord(__pyx_t_10); if (unlikely(__pyx_t_14 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 599, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 599, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 599, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_INCREF(__pyx_v_variable_name); __Pyx_GIVEREF(__pyx_v_variable_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_variable_name)) __PYX_ERR(0, 599, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_9)) __PYX_ERR(0, 599, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_10)) __PYX_ERR(0, 599, __pyx_L1_error); __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyString_Format(__pyx_kp_s_variable_name_s_starts_with_an_i, __pyx_t_15); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 599, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_10}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 599, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 599, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":598 * if type(variable_name) != str: * raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) * if not variable_name[0].isalpha(): # <<<<<<<<<<<<<< * raise PyreadstatError("variable name '%s' starts with an illegal (non-alphabetic) character: '%s' (ordinal %s)" % (variable_name, variable_name[0], ord(variable_name[0]))) * if " " in variable_name: */ } /* "pyreadstat/_readstat_writer.pyx":600 * if not variable_name[0].isalpha(): * raise PyreadstatError("variable name '%s' starts with an illegal (non-alphabetic) character: '%s' (ordinal %s)" % (variable_name, variable_name[0], ord(variable_name[0]))) * if " " in variable_name: # <<<<<<<<<<<<<< * raise PyreadstatError("variable name '%s' contains a space, which is not allowed" % variable_name) * */ __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_kp_s__2, __pyx_v_variable_name, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 600, __pyx_L1_error) if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":601 * raise PyreadstatError("variable name '%s' starts with an illegal (non-alphabetic) character: '%s' (ordinal %s)" % (variable_name, variable_name[0], ord(variable_name[0]))) * if " " in variable_name: * raise PyreadstatError("variable name '%s' contains a space, which is not allowed" % variable_name) # <<<<<<<<<<<<<< * * if file_format == FILE_FORMAT_POR: */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 601, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __Pyx_PyString_FormatSafe(__pyx_kp_s_variable_name_s_contains_a_space, __pyx_v_variable_name); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 601, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_15 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_10}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 601, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 601, __pyx_L1_error) /* "pyreadstat/_readstat_writer.pyx":600 * if not variable_name[0].isalpha(): * raise PyreadstatError("variable name '%s' starts with an illegal (non-alphabetic) character: '%s' (ordinal %s)" % (variable_name, variable_name[0], ord(variable_name[0]))) * if " " in variable_name: # <<<<<<<<<<<<<< * raise PyreadstatError("variable name '%s' contains a space, which is not allowed" % variable_name) * */ } /* "pyreadstat/_readstat_writer.pyx":595 * raise PyreadstatError(msg) * * for variable_name in col_names: # <<<<<<<<<<<<<< * if type(variable_name) != str: * raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) */ } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":603 * raise PyreadstatError("variable name '%s' contains a space, which is not allowed" % variable_name) * * if file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * col_names = [x.upper() for x in col_names] * */ __pyx_t_4 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_POR); if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":604 * * if file_format == FILE_FORMAT_POR: * col_names = [x.upper() for x in col_names] # <<<<<<<<<<<<<< * * cdef list col_types = get_pandas_column_types(df, missing_user_values, variable_value_labels) */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 604, __pyx_L1_error) } __pyx_t_1 = __pyx_v_col_names; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 604, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 604, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_upper); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_15 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_col_names, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":603 * raise PyreadstatError("variable name '%s' contains a space, which is not allowed" % variable_name) * * if file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * col_names = [x.upper() for x in col_names] * */ } /* "pyreadstat/_readstat_writer.pyx":606 * col_names = [x.upper() for x in col_names] * * cdef list col_types = get_pandas_column_types(df, missing_user_values, variable_value_labels) # <<<<<<<<<<<<<< * cdef int row_count = len(df) * cdef int col_count = len(col_names) */ __pyx_t_2 = __pyx_f_10pyreadstat_16_readstat_writer_get_pandas_column_types(__pyx_v_df, __pyx_v_missing_user_values, __pyx_v_variable_value_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_col_types = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":607 * * cdef list col_types = get_pandas_column_types(df, missing_user_values, variable_value_labels) * cdef int row_count = len(df) # <<<<<<<<<<<<<< * cdef int col_count = len(col_names) * cdef dict col_names_to_types = {k:v[0] for k,v in zip(col_names, col_types)} */ __pyx_t_12 = PyObject_Length(__pyx_v_df); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 607, __pyx_L1_error) __pyx_v_row_count = __pyx_t_12; /* "pyreadstat/_readstat_writer.pyx":608 * cdef list col_types = get_pandas_column_types(df, missing_user_values, variable_value_labels) * cdef int row_count = len(df) * cdef int col_count = len(col_names) # <<<<<<<<<<<<<< * cdef dict col_names_to_types = {k:v[0] for k,v in zip(col_names, col_types)} * */ if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 608, __pyx_L1_error) } __pyx_t_12 = __Pyx_PyList_GET_SIZE(__pyx_v_col_names); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 608, __pyx_L1_error) __pyx_v_col_count = __pyx_t_12; /* "pyreadstat/_readstat_writer.pyx":609 * cdef int row_count = len(df) * cdef int col_count = len(col_names) * cdef dict col_names_to_types = {k:v[0] for k,v in zip(col_names, col_types)} # <<<<<<<<<<<<<< * * cdef readstat_variable_t *variable */ { /* enter inner scope */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_col_names); __Pyx_GIVEREF(__pyx_v_col_names); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_col_names)) __PYX_ERR(0, 609, __pyx_L35_error); __Pyx_INCREF(__pyx_v_col_types); __Pyx_GIVEREF(__pyx_v_col_types); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_col_types)) __PYX_ERR(0, 609, __pyx_L35_error); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0; __pyx_t_8 = NULL; } else { __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 609, __pyx_L35_error) } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 609, __pyx_L35_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 609, __pyx_L35_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 609, __pyx_L35_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 609, __pyx_L35_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_8(__pyx_t_1); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 609, __pyx_L35_error) } break; } __Pyx_GOTREF(__pyx_t_5); } if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 609, __pyx_L35_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_15 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_10 = PyList_GET_ITEM(sequence, 0); __pyx_t_15 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_15); #else __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_15 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_15); #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); index = 0; __pyx_t_10 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_10)) goto __pyx_L38_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); index = 1; __pyx_t_15 = __pyx_t_11(__pyx_t_9); if (unlikely(!__pyx_t_15)) goto __pyx_L38_unpacking_failed; __Pyx_GOTREF(__pyx_t_15); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_9), 2) < 0) __PYX_ERR(0, 609, __pyx_L35_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L39_unpacking_done; __pyx_L38_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 609, __pyx_L35_error) __pyx_L39_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_k, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_v, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_5 = __Pyx_GetItemInt(__pyx_7genexpr__pyx_v_v, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_7genexpr__pyx_v_k, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 609, __pyx_L35_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __pyx_7genexpr__pyx_v_k = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __pyx_7genexpr__pyx_v_v = 0; goto __pyx_L41_exit_scope; __pyx_L35_error:; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __pyx_7genexpr__pyx_v_k = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __pyx_7genexpr__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L41_exit_scope:; } /* exit inner scope */ __pyx_v_col_names_to_types = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":618 * cdef int col_indx * cdef bytes cur_col_label * cdef int col_label_count = 0 # <<<<<<<<<<<<<< * * cdef readstat_variable_t *tempvar */ __pyx_v_col_label_count = 0; /* "pyreadstat/_readstat_writer.pyx":627 * cdef object values * cdef dict value_labels * cdef int lblset_cnt = 0 # <<<<<<<<<<<<<< * cdef readstat_label_set_t *label_set * cdef list col_label_temp */ __pyx_v_lblset_cnt = 0; /* "pyreadstat/_readstat_writer.pyx":635 * cdef float mulfac, conv2secs * * if hasattr(os, 'fsencode'): # <<<<<<<<<<<<<< * try: * filename_path = os.fsencode(filename_path) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 635, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_HasAttr(__pyx_t_2, __pyx_n_s_fsencode); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 635, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":636 * * if hasattr(os, 'fsencode'): * try: # <<<<<<<<<<<<<< * filename_path = os.fsencode(filename_path) * except UnicodeError: */ { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); /*try:*/ { /* "pyreadstat/_readstat_writer.pyx":637 * if hasattr(os, 'fsencode'): * try: * filename_path = os.fsencode(filename_path) # <<<<<<<<<<<<<< * except UnicodeError: * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L43_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_fsencode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 637, __pyx_L43_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_filename_path}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 637, __pyx_L43_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_filename_path, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":636 * * if hasattr(os, 'fsencode'): * try: # <<<<<<<<<<<<<< * filename_path = os.fsencode(filename_path) * except UnicodeError: */ } __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; goto __pyx_L48_try_end; __pyx_L43_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/_readstat_writer.pyx":638 * try: * filename_path = os.fsencode(filename_path) * except UnicodeError: # <<<<<<<<<<<<<< * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") */ __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeError); if (__pyx_t_6) { __Pyx_AddTraceback("pyreadstat._readstat_writer.run_write", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(0, 638, __pyx_L45_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_1); /* "pyreadstat/_readstat_writer.pyx":639 * filename_path = os.fsencode(filename_path) * except UnicodeError: * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) # <<<<<<<<<<<<<< * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") * else: */ __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_warnings); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 639, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_warn); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 639, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_n_s_sys); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 639, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_getfilesystemencoding); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 639, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_20))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_19, NULL}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_20, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 639, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; } __pyx_t_20 = __Pyx_PyString_FormatSafe(__pyx_kp_s_file_path_could_not_be_encoded_w, __pyx_t_10); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 639, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_20}; __pyx_t_15 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 639, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/_readstat_writer.pyx":640 * except UnicodeError: * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") # <<<<<<<<<<<<<< * else: * if type(filename_path) == str: */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 640, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_fsdecode); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 640, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_20))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_filename_path}; __pyx_t_15 = __Pyx_PyObject_FastCall(__pyx_t_20, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 640, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; } __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_encode); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 640, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 640, __pyx_L45_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_v_filename_bytes = __pyx_t_15; __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L44_exception_handled; } goto __pyx_L45_except_error; /* "pyreadstat/_readstat_writer.pyx":636 * * if hasattr(os, 'fsencode'): * try: # <<<<<<<<<<<<<< * filename_path = os.fsencode(filename_path) * except UnicodeError: */ __pyx_L45_except_error:; __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); goto __pyx_L1_error; __pyx_L44_exception_handled:; __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_L48_try_end:; } /* "pyreadstat/_readstat_writer.pyx":635 * cdef float mulfac, conv2secs * * if hasattr(os, 'fsencode'): # <<<<<<<<<<<<<< * try: * filename_path = os.fsencode(filename_path) */ goto __pyx_L42; } /* "pyreadstat/_readstat_writer.pyx":642 * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") * else: * if type(filename_path) == str: # <<<<<<<<<<<<<< * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: */ /*else*/ { __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_filename_path)), ((PyObject *)(&PyString_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 642, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 642, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":643 * else: * if type(filename_path) == str: * filename_bytes = filename_path.encode('utf-8') # <<<<<<<<<<<<<< * elif type(filename_path) == bytes: * filename_bytes = filename_path */ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename_path, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_s_utf_8}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_filename_bytes = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":642 * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") * else: * if type(filename_path) == str: # <<<<<<<<<<<<<< * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: */ goto __pyx_L51; } /* "pyreadstat/_readstat_writer.pyx":644 * if type(filename_path) == str: * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: # <<<<<<<<<<<<<< * filename_bytes = filename_path * else: */ __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_filename_path)), ((PyObject *)(&PyBytes_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 644, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (likely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":645 * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: * filename_bytes = filename_path # <<<<<<<<<<<<<< * else: * raise PyreadstatError("path must be either str or bytes") */ __Pyx_INCREF(__pyx_v_filename_path); __pyx_v_filename_bytes = __pyx_v_filename_path; /* "pyreadstat/_readstat_writer.pyx":644 * if type(filename_path) == str: * filename_bytes = filename_path.encode('utf-8') * elif type(filename_path) == bytes: # <<<<<<<<<<<<<< * filename_bytes = filename_path * else: */ goto __pyx_L51; } /* "pyreadstat/_readstat_writer.pyx":647 * filename_bytes = filename_path * else: * raise PyreadstatError("path must be either str or bytes") # <<<<<<<<<<<<<< * * filename_path = os.path.expanduser(filename_path) */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_s_path_must_be_either_str_or_bytes}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 647, __pyx_L1_error) } __pyx_L51:; } __pyx_L42:; /* "pyreadstat/_readstat_writer.pyx":649 * raise PyreadstatError("path must be either str or bytes") * * filename_path = os.path.expanduser(filename_path) # <<<<<<<<<<<<<< * cdef int fd = open_file(filename_path) * writer = readstat_writer_init() */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_expanduser); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_filename_path}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_filename_path, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":650 * * filename_path = os.path.expanduser(filename_path) * cdef int fd = open_file(filename_path) # <<<<<<<<<<<<<< * writer = readstat_writer_init() * */ if (!(likely(PyBytes_CheckExact(__pyx_v_filename_path))||((__pyx_v_filename_path) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_v_filename_path))) __PYX_ERR(0, 650, __pyx_L1_error) __pyx_t_6 = __pyx_f_10pyreadstat_16_readstat_writer_open_file(((PyObject*)__pyx_v_filename_path)); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 650, __pyx_L1_error) __pyx_v_fd = __pyx_t_6; /* "pyreadstat/_readstat_writer.pyx":651 * filename_path = os.path.expanduser(filename_path) * cdef int fd = open_file(filename_path) * writer = readstat_writer_init() # <<<<<<<<<<<<<< * * try: */ __pyx_v_writer = readstat_writer_init(); /* "pyreadstat/_readstat_writer.pyx":653 * writer = readstat_writer_init() * * try: # <<<<<<<<<<<<<< * * check_exit_status(readstat_set_data_writer(writer, write_bytes)) */ /*try:*/ { { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_16); /*try:*/ { /* "pyreadstat/_readstat_writer.pyx":655 * try: * * check_exit_status(readstat_set_data_writer(writer, write_bytes)) # <<<<<<<<<<<<<< * * if file_label: */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_set_data_writer(__pyx_v_writer, __pyx_f_10pyreadstat_16_readstat_writer_write_bytes)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 655, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":657 * check_exit_status(readstat_set_data_writer(writer, write_bytes)) * * if file_label: # <<<<<<<<<<<<<< * file_label_bytes = file_label.encode("utf-8") * file_labl = file_label_bytes */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_file_label); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 657, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":658 * * if file_label: * file_label_bytes = file_label.encode("utf-8") # <<<<<<<<<<<<<< * file_labl = file_label_bytes * check_exit_status(readstat_writer_set_file_label(writer, file_labl)) */ __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyString_Type_encode, __pyx_v_file_label, __pyx_kp_s_utf_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_1))) __PYX_ERR(0, 658, __pyx_L55_error) __pyx_v_file_label_bytes = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":659 * if file_label: * file_label_bytes = file_label.encode("utf-8") * file_labl = file_label_bytes # <<<<<<<<<<<<<< * check_exit_status(readstat_writer_set_file_label(writer, file_labl)) * */ if (unlikely(__pyx_v_file_label_bytes == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 659, __pyx_L55_error) } __pyx_t_21 = __Pyx_PyBytes_AsWritableString(__pyx_v_file_label_bytes); if (unlikely((!__pyx_t_21) && PyErr_Occurred())) __PYX_ERR(0, 659, __pyx_L55_error) __pyx_v_file_labl = ((char *)__pyx_t_21); /* "pyreadstat/_readstat_writer.pyx":660 * file_label_bytes = file_label.encode("utf-8") * file_labl = file_label_bytes * check_exit_status(readstat_writer_set_file_label(writer, file_labl)) # <<<<<<<<<<<<<< * * if note: */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_writer_set_file_label(__pyx_v_writer, __pyx_v_file_labl)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 660, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":657 * check_exit_status(readstat_set_data_writer(writer, write_bytes)) * * if file_label: # <<<<<<<<<<<<<< * file_label_bytes = file_label.encode("utf-8") * file_labl = file_label_bytes */ } /* "pyreadstat/_readstat_writer.pyx":662 * check_exit_status(readstat_writer_set_file_label(writer, file_labl)) * * if note: # <<<<<<<<<<<<<< * readstat_add_note(writer, note.encode("utf-8")) * */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_note); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 662, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":663 * * if note: * readstat_add_note(writer, note.encode("utf-8")) # <<<<<<<<<<<<<< * * if file_format_version > -1: */ __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyString_Type_encode, __pyx_v_note, __pyx_kp_s_utf_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_22 = __Pyx_PyObject_AsString(__pyx_t_1); if (unlikely((!__pyx_t_22) && PyErr_Occurred())) __PYX_ERR(0, 663, __pyx_L55_error) readstat_add_note(__pyx_v_writer, __pyx_t_22); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":662 * check_exit_status(readstat_writer_set_file_label(writer, file_labl)) * * if note: # <<<<<<<<<<<<<< * readstat_add_note(writer, note.encode("utf-8")) * */ } /* "pyreadstat/_readstat_writer.pyx":665 * readstat_add_note(writer, note.encode("utf-8")) * * if file_format_version > -1: # <<<<<<<<<<<<<< * check_exit_status(readstat_writer_set_file_format_version(writer, file_format_version)) * */ __pyx_t_4 = (__pyx_v_file_format_version > -1L); if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":666 * * if file_format_version > -1: * check_exit_status(readstat_writer_set_file_format_version(writer, file_format_version)) # <<<<<<<<<<<<<< * * if row_compression: */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_writer_set_file_format_version(__pyx_v_writer, __pyx_v_file_format_version)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":665 * readstat_add_note(writer, note.encode("utf-8")) * * if file_format_version > -1: # <<<<<<<<<<<<<< * check_exit_status(readstat_writer_set_file_format_version(writer, file_format_version)) * */ } /* "pyreadstat/_readstat_writer.pyx":668 * check_exit_status(readstat_writer_set_file_format_version(writer, file_format_version)) * * if row_compression: # <<<<<<<<<<<<<< * check_exit_status(readstat_writer_set_compression(writer, READSTAT_COMPRESS_ROWS)) * */ if (__pyx_v_row_compression) { /* "pyreadstat/_readstat_writer.pyx":669 * * if row_compression: * check_exit_status(readstat_writer_set_compression(writer, READSTAT_COMPRESS_ROWS)) # <<<<<<<<<<<<<< * * # table name is used only for xpt files */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_writer_set_compression(__pyx_v_writer, READSTAT_COMPRESS_ROWS)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 669, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":668 * check_exit_status(readstat_writer_set_file_format_version(writer, file_format_version)) * * if row_compression: # <<<<<<<<<<<<<< * check_exit_status(readstat_writer_set_compression(writer, READSTAT_COMPRESS_ROWS)) * */ } /* "pyreadstat/_readstat_writer.pyx":672 * * # table name is used only for xpt files * if table_name: # <<<<<<<<<<<<<< * table_name_bytes = table_name.encode("utf-8") * tab_name = table_name_bytes */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_table_name); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 672, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":673 * # table name is used only for xpt files * if table_name: * table_name_bytes = table_name.encode("utf-8") # <<<<<<<<<<<<<< * tab_name = table_name_bytes * check_exit_status(readstat_writer_set_table_name(writer, tab_name)) */ __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyString_Type_encode, __pyx_v_table_name, __pyx_kp_s_utf_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 673, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_table_name_bytes = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":674 * if table_name: * table_name_bytes = table_name.encode("utf-8") * tab_name = table_name_bytes # <<<<<<<<<<<<<< * check_exit_status(readstat_writer_set_table_name(writer, tab_name)) * */ __pyx_t_21 = __Pyx_PyObject_AsWritableString(__pyx_v_table_name_bytes); if (unlikely((!__pyx_t_21) && PyErr_Occurred())) __PYX_ERR(0, 674, __pyx_L55_error) __pyx_v_tab_name = ((char *)__pyx_t_21); /* "pyreadstat/_readstat_writer.pyx":675 * table_name_bytes = table_name.encode("utf-8") * tab_name = table_name_bytes * check_exit_status(readstat_writer_set_table_name(writer, tab_name)) # <<<<<<<<<<<<<< * * # add variables */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_writer_set_table_name(__pyx_v_writer, __pyx_v_tab_name)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 675, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":672 * * # table name is used only for xpt files * if table_name: # <<<<<<<<<<<<<< * table_name_bytes = table_name.encode("utf-8") * tab_name = table_name_bytes */ } /* "pyreadstat/_readstat_writer.pyx":678 * * # add variables * if column_labels: # <<<<<<<<<<<<<< * if type(column_labels) != list and type(column_labels) != dict: * raise PyreadstatError("column_labels must be either list or dict!") */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_column_labels); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 678, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":679 * # add variables * if column_labels: * if type(column_labels) != list and type(column_labels) != dict: # <<<<<<<<<<<<<< * raise PyreadstatError("column_labels must be either list or dict!") * if type(column_labels) == dict: */ __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_column_labels)), ((PyObject *)(&PyList_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 679, __pyx_L55_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 679, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L68_bool_binop_done; } __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_column_labels)), ((PyObject *)(&PyDict_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 679, __pyx_L55_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 679, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __pyx_t_3; __pyx_L68_bool_binop_done:; if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":680 * if column_labels: * if type(column_labels) != list and type(column_labels) != dict: * raise PyreadstatError("column_labels must be either list or dict!") # <<<<<<<<<<<<<< * if type(column_labels) == dict: * col_label_temp = list() */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 680, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_s_column_labels_must_be_either_lis}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 680, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 680, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":679 * # add variables * if column_labels: * if type(column_labels) != list and type(column_labels) != dict: # <<<<<<<<<<<<<< * raise PyreadstatError("column_labels must be either list or dict!") * if type(column_labels) == dict: */ } /* "pyreadstat/_readstat_writer.pyx":681 * if type(column_labels) != list and type(column_labels) != dict: * raise PyreadstatError("column_labels must be either list or dict!") * if type(column_labels) == dict: # <<<<<<<<<<<<<< * col_label_temp = list() * for col_indx in range(col_count): */ __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_column_labels)), ((PyObject *)(&PyDict_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 681, __pyx_L55_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 681, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":682 * raise PyreadstatError("column_labels must be either list or dict!") * if type(column_labels) == dict: * col_label_temp = list() # <<<<<<<<<<<<<< * for col_indx in range(col_count): * variable_name = col_names[col_indx] */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_col_label_temp = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":683 * if type(column_labels) == dict: * col_label_temp = list() * for col_indx in range(col_count): # <<<<<<<<<<<<<< * variable_name = col_names[col_indx] * if variable_name in column_labels.keys(): */ __pyx_t_6 = __pyx_v_col_count; __pyx_t_23 = __pyx_t_6; for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) { __pyx_v_col_indx = __pyx_t_24; /* "pyreadstat/_readstat_writer.pyx":684 * col_label_temp = list() * for col_indx in range(col_count): * variable_name = col_names[col_indx] # <<<<<<<<<<<<<< * if variable_name in column_labels.keys(): * col_label_temp.append(column_labels[variable_name]) */ if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 684, __pyx_L55_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_col_names, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_variable_name, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":685 * for col_indx in range(col_count): * variable_name = col_names[col_indx] * if variable_name in column_labels.keys(): # <<<<<<<<<<<<<< * col_label_temp.append(column_labels[variable_name]) * else: */ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_column_labels, __pyx_n_s_keys); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 685, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_25, 0+__pyx_t_25); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 685, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_variable_name, __pyx_t_1, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 685, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":686 * variable_name = col_names[col_indx] * if variable_name in column_labels.keys(): * col_label_temp.append(column_labels[variable_name]) # <<<<<<<<<<<<<< * else: * col_label_temp.append(None) */ __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_column_labels, __pyx_v_variable_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 686, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_26 = __Pyx_PyList_Append(__pyx_v_col_label_temp, __pyx_t_1); if (unlikely(__pyx_t_26 == ((int)-1))) __PYX_ERR(0, 686, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":685 * for col_indx in range(col_count): * variable_name = col_names[col_indx] * if variable_name in column_labels.keys(): # <<<<<<<<<<<<<< * col_label_temp.append(column_labels[variable_name]) * else: */ goto __pyx_L73; } /* "pyreadstat/_readstat_writer.pyx":688 * col_label_temp.append(column_labels[variable_name]) * else: * col_label_temp.append(None) # <<<<<<<<<<<<<< * column_labels = col_label_temp * */ /*else*/ { __pyx_t_26 = __Pyx_PyList_Append(__pyx_v_col_label_temp, Py_None); if (unlikely(__pyx_t_26 == ((int)-1))) __PYX_ERR(0, 688, __pyx_L55_error) } __pyx_L73:; } /* "pyreadstat/_readstat_writer.pyx":689 * else: * col_label_temp.append(None) * column_labels = col_label_temp # <<<<<<<<<<<<<< * * col_label_count = len(column_labels) */ __Pyx_INCREF(__pyx_v_col_label_temp); __Pyx_DECREF_SET(__pyx_v_column_labels, __pyx_v_col_label_temp); /* "pyreadstat/_readstat_writer.pyx":681 * if type(column_labels) != list and type(column_labels) != dict: * raise PyreadstatError("column_labels must be either list or dict!") * if type(column_labels) == dict: # <<<<<<<<<<<<<< * col_label_temp = list() * for col_indx in range(col_count): */ } /* "pyreadstat/_readstat_writer.pyx":691 * column_labels = col_label_temp * * col_label_count = len(column_labels) # <<<<<<<<<<<<<< * if col_label_count != col_count: * raise PyreadstatError("length of column labels must be the same as number of columns") */ __pyx_t_12 = PyObject_Length(__pyx_v_column_labels); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 691, __pyx_L55_error) __pyx_v_col_label_count = __pyx_t_12; /* "pyreadstat/_readstat_writer.pyx":692 * * col_label_count = len(column_labels) * if col_label_count != col_count: # <<<<<<<<<<<<<< * raise PyreadstatError("length of column labels must be the same as number of columns") * */ __pyx_t_4 = (__pyx_v_col_label_count != __pyx_v_col_count); if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":693 * col_label_count = len(column_labels) * if col_label_count != col_count: * raise PyreadstatError("length of column labels must be the same as number of columns") # <<<<<<<<<<<<<< * * for col_indx in range(col_count): */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 693, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_s_length_of_column_labels_must_be}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 693, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 693, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":692 * * col_label_count = len(column_labels) * if col_label_count != col_count: # <<<<<<<<<<<<<< * raise PyreadstatError("length of column labels must be the same as number of columns") * */ } /* "pyreadstat/_readstat_writer.pyx":678 * * # add variables * if column_labels: # <<<<<<<<<<<<<< * if type(column_labels) != list and type(column_labels) != dict: * raise PyreadstatError("column_labels must be either list or dict!") */ } /* "pyreadstat/_readstat_writer.pyx":695 * raise PyreadstatError("length of column labels must be the same as number of columns") * * for col_indx in range(col_count): # <<<<<<<<<<<<<< * curtype, max_length, _ = col_types[col_indx] * variable_name = col_names[col_indx] */ __pyx_t_6 = __pyx_v_col_count; __pyx_t_23 = __pyx_t_6; for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) { __pyx_v_col_indx = __pyx_t_24; /* "pyreadstat/_readstat_writer.pyx":696 * * for col_indx in range(col_count): * curtype, max_length, _ = col_types[col_indx] # <<<<<<<<<<<<<< * variable_name = col_names[col_indx] * variable = readstat_add_variable(writer, variable_name.encode("utf-8"), pandas_to_readstat_types[curtype], max_length) */ if (unlikely(__pyx_v_col_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 696, __pyx_L55_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_col_types, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 696, __pyx_L55_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_15 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); __pyx_t_15 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_15); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 696, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 696, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 696, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_20 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 696, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_20); index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_20); if (unlikely(!__pyx_t_5)) goto __pyx_L77_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_2 = __pyx_t_11(__pyx_t_20); if (unlikely(!__pyx_t_2)) goto __pyx_L77_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 2; __pyx_t_15 = __pyx_t_11(__pyx_t_20); if (unlikely(!__pyx_t_15)) goto __pyx_L77_unpacking_failed; __Pyx_GOTREF(__pyx_t_15); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_20), 3) < 0) __PYX_ERR(0, 696, __pyx_L55_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; goto __pyx_L78_unpacking_done; __pyx_L77_unpacking_failed:; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 696, __pyx_L55_error) __pyx_L78_unpacking_done:; } __pyx_t_27 = ((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)__Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_t_5)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 696, __pyx_L55_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_25 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_25 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 696, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_curtype = __pyx_t_27; __pyx_v_max_length = __pyx_t_25; __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/_readstat_writer.pyx":697 * for col_indx in range(col_count): * curtype, max_length, _ = col_types[col_indx] * variable_name = col_names[col_indx] # <<<<<<<<<<<<<< * variable = readstat_add_variable(writer, variable_name.encode("utf-8"), pandas_to_readstat_types[curtype], max_length) * if variable_format: */ if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 697, __pyx_L55_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_col_names, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_variable_name, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":698 * curtype, max_length, _ = col_types[col_indx] * variable_name = col_names[col_indx] * variable = readstat_add_variable(writer, variable_name.encode("utf-8"), pandas_to_readstat_types[curtype], max_length) # <<<<<<<<<<<<<< * if variable_format: * tempformat = variable_format.get(variable_name) */ __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_variable_name, __pyx_n_s_encode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 698, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_2 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_s_utf_8}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 698, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_t_28 = __Pyx_PyObject_AsString(__pyx_t_1); if (unlikely((!__pyx_t_28) && PyErr_Occurred())) __PYX_ERR(0, 698, __pyx_L55_error) if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_pandas_to_readstat_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 698, __pyx_L55_error) } __pyx_t_15 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_v_curtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 698, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_10pyreadstat_16_readstat_writer_pandas_to_readstat_types, __pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 698, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_29 = ((readstat_type_t)__Pyx_PyInt_As_readstat_type_t(__pyx_t_2)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 698, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_variable = readstat_add_variable(__pyx_v_writer, __pyx_t_28, __pyx_t_29, __pyx_v_max_length); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":699 * variable_name = col_names[col_indx] * variable = readstat_add_variable(writer, variable_name.encode("utf-8"), pandas_to_readstat_types[curtype], max_length) * if variable_format: # <<<<<<<<<<<<<< * tempformat = variable_format.get(variable_name) * if tempformat: */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_variable_format); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 699, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":700 * variable = readstat_add_variable(writer, variable_name.encode("utf-8"), pandas_to_readstat_types[curtype], max_length) * if variable_format: * tempformat = variable_format.get(variable_name) # <<<<<<<<<<<<<< * if tempformat: * readstat_variable_set_format(variable, tempformat.encode("utf-8")) */ if (unlikely(__pyx_v_variable_format == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 700, __pyx_L55_error) } __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_format, __pyx_v_variable_name, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 700, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_1))) __PYX_ERR(0, 700, __pyx_L55_error) __Pyx_XDECREF_SET(__pyx_v_tempformat, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":701 * if variable_format: * tempformat = variable_format.get(variable_name) * if tempformat: # <<<<<<<<<<<<<< * readstat_variable_set_format(variable, tempformat.encode("utf-8")) * if curtype in pyrwriter_datetimelike_types and (variable_format is None or variable_name not in variable_format.keys()): */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_tempformat); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 701, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":702 * tempformat = variable_format.get(variable_name) * if tempformat: * readstat_variable_set_format(variable, tempformat.encode("utf-8")) # <<<<<<<<<<<<<< * if curtype in pyrwriter_datetimelike_types and (variable_format is None or variable_name not in variable_format.keys()): * curformat = get_datetimelike_format_for_readstat(file_format, curtype) */ __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyString_Type_encode, __pyx_v_tempformat, __pyx_kp_s_utf_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 702, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_30 = __Pyx_PyObject_AsString(__pyx_t_1); if (unlikely((!__pyx_t_30) && PyErr_Occurred())) __PYX_ERR(0, 702, __pyx_L55_error) readstat_variable_set_format(__pyx_v_variable, __pyx_t_30); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":701 * if variable_format: * tempformat = variable_format.get(variable_name) * if tempformat: # <<<<<<<<<<<<<< * readstat_variable_set_format(variable, tempformat.encode("utf-8")) * if curtype in pyrwriter_datetimelike_types and (variable_format is None or variable_name not in variable_format.keys()): */ } /* "pyreadstat/_readstat_writer.pyx":699 * variable_name = col_names[col_indx] * variable = readstat_add_variable(writer, variable_name.encode("utf-8"), pandas_to_readstat_types[curtype], max_length) * if variable_format: # <<<<<<<<<<<<<< * tempformat = variable_format.get(variable_name) * if tempformat: */ } /* "pyreadstat/_readstat_writer.pyx":703 * if tempformat: * readstat_variable_set_format(variable, tempformat.encode("utf-8")) * if curtype in pyrwriter_datetimelike_types and (variable_format is None or variable_name not in variable_format.keys()): # <<<<<<<<<<<<<< * curformat = get_datetimelike_format_for_readstat(file_format, curtype) * readstat_variable_set_format(variable, curformat) */ __pyx_t_1 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_v_curtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 703, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_pyrwriter_datetimelike_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 703, __pyx_L55_error) } __pyx_t_3 = (__Pyx_PySet_ContainsTF(__pyx_t_1, __pyx_v_10pyreadstat_16_readstat_writer_pyrwriter_datetimelike_types, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 703, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L82_bool_binop_done; } __pyx_t_3 = (__pyx_v_variable_format == ((PyObject*)Py_None)); if (!__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L82_bool_binop_done; } if (unlikely(__pyx_v_variable_format == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "keys"); __PYX_ERR(0, 703, __pyx_L55_error) } __pyx_t_1 = __Pyx_PyDict_Keys(__pyx_v_variable_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 703, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_variable_name, __pyx_t_1, Py_NE)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 703, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __pyx_t_3; __pyx_L82_bool_binop_done:; if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":704 * readstat_variable_set_format(variable, tempformat.encode("utf-8")) * if curtype in pyrwriter_datetimelike_types and (variable_format is None or variable_name not in variable_format.keys()): * curformat = get_datetimelike_format_for_readstat(file_format, curtype) # <<<<<<<<<<<<<< * readstat_variable_set_format(variable, curformat) * if col_label_count: */ __pyx_t_21 = __pyx_f_10pyreadstat_16_readstat_writer_get_datetimelike_format_for_readstat(__pyx_v_file_format, __pyx_v_curtype); if (unlikely(__pyx_t_21 == ((char *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 704, __pyx_L55_error) __pyx_v_curformat = __pyx_t_21; /* "pyreadstat/_readstat_writer.pyx":705 * if curtype in pyrwriter_datetimelike_types and (variable_format is None or variable_name not in variable_format.keys()): * curformat = get_datetimelike_format_for_readstat(file_format, curtype) * readstat_variable_set_format(variable, curformat) # <<<<<<<<<<<<<< * if col_label_count: * if column_labels[col_indx] is not None: */ readstat_variable_set_format(__pyx_v_variable, __pyx_v_curformat); /* "pyreadstat/_readstat_writer.pyx":703 * if tempformat: * readstat_variable_set_format(variable, tempformat.encode("utf-8")) * if curtype in pyrwriter_datetimelike_types and (variable_format is None or variable_name not in variable_format.keys()): # <<<<<<<<<<<<<< * curformat = get_datetimelike_format_for_readstat(file_format, curtype) * readstat_variable_set_format(variable, curformat) */ } /* "pyreadstat/_readstat_writer.pyx":706 * curformat = get_datetimelike_format_for_readstat(file_format, curtype) * readstat_variable_set_format(variable, curformat) * if col_label_count: # <<<<<<<<<<<<<< * if column_labels[col_indx] is not None: * if type(column_labels[col_indx]) != str: */ __pyx_t_4 = (__pyx_v_col_label_count != 0); if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":707 * readstat_variable_set_format(variable, curformat) * if col_label_count: * if column_labels[col_indx] is not None: # <<<<<<<<<<<<<< * if type(column_labels[col_indx]) != str: * raise PyreadstatError("Column labels must be strings") */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_column_labels, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 707, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__pyx_t_1 != Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":708 * if col_label_count: * if column_labels[col_indx] is not None: * if type(column_labels[col_indx]) != str: # <<<<<<<<<<<<<< * raise PyreadstatError("Column labels must be strings") * cur_col_label = column_labels[col_indx].encode("utf-8") */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_column_labels, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_t_1)), ((PyObject *)(&PyString_Type)), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 708, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 708, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__pyx_t_4)) { /* "pyreadstat/_readstat_writer.pyx":709 * if column_labels[col_indx] is not None: * if type(column_labels[col_indx]) != str: * raise PyreadstatError("Column labels must be strings") # <<<<<<<<<<<<<< * cur_col_label = column_labels[col_indx].encode("utf-8") * readstat_variable_set_label(variable, cur_col_label) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 709, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_kp_s_Column_labels_must_be_strings}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 709, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 709, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":708 * if col_label_count: * if column_labels[col_indx] is not None: * if type(column_labels[col_indx]) != str: # <<<<<<<<<<<<<< * raise PyreadstatError("Column labels must be strings") * cur_col_label = column_labels[col_indx].encode("utf-8") */ } /* "pyreadstat/_readstat_writer.pyx":710 * if type(column_labels[col_indx]) != str: * raise PyreadstatError("Column labels must be strings") * cur_col_label = column_labels[col_indx].encode("utf-8") # <<<<<<<<<<<<<< * readstat_variable_set_label(variable, cur_col_label) * if variable_value_labels: */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_column_labels, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_encode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 710, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_s_utf_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 710, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("bytes", __pyx_t_2))) __PYX_ERR(0, 710, __pyx_L55_error) __Pyx_XDECREF_SET(__pyx_v_cur_col_label, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":711 * raise PyreadstatError("Column labels must be strings") * cur_col_label = column_labels[col_indx].encode("utf-8") * readstat_variable_set_label(variable, cur_col_label) # <<<<<<<<<<<<<< * if variable_value_labels: * value_labels = variable_value_labels.get(variable_name) */ if (unlikely(__pyx_v_cur_col_label == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); __PYX_ERR(0, 711, __pyx_L55_error) } __pyx_t_31 = __Pyx_PyBytes_AsString(__pyx_v_cur_col_label); if (unlikely((!__pyx_t_31) && PyErr_Occurred())) __PYX_ERR(0, 711, __pyx_L55_error) readstat_variable_set_label(__pyx_v_variable, __pyx_t_31); /* "pyreadstat/_readstat_writer.pyx":707 * readstat_variable_set_format(variable, curformat) * if col_label_count: * if column_labels[col_indx] is not None: # <<<<<<<<<<<<<< * if type(column_labels[col_indx]) != str: * raise PyreadstatError("Column labels must be strings") */ } /* "pyreadstat/_readstat_writer.pyx":706 * curformat = get_datetimelike_format_for_readstat(file_format, curtype) * readstat_variable_set_format(variable, curformat) * if col_label_count: # <<<<<<<<<<<<<< * if column_labels[col_indx] is not None: * if type(column_labels[col_indx]) != str: */ } /* "pyreadstat/_readstat_writer.pyx":712 * cur_col_label = column_labels[col_indx].encode("utf-8") * readstat_variable_set_label(variable, cur_col_label) * if variable_value_labels: # <<<<<<<<<<<<<< * value_labels = variable_value_labels.get(variable_name) * if value_labels: */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_variable_value_labels); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 712, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":713 * readstat_variable_set_label(variable, cur_col_label) * if variable_value_labels: * value_labels = variable_value_labels.get(variable_name) # <<<<<<<<<<<<<< * if value_labels: * labelset_name = variable_name + str(lblset_cnt) */ if (unlikely(__pyx_v_variable_value_labels == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 713, __pyx_L55_error) } __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_value_labels, __pyx_v_variable_name, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 713, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("dict", __pyx_t_2))) __PYX_ERR(0, 713, __pyx_L55_error) __Pyx_XDECREF_SET(__pyx_v_value_labels, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":714 * if variable_value_labels: * value_labels = variable_value_labels.get(variable_name) * if value_labels: # <<<<<<<<<<<<<< * labelset_name = variable_name + str(lblset_cnt) * lblset_cnt += 1 */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_value_labels); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 714, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":715 * value_labels = variable_value_labels.get(variable_name) * if value_labels: * labelset_name = variable_name + str(lblset_cnt) # <<<<<<<<<<<<<< * lblset_cnt += 1 * curuser_missing = None */ __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_lblset_cnt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = __Pyx_PyObject_Str(__pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 715, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Add(__pyx_v_variable_name, __pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF_SET(__pyx_v_labelset_name, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":716 * if value_labels: * labelset_name = variable_name + str(lblset_cnt) * lblset_cnt += 1 # <<<<<<<<<<<<<< * curuser_missing = None * if missing_user_values: */ __pyx_v_lblset_cnt = (__pyx_v_lblset_cnt + 1); /* "pyreadstat/_readstat_writer.pyx":717 * labelset_name = variable_name + str(lblset_cnt) * lblset_cnt += 1 * curuser_missing = None # <<<<<<<<<<<<<< * if missing_user_values: * curuser_missing = missing_user_values.get(variable_name) */ __Pyx_INCREF(Py_None); __Pyx_XDECREF_SET(__pyx_v_curuser_missing, Py_None); /* "pyreadstat/_readstat_writer.pyx":718 * lblset_cnt += 1 * curuser_missing = None * if missing_user_values: # <<<<<<<<<<<<<< * curuser_missing = missing_user_values.get(variable_name) * label_set = set_value_label(writer, value_labels, labelset_name, */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_missing_user_values); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 718, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":719 * curuser_missing = None * if missing_user_values: * curuser_missing = missing_user_values.get(variable_name) # <<<<<<<<<<<<<< * label_set = set_value_label(writer, value_labels, labelset_name, * col_names_to_types[variable_name], file_format, variable_name, curuser_missing) */ if (unlikely(__pyx_v_missing_user_values == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 719, __pyx_L55_error) } __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_missing_user_values, __pyx_v_variable_name, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 719, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_curuser_missing, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":718 * lblset_cnt += 1 * curuser_missing = None * if missing_user_values: # <<<<<<<<<<<<<< * curuser_missing = missing_user_values.get(variable_name) * label_set = set_value_label(writer, value_labels, labelset_name, */ } /* "pyreadstat/_readstat_writer.pyx":720 * if missing_user_values: * curuser_missing = missing_user_values.get(variable_name) * label_set = set_value_label(writer, value_labels, labelset_name, # <<<<<<<<<<<<<< * col_names_to_types[variable_name], file_format, variable_name, curuser_missing) * readstat_variable_set_label_set(variable, label_set) */ if (!(likely(PyString_CheckExact(__pyx_v_labelset_name))||((__pyx_v_labelset_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_labelset_name))) __PYX_ERR(0, 720, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":721 * curuser_missing = missing_user_values.get(variable_name) * label_set = set_value_label(writer, value_labels, labelset_name, * col_names_to_types[variable_name], file_format, variable_name, curuser_missing) # <<<<<<<<<<<<<< * readstat_variable_set_label_set(variable, label_set) * if missing_ranges: */ __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_col_names_to_types, __pyx_v_variable_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_27 = ((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)__Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_t_2)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 721, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(PyString_CheckExact(__pyx_v_variable_name))||((__pyx_v_variable_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_variable_name))) __PYX_ERR(0, 721, __pyx_L55_error) if (!(likely(PyList_CheckExact(__pyx_v_curuser_missing))||((__pyx_v_curuser_missing) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_v_curuser_missing))) __PYX_ERR(0, 721, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":720 * if missing_user_values: * curuser_missing = missing_user_values.get(variable_name) * label_set = set_value_label(writer, value_labels, labelset_name, # <<<<<<<<<<<<<< * col_names_to_types[variable_name], file_format, variable_name, curuser_missing) * readstat_variable_set_label_set(variable, label_set) */ __pyx_t_32 = __pyx_f_10pyreadstat_16_readstat_writer_set_value_label(__pyx_v_writer, __pyx_v_value_labels, ((PyObject*)__pyx_v_labelset_name), __pyx_t_27, __pyx_v_file_format, ((PyObject*)__pyx_v_variable_name), ((PyObject*)__pyx_v_curuser_missing)); if (unlikely(__pyx_t_32 == ((readstat_label_set_t *)NULL) && PyErr_Occurred())) __PYX_ERR(0, 720, __pyx_L55_error) __pyx_v_label_set = __pyx_t_32; /* "pyreadstat/_readstat_writer.pyx":722 * label_set = set_value_label(writer, value_labels, labelset_name, * col_names_to_types[variable_name], file_format, variable_name, curuser_missing) * readstat_variable_set_label_set(variable, label_set) # <<<<<<<<<<<<<< * if missing_ranges: * cur_ranges = missing_ranges.get(variable_name) */ readstat_variable_set_label_set(__pyx_v_variable, __pyx_v_label_set); /* "pyreadstat/_readstat_writer.pyx":714 * if variable_value_labels: * value_labels = variable_value_labels.get(variable_name) * if value_labels: # <<<<<<<<<<<<<< * labelset_name = variable_name + str(lblset_cnt) * lblset_cnt += 1 */ } /* "pyreadstat/_readstat_writer.pyx":712 * cur_col_label = column_labels[col_indx].encode("utf-8") * readstat_variable_set_label(variable, cur_col_label) * if variable_value_labels: # <<<<<<<<<<<<<< * value_labels = variable_value_labels.get(variable_name) * if value_labels: */ } /* "pyreadstat/_readstat_writer.pyx":723 * col_names_to_types[variable_name], file_format, variable_name, curuser_missing) * readstat_variable_set_label_set(variable, label_set) * if missing_ranges: # <<<<<<<<<<<<<< * cur_ranges = missing_ranges.get(variable_name) * if cur_ranges: */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_missing_ranges); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 723, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":724 * readstat_variable_set_label_set(variable, label_set) * if missing_ranges: * cur_ranges = missing_ranges.get(variable_name) # <<<<<<<<<<<<<< * if cur_ranges: * if not isinstance(cur_ranges, list): */ if (unlikely(__pyx_v_missing_ranges == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 724, __pyx_L55_error) } __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_missing_ranges, __pyx_v_variable_name, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_cur_ranges, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":725 * if missing_ranges: * cur_ranges = missing_ranges.get(variable_name) * if cur_ranges: # <<<<<<<<<<<<<< * if not isinstance(cur_ranges, list): * msg = "missing_ranges: values in dictionary must be list" */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_cur_ranges); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 725, __pyx_L55_error) if (__pyx_t_4) { /* "pyreadstat/_readstat_writer.pyx":726 * cur_ranges = missing_ranges.get(variable_name) * if cur_ranges: * if not isinstance(cur_ranges, list): # <<<<<<<<<<<<<< * msg = "missing_ranges: values in dictionary must be list" * raise PyreadstatError(msg) */ __pyx_t_4 = PyList_Check(__pyx_v_cur_ranges); __pyx_t_3 = (!__pyx_t_4); if (unlikely(__pyx_t_3)) { /* "pyreadstat/_readstat_writer.pyx":727 * if cur_ranges: * if not isinstance(cur_ranges, list): * msg = "missing_ranges: values in dictionary must be list" # <<<<<<<<<<<<<< * raise PyreadstatError(msg) * add_missing_ranges(cur_ranges, variable, curtype, variable_name) */ __Pyx_INCREF(__pyx_kp_s_missing_ranges_values_in_diction); __pyx_v_msg = __pyx_kp_s_missing_ranges_values_in_diction; /* "pyreadstat/_readstat_writer.pyx":728 * if not isinstance(cur_ranges, list): * msg = "missing_ranges: values in dictionary must be list" * raise PyreadstatError(msg) # <<<<<<<<<<<<<< * add_missing_ranges(cur_ranges, variable, curtype, variable_name) * if variable_alignment: */ __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 728, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_1 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_msg}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 728, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 728, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":726 * cur_ranges = missing_ranges.get(variable_name) * if cur_ranges: * if not isinstance(cur_ranges, list): # <<<<<<<<<<<<<< * msg = "missing_ranges: values in dictionary must be list" * raise PyreadstatError(msg) */ } /* "pyreadstat/_readstat_writer.pyx":729 * msg = "missing_ranges: values in dictionary must be list" * raise PyreadstatError(msg) * add_missing_ranges(cur_ranges, variable, curtype, variable_name) # <<<<<<<<<<<<<< * if variable_alignment: * # At the moment this is ineffective for sav and dta (the function runs but in */ if (!(likely(PyList_CheckExact(__pyx_v_cur_ranges))||((__pyx_v_cur_ranges) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_v_cur_ranges))) __PYX_ERR(0, 729, __pyx_L55_error) if (!(likely(PyString_CheckExact(__pyx_v_variable_name))||((__pyx_v_variable_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_variable_name))) __PYX_ERR(0, 729, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_writer_add_missing_ranges(((PyObject*)__pyx_v_cur_ranges), __pyx_v_variable, __pyx_v_curtype, ((PyObject*)__pyx_v_variable_name)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 729, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":725 * if missing_ranges: * cur_ranges = missing_ranges.get(variable_name) * if cur_ranges: # <<<<<<<<<<<<<< * if not isinstance(cur_ranges, list): * msg = "missing_ranges: values in dictionary must be list" */ } /* "pyreadstat/_readstat_writer.pyx":723 * col_names_to_types[variable_name], file_format, variable_name, curuser_missing) * readstat_variable_set_label_set(variable, label_set) * if missing_ranges: # <<<<<<<<<<<<<< * cur_ranges = missing_ranges.get(variable_name) * if cur_ranges: */ } /* "pyreadstat/_readstat_writer.pyx":730 * raise PyreadstatError(msg) * add_missing_ranges(cur_ranges, variable, curtype, variable_name) * if variable_alignment: # <<<<<<<<<<<<<< * # At the moment this is ineffective for sav and dta (the function runs but in * # the resulting file all alignments are still unknown) */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_variable_alignment); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 730, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":733 * # At the moment this is ineffective for sav and dta (the function runs but in * # the resulting file all alignments are still unknown) * cur_alignment = variable_alignment.get(variable_name) # <<<<<<<<<<<<<< * if cur_alignment: * set_variable_alignment(variable, cur_alignment, variable_name) */ if (unlikely(__pyx_v_variable_alignment == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 733, __pyx_L55_error) } __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_alignment, __pyx_v_variable_name, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 733, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_cur_alignment, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":734 * # the resulting file all alignments are still unknown) * cur_alignment = variable_alignment.get(variable_name) * if cur_alignment: # <<<<<<<<<<<<<< * set_variable_alignment(variable, cur_alignment, variable_name) * if variable_display_width: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_cur_alignment); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 734, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":735 * cur_alignment = variable_alignment.get(variable_name) * if cur_alignment: * set_variable_alignment(variable, cur_alignment, variable_name) # <<<<<<<<<<<<<< * if variable_display_width: * cur_display_width = variable_display_width.get(variable_name) */ if (!(likely(PyString_CheckExact(__pyx_v_cur_alignment))||((__pyx_v_cur_alignment) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_cur_alignment))) __PYX_ERR(0, 735, __pyx_L55_error) if (!(likely(PyString_CheckExact(__pyx_v_variable_name))||((__pyx_v_variable_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_variable_name))) __PYX_ERR(0, 735, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_writer_set_variable_alignment(__pyx_v_variable, ((PyObject*)__pyx_v_cur_alignment), ((PyObject*)__pyx_v_variable_name)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 735, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":734 * # the resulting file all alignments are still unknown) * cur_alignment = variable_alignment.get(variable_name) * if cur_alignment: # <<<<<<<<<<<<<< * set_variable_alignment(variable, cur_alignment, variable_name) * if variable_display_width: */ } /* "pyreadstat/_readstat_writer.pyx":730 * raise PyreadstatError(msg) * add_missing_ranges(cur_ranges, variable, curtype, variable_name) * if variable_alignment: # <<<<<<<<<<<<<< * # At the moment this is ineffective for sav and dta (the function runs but in * # the resulting file all alignments are still unknown) */ } /* "pyreadstat/_readstat_writer.pyx":736 * if cur_alignment: * set_variable_alignment(variable, cur_alignment, variable_name) * if variable_display_width: # <<<<<<<<<<<<<< * cur_display_width = variable_display_width.get(variable_name) * if cur_display_width: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_variable_display_width); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 736, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":737 * set_variable_alignment(variable, cur_alignment, variable_name) * if variable_display_width: * cur_display_width = variable_display_width.get(variable_name) # <<<<<<<<<<<<<< * if cur_display_width: * set_variable_display_width(variable, cur_display_width, variable_name) */ if (unlikely(__pyx_v_variable_display_width == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 737, __pyx_L55_error) } __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_display_width, __pyx_v_variable_name, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_cur_display_width, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":738 * if variable_display_width: * cur_display_width = variable_display_width.get(variable_name) * if cur_display_width: # <<<<<<<<<<<<<< * set_variable_display_width(variable, cur_display_width, variable_name) * if variable_measure: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_cur_display_width); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 738, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":739 * cur_display_width = variable_display_width.get(variable_name) * if cur_display_width: * set_variable_display_width(variable, cur_display_width, variable_name) # <<<<<<<<<<<<<< * if variable_measure: * cur_measure = variable_measure.get(variable_name) */ __pyx_t_25 = __Pyx_PyInt_As_int(__pyx_v_cur_display_width); if (unlikely((__pyx_t_25 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 739, __pyx_L55_error) if (!(likely(PyString_CheckExact(__pyx_v_variable_name))||((__pyx_v_variable_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_variable_name))) __PYX_ERR(0, 739, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_writer_set_variable_display_width(__pyx_v_variable, __pyx_t_25, ((PyObject*)__pyx_v_variable_name)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 739, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":738 * if variable_display_width: * cur_display_width = variable_display_width.get(variable_name) * if cur_display_width: # <<<<<<<<<<<<<< * set_variable_display_width(variable, cur_display_width, variable_name) * if variable_measure: */ } /* "pyreadstat/_readstat_writer.pyx":736 * if cur_alignment: * set_variable_alignment(variable, cur_alignment, variable_name) * if variable_display_width: # <<<<<<<<<<<<<< * cur_display_width = variable_display_width.get(variable_name) * if cur_display_width: */ } /* "pyreadstat/_readstat_writer.pyx":740 * if cur_display_width: * set_variable_display_width(variable, cur_display_width, variable_name) * if variable_measure: # <<<<<<<<<<<<<< * cur_measure = variable_measure.get(variable_name) * if cur_measure: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_variable_measure); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 740, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":741 * set_variable_display_width(variable, cur_display_width, variable_name) * if variable_measure: * cur_measure = variable_measure.get(variable_name) # <<<<<<<<<<<<<< * if cur_measure: * set_variable_measure(variable, cur_measure, variable_name) */ if (unlikely(__pyx_v_variable_measure == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 741, __pyx_L55_error) } __pyx_t_2 = __Pyx_PyDict_GetItemDefault(__pyx_v_variable_measure, __pyx_v_variable_name, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 741, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_cur_measure, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":742 * if variable_measure: * cur_measure = variable_measure.get(variable_name) * if cur_measure: # <<<<<<<<<<<<<< * set_variable_measure(variable, cur_measure, variable_name) * */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_cur_measure); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 742, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":743 * cur_measure = variable_measure.get(variable_name) * if cur_measure: * set_variable_measure(variable, cur_measure, variable_name) # <<<<<<<<<<<<<< * * # start writing */ if (!(likely(PyString_CheckExact(__pyx_v_cur_measure))||((__pyx_v_cur_measure) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_cur_measure))) __PYX_ERR(0, 743, __pyx_L55_error) if (!(likely(PyString_CheckExact(__pyx_v_variable_name))||((__pyx_v_variable_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_variable_name))) __PYX_ERR(0, 743, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_writer_set_variable_measure(__pyx_v_variable, ((PyObject*)__pyx_v_cur_measure), ((PyObject*)__pyx_v_variable_name)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 743, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":742 * if variable_measure: * cur_measure = variable_measure.get(variable_name) * if cur_measure: # <<<<<<<<<<<<<< * set_variable_measure(variable, cur_measure, variable_name) * */ } /* "pyreadstat/_readstat_writer.pyx":740 * if cur_display_width: * set_variable_display_width(variable, cur_display_width, variable_name) * if variable_measure: # <<<<<<<<<<<<<< * cur_measure = variable_measure.get(variable_name) * if cur_measure: */ } } /* "pyreadstat/_readstat_writer.pyx":746 * * # start writing * if file_format == FILE_FORMAT_SAS7BCAT: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_writing_sas7bcat(writer, &fd)) * elif file_format == FILE_FORMAT_DTA: */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAS7BCAT: /* "pyreadstat/_readstat_writer.pyx":747 * # start writing * if file_format == FILE_FORMAT_SAS7BCAT: * check_exit_status(readstat_begin_writing_sas7bcat(writer, &fd)) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_DTA: * check_exit_status(readstat_begin_writing_dta(writer, &fd, row_count)) */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_begin_writing_sas7bcat(__pyx_v_writer, (&__pyx_v_fd))); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 747, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":746 * * # start writing * if file_format == FILE_FORMAT_SAS7BCAT: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_writing_sas7bcat(writer, &fd)) * elif file_format == FILE_FORMAT_DTA: */ break; case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA: /* "pyreadstat/_readstat_writer.pyx":749 * check_exit_status(readstat_begin_writing_sas7bcat(writer, &fd)) * elif file_format == FILE_FORMAT_DTA: * check_exit_status(readstat_begin_writing_dta(writer, &fd, row_count)) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_SAV: * check_exit_status(readstat_begin_writing_sav(writer, &fd, row_count)) */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_begin_writing_dta(__pyx_v_writer, (&__pyx_v_fd), __pyx_v_row_count)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 749, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":748 * if file_format == FILE_FORMAT_SAS7BCAT: * check_exit_status(readstat_begin_writing_sas7bcat(writer, &fd)) * elif file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_writing_dta(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_SAV: */ break; case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAV: /* "pyreadstat/_readstat_writer.pyx":751 * check_exit_status(readstat_begin_writing_dta(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_SAV: * check_exit_status(readstat_begin_writing_sav(writer, &fd, row_count)) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_POR: * check_exit_status(readstat_begin_writing_por(writer, &fd, row_count)) */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_begin_writing_sav(__pyx_v_writer, (&__pyx_v_fd), __pyx_v_row_count)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 751, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":750 * elif file_format == FILE_FORMAT_DTA: * check_exit_status(readstat_begin_writing_dta(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_SAV: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_writing_sav(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_POR: */ break; case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_POR: /* "pyreadstat/_readstat_writer.pyx":753 * check_exit_status(readstat_begin_writing_sav(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_POR: * check_exit_status(readstat_begin_writing_por(writer, &fd, row_count)) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_SAS7BDAT: * check_exit_status(readstat_begin_writing_sas7bdat(writer, &fd, row_count)) */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_begin_writing_por(__pyx_v_writer, (&__pyx_v_fd), __pyx_v_row_count)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 753, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":752 * elif file_format == FILE_FORMAT_SAV: * check_exit_status(readstat_begin_writing_sav(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_writing_por(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_SAS7BDAT: */ break; case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAS7BDAT: /* "pyreadstat/_readstat_writer.pyx":755 * check_exit_status(readstat_begin_writing_por(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_SAS7BDAT: * check_exit_status(readstat_begin_writing_sas7bdat(writer, &fd, row_count)) # <<<<<<<<<<<<<< * elif file_format == FILE_FORMAT_XPORT: * check_exit_status(readstat_begin_writing_xport(writer, &fd, row_count)) */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_begin_writing_sas7bdat(__pyx_v_writer, (&__pyx_v_fd), __pyx_v_row_count)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 755, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":754 * elif file_format == FILE_FORMAT_POR: * check_exit_status(readstat_begin_writing_por(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_SAS7BDAT: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_writing_sas7bdat(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_XPORT: */ break; case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_XPORT: /* "pyreadstat/_readstat_writer.pyx":757 * check_exit_status(readstat_begin_writing_sas7bdat(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_XPORT: * check_exit_status(readstat_begin_writing_xport(writer, &fd, row_count)) # <<<<<<<<<<<<<< * else: * raise PyreadstatError("unknown file format") */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_begin_writing_xport(__pyx_v_writer, (&__pyx_v_fd), __pyx_v_row_count)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 757, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":756 * elif file_format == FILE_FORMAT_SAS7BDAT: * check_exit_status(readstat_begin_writing_sas7bdat(writer, &fd, row_count)) * elif file_format == FILE_FORMAT_XPORT: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_writing_xport(writer, &fd, row_count)) * else: */ break; default: /* "pyreadstat/_readstat_writer.pyx":759 * check_exit_status(readstat_begin_writing_xport(writer, &fd, row_count)) * else: * raise PyreadstatError("unknown file format") # <<<<<<<<<<<<<< * * # validation */ __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 759, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_1 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_s_unknown_file_format}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 759, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 759, __pyx_L55_error) break; } /* "pyreadstat/_readstat_writer.pyx":762 * * # validation * check_exit_status(readstat_validate_metadata(writer)) # <<<<<<<<<<<<<< * for col_indx in range(col_count): * tempvar = readstat_get_variable(writer, col_indx) */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_validate_metadata(__pyx_v_writer)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 762, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":763 * # validation * check_exit_status(readstat_validate_metadata(writer)) * for col_indx in range(col_count): # <<<<<<<<<<<<<< * tempvar = readstat_get_variable(writer, col_indx) * check_exit_status(readstat_validate_variable(writer, tempvar)) */ __pyx_t_6 = __pyx_v_col_count; __pyx_t_23 = __pyx_t_6; for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) { __pyx_v_col_indx = __pyx_t_24; /* "pyreadstat/_readstat_writer.pyx":764 * check_exit_status(readstat_validate_metadata(writer)) * for col_indx in range(col_count): * tempvar = readstat_get_variable(writer, col_indx) # <<<<<<<<<<<<<< * check_exit_status(readstat_validate_variable(writer, tempvar)) * */ __pyx_v_tempvar = readstat_get_variable(__pyx_v_writer, __pyx_v_col_indx); /* "pyreadstat/_readstat_writer.pyx":765 * for col_indx in range(col_count): * tempvar = readstat_get_variable(writer, col_indx) * check_exit_status(readstat_validate_variable(writer, tempvar)) # <<<<<<<<<<<<<< * * # vectorized transform of datetime64ns columns */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_validate_variable(__pyx_v_writer, __pyx_v_tempvar)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 765, __pyx_L55_error) } /* "pyreadstat/_readstat_writer.pyx":768 * * # vectorized transform of datetime64ns columns * pywriter_types = [x[0] for x in col_types] # <<<<<<<<<<<<<< * hasdatetime64 = PYWRITER_DATETIME64_NS in pywriter_types or PYWRITER_DATETIME64_US in pywriter_types * if hasdatetime64: */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(__pyx_v_col_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 768, __pyx_L55_error) } __pyx_t_15 = __pyx_v_col_types; __Pyx_INCREF(__pyx_t_15); __pyx_t_12 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_15); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 768, __pyx_L55_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_15, __pyx_t_12); __Pyx_INCREF(__pyx_t_1); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 768, __pyx_L55_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_15, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_x, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 768, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_v_pywriter_types = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":769 * # vectorized transform of datetime64ns columns * pywriter_types = [x[0] for x in col_types] * hasdatetime64 = PYWRITER_DATETIME64_NS in pywriter_types or PYWRITER_DATETIME64_US in pywriter_types # <<<<<<<<<<<<<< * if hasdatetime64: * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: */ __pyx_t_2 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 769, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_v_pywriter_types, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 769, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L105_bool_binop_done; } __pyx_t_2 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 769, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_t_2, __pyx_v_pywriter_types, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 769, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_4; __pyx_L105_bool_binop_done:; __pyx_v_hasdatetime64 = __pyx_t_3; /* "pyreadstat/_readstat_writer.pyx":770 * pywriter_types = [x[0] for x in col_types] * hasdatetime64 = PYWRITER_DATETIME64_NS in pywriter_types or PYWRITER_DATETIME64_US in pywriter_types * if hasdatetime64: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: * offset_secs = spss_offset_secs */ if (__pyx_v_hasdatetime64) { /* "pyreadstat/_readstat_writer.pyx":771 * hasdatetime64 = PYWRITER_DATETIME64_NS in pywriter_types or PYWRITER_DATETIME64_US in pywriter_types * if hasdatetime64: * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * offset_secs = spss_offset_secs * else: */ switch (__pyx_v_file_format) { case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAV: case __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_POR: /* "pyreadstat/_readstat_writer.pyx":772 * if hasdatetime64: * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: * offset_secs = spss_offset_secs # <<<<<<<<<<<<<< * else: * offset_secs = sas_offset_secs */ __pyx_v_offset_secs = __pyx_v_10pyreadstat_16_readstat_writer_spss_offset_secs; /* "pyreadstat/_readstat_writer.pyx":771 * hasdatetime64 = PYWRITER_DATETIME64_NS in pywriter_types or PYWRITER_DATETIME64_US in pywriter_types * if hasdatetime64: * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: # <<<<<<<<<<<<<< * offset_secs = spss_offset_secs * else: */ break; default: /* "pyreadstat/_readstat_writer.pyx":774 * offset_secs = spss_offset_secs * else: * offset_secs = sas_offset_secs # <<<<<<<<<<<<<< * mulfac = 1.0 * if file_format == FILE_FORMAT_DTA: */ __pyx_v_offset_secs = __pyx_v_10pyreadstat_16_readstat_writer_sas_offset_secs; break; } /* "pyreadstat/_readstat_writer.pyx":775 * else: * offset_secs = sas_offset_secs * mulfac = 1.0 # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_DTA: * # stata stores in milliseconds */ __pyx_v_mulfac = 1.0; /* "pyreadstat/_readstat_writer.pyx":776 * offset_secs = sas_offset_secs * mulfac = 1.0 * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * # stata stores in milliseconds * mulfac = 1000.0 */ __pyx_t_3 = (__pyx_v_file_format == __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA); if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":778 * if file_format == FILE_FORMAT_DTA: * # stata stores in milliseconds * mulfac = 1000.0 # <<<<<<<<<<<<<< * df2 = df.copy() * for col_indx in range(col_count): */ __pyx_v_mulfac = 1000.0; /* "pyreadstat/_readstat_writer.pyx":776 * offset_secs = sas_offset_secs * mulfac = 1.0 * if file_format == FILE_FORMAT_DTA: # <<<<<<<<<<<<<< * # stata stores in milliseconds * mulfac = 1000.0 */ } /* "pyreadstat/_readstat_writer.pyx":779 * # stata stores in milliseconds * mulfac = 1000.0 * df2 = df.copy() # <<<<<<<<<<<<<< * for col_indx in range(col_count): * if pywriter_types[col_indx] == PYWRITER_DATETIME64_NS: */ __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_copy); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 779, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_1 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 779, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_v_df2 = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":780 * mulfac = 1000.0 * df2 = df.copy() * for col_indx in range(col_count): # <<<<<<<<<<<<<< * if pywriter_types[col_indx] == PYWRITER_DATETIME64_NS: * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac */ __pyx_t_6 = __pyx_v_col_count; __pyx_t_23 = __pyx_t_6; for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) { __pyx_v_col_indx = __pyx_t_24; /* "pyreadstat/_readstat_writer.pyx":781 * df2 = df.copy() * for col_indx in range(col_count): * if pywriter_types[col_indx] == PYWRITER_DATETIME64_NS: # <<<<<<<<<<<<<< * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac * #df2.iloc[:, col_indx] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac */ __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_pywriter_types, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 781, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 781, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_15, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 781, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 781, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":782 * for col_indx in range(col_count): * if pywriter_types[col_indx] == PYWRITER_DATETIME64_NS: * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac # <<<<<<<<<<<<<< * #df2.iloc[:, col_indx] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac * elif pywriter_types[col_indx] == PYWRITER_DATETIME64_US: */ __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_round); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_v_df2, __pyx_n_s_iloc); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_col_indx); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice_)) __PYX_ERR(0, 782, __pyx_L55_error); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9)) __PYX_ERR(0, 782, __pyx_L55_error); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_20, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_values); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_astype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_builtin_object}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_astype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float64); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_10}; __pyx_t_15 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyFloat_DivideObjC(__pyx_t_15, __pyx_float_1e9, 1e9, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_9}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyFloat_FromDouble(__pyx_v_offset_secs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyFloat_FromDouble(__pyx_v_mulfac); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_Multiply(__pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_df2, __pyx_n_s_columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely((PyObject_SetItem(__pyx_v_df2, __pyx_t_9, __pyx_t_1) < 0))) __PYX_ERR(0, 782, __pyx_L55_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":781 * df2 = df.copy() * for col_indx in range(col_count): * if pywriter_types[col_indx] == PYWRITER_DATETIME64_NS: # <<<<<<<<<<<<<< * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac * #df2.iloc[:, col_indx] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac */ goto __pyx_L111; } /* "pyreadstat/_readstat_writer.pyx":784 * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac * #df2.iloc[:, col_indx] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac * elif pywriter_types[col_indx] == PYWRITER_DATETIME64_US: # <<<<<<<<<<<<<< * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(np.float64)/1e6) + offset_secs) * mulfac * df2.loc[df2[df2.columns[col_indx]]==-9223056417655, df2.columns[col_indx]] = np.nan */ __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_pywriter_types, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 784, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 784, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_9, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 784, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 784, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":785 * #df2.iloc[:, col_indx] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac * elif pywriter_types[col_indx] == PYWRITER_DATETIME64_US: * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(np.float64)/1e6) + offset_secs) * mulfac # <<<<<<<<<<<<<< * df2.loc[df2[df2.columns[col_indx]]==-9223056417655, df2.columns[col_indx]] = np.nan * */ __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_round); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_df2, __pyx_n_s_iloc); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_col_indx); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_slice_)) __PYX_ERR(0, 785, __pyx_L55_error); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_10)) __PYX_ERR(0, 785, __pyx_L55_error); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_GetItem(__pyx_t_15, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_astype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_float64); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_15}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = __Pyx_PyFloat_DivideObjC(__pyx_t_9, __pyx_float_1e6, 1e6, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_10}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyFloat_FromDouble(__pyx_v_offset_secs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = PyNumber_Add(__pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyFloat_FromDouble(__pyx_v_mulfac); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Multiply(__pyx_t_10, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_df2, __pyx_n_s_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely((PyObject_SetItem(__pyx_v_df2, __pyx_t_10, __pyx_t_2) < 0))) __PYX_ERR(0, 785, __pyx_L55_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":786 * elif pywriter_types[col_indx] == PYWRITER_DATETIME64_US: * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(np.float64)/1e6) + offset_secs) * mulfac * df2.loc[df2[df2.columns[col_indx]]==-9223056417655, df2.columns[col_indx]] = np.nan # <<<<<<<<<<<<<< * * else: */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_nan); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_df2, __pyx_n_s_loc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_df2, __pyx_n_s_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_df2, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyObject_RichCompare(__pyx_t_1, __pyx_int_neg_9223056417655, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_df2, __pyx_n_s_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_1, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9)) __PYX_ERR(0, 786, __pyx_L55_error); __Pyx_GIVEREF(__pyx_t_15); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_15)) __PYX_ERR(0, 786, __pyx_L55_error); __pyx_t_9 = 0; __pyx_t_15 = 0; if (unlikely((PyObject_SetItem(__pyx_t_2, __pyx_t_1, __pyx_t_10) < 0))) __PYX_ERR(0, 786, __pyx_L55_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":784 * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac * #df2.iloc[:, col_indx] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac * elif pywriter_types[col_indx] == PYWRITER_DATETIME64_US: # <<<<<<<<<<<<<< * df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(np.float64)/1e6) + offset_secs) * mulfac * df2.loc[df2[df2.columns[col_indx]]==-9223056417655, df2.columns[col_indx]] = np.nan */ } __pyx_L111:; } /* "pyreadstat/_readstat_writer.pyx":770 * pywriter_types = [x[0] for x in col_types] * hasdatetime64 = PYWRITER_DATETIME64_NS in pywriter_types or PYWRITER_DATETIME64_US in pywriter_types * if hasdatetime64: # <<<<<<<<<<<<<< * if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: * offset_secs = spss_offset_secs */ goto __pyx_L107; } /* "pyreadstat/_readstat_writer.pyx":789 * * else: * df2 = df # <<<<<<<<<<<<<< * * # inserting */ /*else*/ { __Pyx_INCREF(__pyx_v_df); __pyx_v_df2 = __pyx_v_df; } __pyx_L107:; /* "pyreadstat/_readstat_writer.pyx":792 * * # inserting * rowcnt = 0 # <<<<<<<<<<<<<< * * for row in df2.values: */ __Pyx_INCREF(__pyx_int_0); __pyx_v_rowcnt = __pyx_int_0; /* "pyreadstat/_readstat_writer.pyx":794 * rowcnt = 0 * * for row in df2.values: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_row(writer)) * */ __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_df2, __pyx_n_s_values); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 794, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); if (likely(PyList_CheckExact(__pyx_t_10)) || PyTuple_CheckExact(__pyx_t_10)) { __pyx_t_1 = __pyx_t_10; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0; __pyx_t_8 = NULL; } else { __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 794, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 794, __pyx_L55_error) } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 794, __pyx_L55_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_10 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 794, __pyx_L55_error) #else __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 794, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 794, __pyx_L55_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 794, __pyx_L55_error) #else __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 794, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); #endif } } else { __pyx_t_10 = __pyx_t_8(__pyx_t_1); if (unlikely(!__pyx_t_10)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 794, __pyx_L55_error) } break; } __Pyx_GOTREF(__pyx_t_10); } __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":795 * * for row in df2.values: * check_exit_status(readstat_begin_row(writer)) # <<<<<<<<<<<<<< * * for col_indx in range(col_count): */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_begin_row(__pyx_v_writer)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 795, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":797 * check_exit_status(readstat_begin_row(writer)) * * for col_indx in range(col_count): # <<<<<<<<<<<<<< * * tempvar = readstat_get_variable(writer, col_indx) */ __pyx_t_6 = __pyx_v_col_count; __pyx_t_23 = __pyx_t_6; for (__pyx_t_24 = 0; __pyx_t_24 < __pyx_t_23; __pyx_t_24+=1) { __pyx_v_col_indx = __pyx_t_24; /* "pyreadstat/_readstat_writer.pyx":799 * for col_indx in range(col_count): * * tempvar = readstat_get_variable(writer, col_indx) # <<<<<<<<<<<<<< * curval = row[col_indx] * curtype = pywriter_types[col_indx] */ __pyx_v_tempvar = readstat_get_variable(__pyx_v_writer, __pyx_v_col_indx); /* "pyreadstat/_readstat_writer.pyx":800 * * tempvar = readstat_get_variable(writer, col_indx) * curval = row[col_indx] # <<<<<<<<<<<<<< * curtype = pywriter_types[col_indx] * is_missing = col_types[col_indx][2] */ __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_row, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 800, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_v_curval, __pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":801 * tempvar = readstat_get_variable(writer, col_indx) * curval = row[col_indx] * curtype = pywriter_types[col_indx] # <<<<<<<<<<<<<< * is_missing = col_types[col_indx][2] * curuser_missing = None */ __pyx_t_10 = __Pyx_GetItemInt_List(__pyx_v_pywriter_types, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 801, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_27 = ((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)__Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_t_10)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 801, __pyx_L55_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_v_curtype = __pyx_t_27; /* "pyreadstat/_readstat_writer.pyx":802 * curval = row[col_indx] * curtype = pywriter_types[col_indx] * is_missing = col_types[col_indx][2] # <<<<<<<<<<<<<< * curuser_missing = None * if missing_user_values: */ if (unlikely(__pyx_v_col_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 802, __pyx_L55_error) } __pyx_t_10 = __Pyx_GetItemInt_List(__pyx_v_col_types, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 802, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_10, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 802, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_is_missing, __pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":803 * curtype = pywriter_types[col_indx] * is_missing = col_types[col_indx][2] * curuser_missing = None # <<<<<<<<<<<<<< * if missing_user_values: * curuser_missing = missing_user_values.get(col_names[col_indx]) */ __Pyx_INCREF(Py_None); __Pyx_XDECREF_SET(__pyx_v_curuser_missing, Py_None); /* "pyreadstat/_readstat_writer.pyx":804 * is_missing = col_types[col_indx][2] * curuser_missing = None * if missing_user_values: # <<<<<<<<<<<<<< * curuser_missing = missing_user_values.get(col_names[col_indx]) * */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_missing_user_values); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 804, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":805 * curuser_missing = None * if missing_user_values: * curuser_missing = missing_user_values.get(col_names[col_indx]) # <<<<<<<<<<<<<< * * if is_missing: */ if (unlikely(__pyx_v_missing_user_values == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "get"); __PYX_ERR(0, 805, __pyx_L55_error) } if (unlikely(__pyx_v_col_names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 805, __pyx_L55_error) } __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_col_names, __pyx_v_col_indx, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 805, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = __Pyx_PyDict_GetItemDefault(__pyx_v_missing_user_values, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 805, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_curuser_missing, __pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":804 * is_missing = col_types[col_indx][2] * curuser_missing = None * if missing_user_values: # <<<<<<<<<<<<<< * curuser_missing = missing_user_values.get(col_names[col_indx]) * */ } /* "pyreadstat/_readstat_writer.pyx":807 * curuser_missing = missing_user_values.get(col_names[col_indx]) * * if is_missing: # <<<<<<<<<<<<<< * #if curval is None or (type(curval) in numeric_types and np.isnan(curval)): * if pd.isna(curval): */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_is_missing); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 807, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":809 * if is_missing: * #if curval is None or (type(curval) in numeric_types and np.isnan(curval)): * if pd.isna(curval): # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_missing_value(writer, tempvar)) * continue */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 809, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isna); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 809, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_curval}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 809, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 809, __pyx_L55_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":810 * #if curval is None or (type(curval) in numeric_types and np.isnan(curval)): * if pd.isna(curval): * check_exit_status(readstat_insert_missing_value(writer, tempvar)) # <<<<<<<<<<<<<< * continue * */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_missing_value(__pyx_v_writer, __pyx_v_tempvar)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 810, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":811 * if pd.isna(curval): * check_exit_status(readstat_insert_missing_value(writer, tempvar)) * continue # <<<<<<<<<<<<<< * * if curuser_missing and curtype in pywriter_numeric_types: */ goto __pyx_L114_continue; /* "pyreadstat/_readstat_writer.pyx":809 * if is_missing: * #if curval is None or (type(curval) in numeric_types and np.isnan(curval)): * if pd.isna(curval): # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_missing_value(writer, tempvar)) * continue */ } /* "pyreadstat/_readstat_writer.pyx":807 * curuser_missing = missing_user_values.get(col_names[col_indx]) * * if is_missing: # <<<<<<<<<<<<<< * #if curval is None or (type(curval) in numeric_types and np.isnan(curval)): * if pd.isna(curval): */ } /* "pyreadstat/_readstat_writer.pyx":813 * continue * * if curuser_missing and curtype in pywriter_numeric_types: # <<<<<<<<<<<<<< * if curval in curuser_missing: * check_exit_status(readstat_insert_tagged_missing_value(writer, tempvar, ord(curval))) */ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_curuser_missing); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 813, __pyx_L55_error) if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L120_bool_binop_done; } __pyx_t_10 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_v_curtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 813, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 813, __pyx_L55_error) } __pyx_t_4 = (__Pyx_PySet_ContainsTF(__pyx_t_10, __pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 813, __pyx_L55_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_3 = __pyx_t_4; __pyx_L120_bool_binop_done:; if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":814 * * if curuser_missing and curtype in pywriter_numeric_types: * if curval in curuser_missing: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_tagged_missing_value(writer, tempvar, ord(curval))) * continue */ __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_curval, __pyx_v_curuser_missing, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 814, __pyx_L55_error) if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":815 * if curuser_missing and curtype in pywriter_numeric_types: * if curval in curuser_missing: * check_exit_status(readstat_insert_tagged_missing_value(writer, tempvar, ord(curval))) # <<<<<<<<<<<<<< * continue * */ __pyx_t_14 = __Pyx_PyObject_Ord(__pyx_v_curval); if (unlikely(__pyx_t_14 == ((long)(long)(Py_UCS4)-1))) __PYX_ERR(0, 815, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_tagged_missing_value(__pyx_v_writer, __pyx_v_tempvar, __pyx_t_14)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 815, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":816 * if curval in curuser_missing: * check_exit_status(readstat_insert_tagged_missing_value(writer, tempvar, ord(curval))) * continue # <<<<<<<<<<<<<< * * if curtype == PYWRITER_DOUBLE: */ goto __pyx_L114_continue; /* "pyreadstat/_readstat_writer.pyx":814 * * if curuser_missing and curtype in pywriter_numeric_types: * if curval in curuser_missing: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_tagged_missing_value(writer, tempvar, ord(curval))) * continue */ } /* "pyreadstat/_readstat_writer.pyx":813 * continue * * if curuser_missing and curtype in pywriter_numeric_types: # <<<<<<<<<<<<<< * if curval in curuser_missing: * check_exit_status(readstat_insert_tagged_missing_value(writer, tempvar, ord(curval))) */ } /* "pyreadstat/_readstat_writer.pyx":818 * continue * * if curtype == PYWRITER_DOUBLE: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype == PYWRITER_INTEGER: */ __pyx_t_3 = (__pyx_v_curtype == __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DOUBLE); if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":819 * * if curtype == PYWRITER_DOUBLE: * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) # <<<<<<<<<<<<<< * elif curtype == PYWRITER_INTEGER: * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) */ __pyx_t_33 = __pyx_PyFloat_AsDouble(__pyx_v_curval); if (unlikely((__pyx_t_33 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_double_value(__pyx_v_writer, __pyx_v_tempvar, ((double)__pyx_t_33))); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 819, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":818 * continue * * if curtype == PYWRITER_DOUBLE: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype == PYWRITER_INTEGER: */ goto __pyx_L123; } /* "pyreadstat/_readstat_writer.pyx":820 * if curtype == PYWRITER_DOUBLE: * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype == PYWRITER_INTEGER: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_LOGICAL: */ __pyx_t_3 = (__pyx_v_curtype == __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_INTEGER); if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":821 * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype == PYWRITER_INTEGER: * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) # <<<<<<<<<<<<<< * elif curtype == PYWRITER_LOGICAL: * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) */ __pyx_t_34 = __Pyx_PyInt_As_int32_t(__pyx_v_curval); if (unlikely((__pyx_t_34 == ((int32_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 821, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_int32_value(__pyx_v_writer, __pyx_v_tempvar, __pyx_t_34)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 821, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":820 * if curtype == PYWRITER_DOUBLE: * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype == PYWRITER_INTEGER: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_LOGICAL: */ goto __pyx_L123; } /* "pyreadstat/_readstat_writer.pyx":822 * elif curtype == PYWRITER_INTEGER: * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_LOGICAL: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_CHARACTER: */ __pyx_t_3 = (__pyx_v_curtype == __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_LOGICAL); if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":823 * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_LOGICAL: * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) # <<<<<<<<<<<<<< * elif curtype == PYWRITER_CHARACTER: * check_exit_status(readstat_insert_string_value(writer, tempvar, curval.encode("utf-8"))) */ __pyx_t_25 = __Pyx_PyInt_As_int(__pyx_v_curval); if (unlikely((__pyx_t_25 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_int32_value(__pyx_v_writer, __pyx_v_tempvar, ((int)__pyx_t_25))); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 823, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":822 * elif curtype == PYWRITER_INTEGER: * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_LOGICAL: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_CHARACTER: */ goto __pyx_L123; } /* "pyreadstat/_readstat_writer.pyx":824 * elif curtype == PYWRITER_LOGICAL: * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_CHARACTER: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_string_value(writer, tempvar, curval.encode("utf-8"))) * elif curtype == PYWRITER_OBJECT: */ __pyx_t_3 = (__pyx_v_curtype == __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER); if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":825 * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_CHARACTER: * check_exit_status(readstat_insert_string_value(writer, tempvar, curval.encode("utf-8"))) # <<<<<<<<<<<<<< * elif curtype == PYWRITER_OBJECT: * curvalstr = str(curval) */ __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_curval, __pyx_n_s_encode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 825, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_2 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_s_utf_8}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 825, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_t_35 = __Pyx_PyObject_AsString(__pyx_t_10); if (unlikely((!__pyx_t_35) && PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_string_value(__pyx_v_writer, __pyx_v_tempvar, __pyx_t_35)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 825, __pyx_L55_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":824 * elif curtype == PYWRITER_LOGICAL: * check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) * elif curtype == PYWRITER_CHARACTER: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_string_value(writer, tempvar, curval.encode("utf-8"))) * elif curtype == PYWRITER_OBJECT: */ goto __pyx_L123; } /* "pyreadstat/_readstat_writer.pyx":826 * elif curtype == PYWRITER_CHARACTER: * check_exit_status(readstat_insert_string_value(writer, tempvar, curval.encode("utf-8"))) * elif curtype == PYWRITER_OBJECT: # <<<<<<<<<<<<<< * curvalstr = str(curval) * check_exit_status(readstat_insert_string_value(writer, tempvar, curvalstr.encode("utf-8"))) */ __pyx_t_3 = (__pyx_v_curtype == __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT); if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":827 * check_exit_status(readstat_insert_string_value(writer, tempvar, curval.encode("utf-8"))) * elif curtype == PYWRITER_OBJECT: * curvalstr = str(curval) # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_string_value(writer, tempvar, curvalstr.encode("utf-8"))) * elif curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: */ __pyx_t_10 = __Pyx_PyObject_Str(__pyx_v_curval); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 827, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); if (!(likely(PyString_CheckExact(__pyx_t_10)) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_10))) __PYX_ERR(0, 827, __pyx_L55_error) __Pyx_XDECREF_SET(__pyx_v_curvalstr, ((PyObject*)__pyx_t_10)); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":828 * elif curtype == PYWRITER_OBJECT: * curvalstr = str(curval) * check_exit_status(readstat_insert_string_value(writer, tempvar, curvalstr.encode("utf-8"))) # <<<<<<<<<<<<<< * elif curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) */ __pyx_t_10 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyString_Type_encode, __pyx_v_curvalstr, __pyx_kp_s_utf_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 828, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_35 = __Pyx_PyObject_AsString(__pyx_t_10); if (unlikely((!__pyx_t_35) && PyErr_Occurred())) __PYX_ERR(0, 828, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_string_value(__pyx_v_writer, __pyx_v_tempvar, __pyx_t_35)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 828, __pyx_L55_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":826 * elif curtype == PYWRITER_CHARACTER: * check_exit_status(readstat_insert_string_value(writer, tempvar, curval.encode("utf-8"))) * elif curtype == PYWRITER_OBJECT: # <<<<<<<<<<<<<< * curvalstr = str(curval) * check_exit_status(readstat_insert_string_value(writer, tempvar, curvalstr.encode("utf-8"))) */ goto __pyx_L123; } /* "pyreadstat/_readstat_writer.pyx":829 * curvalstr = str(curval) * check_exit_status(readstat_insert_string_value(writer, tempvar, curvalstr.encode("utf-8"))) * elif curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype in pyrwriter_datetimelike_types: */ switch (__pyx_v_curtype) { case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS: case __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US: __pyx_t_3 = 1; break; default: __pyx_t_3 = 0; break; } if (__pyx_t_3) { /* "pyreadstat/_readstat_writer.pyx":830 * check_exit_status(readstat_insert_string_value(writer, tempvar, curvalstr.encode("utf-8"))) * elif curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) # <<<<<<<<<<<<<< * elif curtype in pyrwriter_datetimelike_types: * dtimelikeval = convert_datetimelike_to_number(file_format, curtype, curval) */ __pyx_t_33 = __pyx_PyFloat_AsDouble(__pyx_v_curval); if (unlikely((__pyx_t_33 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L55_error) __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_double_value(__pyx_v_writer, __pyx_v_tempvar, ((double)__pyx_t_33))); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 830, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":829 * curvalstr = str(curval) * check_exit_status(readstat_insert_string_value(writer, tempvar, curvalstr.encode("utf-8"))) * elif curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype in pyrwriter_datetimelike_types: */ goto __pyx_L123; } /* "pyreadstat/_readstat_writer.pyx":831 * elif curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype in pyrwriter_datetimelike_types: # <<<<<<<<<<<<<< * dtimelikeval = convert_datetimelike_to_number(file_format, curtype, curval) * check_exit_status(readstat_insert_double_value(writer, tempvar, dtimelikeval)) */ __pyx_t_10 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_v_curtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 831, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); if (unlikely(__pyx_v_10pyreadstat_16_readstat_writer_pyrwriter_datetimelike_types == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 831, __pyx_L55_error) } __pyx_t_3 = (__Pyx_PySet_ContainsTF(__pyx_t_10, __pyx_v_10pyreadstat_16_readstat_writer_pyrwriter_datetimelike_types, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 831, __pyx_L55_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (likely(__pyx_t_3)) { /* "pyreadstat/_readstat_writer.pyx":832 * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype in pyrwriter_datetimelike_types: * dtimelikeval = convert_datetimelike_to_number(file_format, curtype, curval) # <<<<<<<<<<<<<< * check_exit_status(readstat_insert_double_value(writer, tempvar, dtimelikeval)) * else: */ __pyx_t_33 = __pyx_f_10pyreadstat_16_readstat_writer_convert_datetimelike_to_number(__pyx_v_file_format, __pyx_v_curtype, __pyx_v_curval); if (unlikely(__pyx_t_33 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 832, __pyx_L55_error) __pyx_v_dtimelikeval = __pyx_t_33; /* "pyreadstat/_readstat_writer.pyx":833 * elif curtype in pyrwriter_datetimelike_types: * dtimelikeval = convert_datetimelike_to_number(file_format, curtype, curval) * check_exit_status(readstat_insert_double_value(writer, tempvar, dtimelikeval)) # <<<<<<<<<<<<<< * else: * raise PyreadstatError("Unknown data format to insert") */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_insert_double_value(__pyx_v_writer, __pyx_v_tempvar, __pyx_v_dtimelikeval)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 833, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":831 * elif curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: * check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) * elif curtype in pyrwriter_datetimelike_types: # <<<<<<<<<<<<<< * dtimelikeval = convert_datetimelike_to_number(file_format, curtype, curval) * check_exit_status(readstat_insert_double_value(writer, tempvar, dtimelikeval)) */ goto __pyx_L123; } /* "pyreadstat/_readstat_writer.pyx":835 * check_exit_status(readstat_insert_double_value(writer, tempvar, dtimelikeval)) * else: * raise PyreadstatError("Unknown data format to insert") # <<<<<<<<<<<<<< * * check_exit_status(readstat_end_row(writer)) */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 835, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_2 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_s_Unknown_data_format_to_insert}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_25, 1+__pyx_t_25); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 835, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 835, __pyx_L55_error) } __pyx_L123:; __pyx_L114_continue:; } /* "pyreadstat/_readstat_writer.pyx":837 * raise PyreadstatError("Unknown data format to insert") * * check_exit_status(readstat_end_row(writer)) # <<<<<<<<<<<<<< * rowcnt += 1 * */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_end_row(__pyx_v_writer)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 837, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":838 * * check_exit_status(readstat_end_row(writer)) * rowcnt += 1 # <<<<<<<<<<<<<< * * check_exit_status(readstat_end_writing(writer)) */ __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_v_rowcnt, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 838, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF_SET(__pyx_v_rowcnt, __pyx_t_10); __pyx_t_10 = 0; /* "pyreadstat/_readstat_writer.pyx":794 * rowcnt = 0 * * for row in df2.values: # <<<<<<<<<<<<<< * check_exit_status(readstat_begin_row(writer)) * */ } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/_readstat_writer.pyx":840 * rowcnt += 1 * * check_exit_status(readstat_end_writing(writer)) # <<<<<<<<<<<<<< * * except: */ __pyx_f_10pyreadstat_16_readstat_parser_check_exit_status(readstat_end_writing(__pyx_v_writer)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 840, __pyx_L55_error) /* "pyreadstat/_readstat_writer.pyx":653 * writer = readstat_writer_init() * * try: # <<<<<<<<<<<<<< * * check_exit_status(readstat_set_data_writer(writer, write_bytes)) */ } __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L60_try_end; __pyx_L55_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/_readstat_writer.pyx":842 * check_exit_status(readstat_end_writing(writer)) * * except: # <<<<<<<<<<<<<< * raise * finally: */ /*except:*/ { __Pyx_AddTraceback("pyreadstat._readstat_writer.run_write", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_10, &__pyx_t_15) < 0) __PYX_ERR(0, 842, __pyx_L57_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_15); /* "pyreadstat/_readstat_writer.pyx":843 * * except: * raise # <<<<<<<<<<<<<< * finally: * readstat_writer_free(writer) */ __Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_10, __pyx_t_15); __pyx_t_1 = 0; __pyx_t_10 = 0; __pyx_t_15 = 0; __PYX_ERR(0, 843, __pyx_L57_except_error) } /* "pyreadstat/_readstat_writer.pyx":653 * writer = readstat_writer_init() * * try: # <<<<<<<<<<<<<< * * check_exit_status(readstat_set_data_writer(writer, write_bytes)) */ __pyx_L57_except_error:; __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_17, __pyx_t_16); goto __pyx_L53_error; __pyx_L60_try_end:; } } /* "pyreadstat/_readstat_writer.pyx":845 * raise * finally: * readstat_writer_free(writer) # <<<<<<<<<<<<<< * close_file(fd) * */ /*finally:*/ { /*normal exit:*/{ readstat_writer_free(__pyx_v_writer); /* "pyreadstat/_readstat_writer.pyx":846 * finally: * readstat_writer_free(writer) * close_file(fd) # <<<<<<<<<<<<<< * * return 0 */ __pyx_t_6 = __pyx_f_10pyreadstat_16_readstat_writer_close_file(__pyx_v_fd); if (unlikely(__pyx_t_6 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 846, __pyx_L1_error) goto __pyx_L54; } __pyx_L53_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_37 = 0; __pyx_t_38 = 0; __pyx_t_39 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_37, &__pyx_t_38, &__pyx_t_39); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_37); __Pyx_XGOTREF(__pyx_t_38); __Pyx_XGOTREF(__pyx_t_39); __pyx_t_6 = __pyx_lineno; __pyx_t_23 = __pyx_clineno; __pyx_t_36 = __pyx_filename; { /* "pyreadstat/_readstat_writer.pyx":845 * raise * finally: * readstat_writer_free(writer) # <<<<<<<<<<<<<< * close_file(fd) * */ readstat_writer_free(__pyx_v_writer); /* "pyreadstat/_readstat_writer.pyx":846 * finally: * readstat_writer_free(writer) * close_file(fd) # <<<<<<<<<<<<<< * * return 0 */ __pyx_t_24 = __pyx_f_10pyreadstat_16_readstat_writer_close_file(__pyx_v_fd); if (unlikely(__pyx_t_24 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 846, __pyx_L128_error) } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_37); __Pyx_XGIVEREF(__pyx_t_38); __Pyx_XGIVEREF(__pyx_t_39); __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_38, __pyx_t_39); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_37 = 0; __pyx_t_38 = 0; __pyx_t_39 = 0; __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_23; __pyx_filename = __pyx_t_36; goto __pyx_L1_error; __pyx_L128_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_37); __Pyx_XGIVEREF(__pyx_t_38); __Pyx_XGIVEREF(__pyx_t_39); __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_38, __pyx_t_39); } __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_37 = 0; __pyx_t_38 = 0; __pyx_t_39 = 0; goto __pyx_L1_error; } __pyx_L54:; } /* "pyreadstat/_readstat_writer.pyx":848 * close_file(fd) * * return 0 # <<<<<<<<<<<<<< */ __pyx_r = 0; goto __pyx_L0; /* "pyreadstat/_readstat_writer.pyx":548 * return close(fd) * * cdef int run_write(df, object filename_path, dst_file_format file_format, str file_label, object column_labels, # <<<<<<<<<<<<<< * int file_format_version, str note, str table_name, dict variable_value_labels, * dict missing_ranges, dict missing_user_values, dict variable_alignment, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_20); __Pyx_AddTraceback("pyreadstat._readstat_writer.run_write", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_k); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_valid_user_missing); __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_missing_values); __Pyx_XDECREF(__pyx_v_val); __Pyx_XDECREF(__pyx_v_file_label_bytes); __Pyx_XDECREF(__pyx_v_col_names); __Pyx_XDECREF(__pyx_v_variable_name); __Pyx_XDECREF(__pyx_v_col_types); __Pyx_XDECREF(__pyx_v_col_names_to_types); __Pyx_XDECREF(__pyx_v_tempformat); __Pyx_XDECREF(__pyx_v_cur_col_label); __Pyx_XDECREF(__pyx_v_curvalstr); __Pyx_XDECREF(__pyx_v_value_labels); __Pyx_XDECREF(__pyx_v_col_label_temp); __Pyx_XDECREF(__pyx_v_pywriter_types); __Pyx_XDECREF(__pyx_v_df2); __Pyx_XDECREF(__pyx_v_filename_bytes); __Pyx_XDECREF(__pyx_v_table_name_bytes); __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_labelset_name); __Pyx_XDECREF(__pyx_v_curuser_missing); __Pyx_XDECREF(__pyx_v_cur_ranges); __Pyx_XDECREF(__pyx_v_cur_alignment); __Pyx_XDECREF(__pyx_v_cur_display_width); __Pyx_XDECREF(__pyx_v_cur_measure); __Pyx_XDECREF(__pyx_v_rowcnt); __Pyx_XDECREF(__pyx_v_row); __Pyx_XDECREF(__pyx_v_curval); __Pyx_XDECREF(__pyx_v_is_missing); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_k); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_v); __Pyx_XDECREF(__pyx_v_filename_path); __Pyx_XDECREF(__pyx_v_column_labels); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif /* #### Code section: pystring_table ### */ static int __Pyx_CreateStringTabAndInitStrings(void) { __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_CategoricalDtype, __pyx_k_CategoricalDtype, sizeof(__pyx_k_CategoricalDtype), 0, 0, 1, 1}, {&__pyx_kp_s_Column_labels_must_be_strings, __pyx_k_Column_labels_must_be_strings, sizeof(__pyx_k_Column_labels_must_be_strings), 0, 0, 1, 0}, {&__pyx_n_s_DataFrame, __pyx_k_DataFrame, sizeof(__pyx_k_DataFrame), 0, 0, 1, 1}, {&__pyx_n_s_Float32Dtype, __pyx_k_Float32Dtype, sizeof(__pyx_k_Float32Dtype), 0, 0, 1, 1}, {&__pyx_n_s_Float64Dtype, __pyx_k_Float64Dtype, sizeof(__pyx_k_Float64Dtype), 0, 0, 1, 1}, {&__pyx_n_s_Int16Dtype, __pyx_k_Int16Dtype, sizeof(__pyx_k_Int16Dtype), 0, 0, 1, 1}, {&__pyx_n_s_Int32Dtype, __pyx_k_Int32Dtype, sizeof(__pyx_k_Int32Dtype), 0, 0, 1, 1}, {&__pyx_n_s_Int64Dtype, __pyx_k_Int64Dtype, sizeof(__pyx_k_Int64Dtype), 0, 0, 1, 1}, {&__pyx_n_s_Int8Dtype, __pyx_k_Int8Dtype, sizeof(__pyx_k_Int8Dtype), 0, 0, 1, 1}, {&__pyx_kp_s_M8_ns, __pyx_k_M8_ns, sizeof(__pyx_k_M8_ns), 0, 0, 1, 0}, {&__pyx_kp_s_Non_unique_column_names_detected, __pyx_k_Non_unique_column_names_detected, sizeof(__pyx_k_Non_unique_column_names_detected), 0, 0, 1, 0}, {&__pyx_n_s_PyreadstatError, __pyx_k_PyreadstatError, sizeof(__pyx_k_PyreadstatError), 0, 0, 1, 1}, {&__pyx_n_s_ReadstatError, __pyx_k_ReadstatError, sizeof(__pyx_k_ReadstatError), 0, 0, 1, 1}, {&__pyx_n_s_Timestamp, __pyx_k_Timestamp, sizeof(__pyx_k_Timestamp), 0, 0, 1, 1}, {&__pyx_n_s_UInt16Dtype, __pyx_k_UInt16Dtype, sizeof(__pyx_k_UInt16Dtype), 0, 0, 1, 1}, {&__pyx_n_s_UInt32Dtype, __pyx_k_UInt32Dtype, sizeof(__pyx_k_UInt32Dtype), 0, 0, 1, 1}, {&__pyx_n_s_UInt64Dtype, __pyx_k_UInt64Dtype, sizeof(__pyx_k_UInt64Dtype), 0, 0, 1, 1}, {&__pyx_n_s_UInt8Dtype, __pyx_k_UInt8Dtype, sizeof(__pyx_k_UInt8Dtype), 0, 0, 1, 1}, {&__pyx_n_s_UnicodeError, __pyx_k_UnicodeError, sizeof(__pyx_k_UnicodeError), 0, 0, 1, 1}, {&__pyx_kp_s_Unknown_data_format_to_insert, __pyx_k_Unknown_data_format_to_insert, sizeof(__pyx_k_Unknown_data_format_to_insert), 0, 0, 1, 0}, {&__pyx_kp_s_Unknown_pywriter_variable_format, __pyx_k_Unknown_pywriter_variable_format, sizeof(__pyx_k_Unknown_pywriter_variable_format), 0, 0, 1, 0}, {&__pyx_n_s__17, __pyx_k__17, sizeof(__pyx_k__17), 0, 0, 1, 1}, {&__pyx_n_s__18, __pyx_k__18, sizeof(__pyx_k__18), 0, 0, 1, 1}, {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0}, {&__pyx_n_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 1}, {&__pyx_kp_u__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 1, 0, 0}, {&__pyx_kp_s_alignment_for_variable_s_must_be, __pyx_k_alignment_for_variable_s_must_be, sizeof(__pyx_k_alignment_for_variable_s_must_be), 0, 0, 1, 0}, {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1}, {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1}, {&__pyx_n_s_asm8, __pyx_k_asm8, sizeof(__pyx_k_asm8), 0, 0, 1, 1}, {&__pyx_n_s_astype, __pyx_k_astype, sizeof(__pyx_k_astype), 0, 0, 1, 1}, {&__pyx_n_s_calendar, __pyx_k_calendar, sizeof(__pyx_k_calendar), 0, 0, 1, 1}, {&__pyx_n_s_center, __pyx_k_center, sizeof(__pyx_k_center), 0, 0, 1, 1}, {&__pyx_kp_s_character_missing_ranges_value_g, __pyx_k_character_missing_ranges_value_g, sizeof(__pyx_k_character_missing_ranges_value_g), 0, 0, 1, 0}, {&__pyx_n_s_chr, __pyx_k_chr, sizeof(__pyx_k_chr), 0, 0, 1, 1}, {&__pyx_n_s_class_getitem, __pyx_k_class_getitem, sizeof(__pyx_k_class_getitem), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_kp_s_column_labels_must_be_either_lis, __pyx_k_column_labels_must_be_either_lis, sizeof(__pyx_k_column_labels_must_be_either_lis), 0, 0, 1, 0}, {&__pyx_n_s_columns, __pyx_k_columns, sizeof(__pyx_k_columns), 0, 0, 1, 1}, {&__pyx_n_s_combine, __pyx_k_combine, sizeof(__pyx_k_combine), 0, 0, 1, 1}, {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1}, {&__pyx_n_s_core, __pyx_k_core, sizeof(__pyx_k_core), 0, 0, 1, 1}, {&__pyx_n_s_date, __pyx_k_date, sizeof(__pyx_k_date), 0, 0, 1, 1}, {&__pyx_n_s_datetime, __pyx_k_datetime, sizeof(__pyx_k_datetime), 0, 0, 1, 1}, {&__pyx_n_s_datetime64, __pyx_k_datetime64, sizeof(__pyx_k_datetime64), 0, 0, 1, 1}, {&__pyx_kp_s_datetime64_ms, __pyx_k_datetime64_ms, sizeof(__pyx_k_datetime64_ms), 0, 0, 1, 0}, {&__pyx_kp_s_datetime64_ns, __pyx_k_datetime64_ns, sizeof(__pyx_k_datetime64_ns), 0, 0, 1, 0}, {&__pyx_kp_s_datetime64_us, __pyx_k_datetime64_us, sizeof(__pyx_k_datetime64_us), 0, 0, 1, 0}, {&__pyx_kp_s_datetime64_us_2, __pyx_k_datetime64_us_2, sizeof(__pyx_k_datetime64_us_2), 0, 0, 1, 0}, {&__pyx_n_s_days, __pyx_k_days, sizeof(__pyx_k_days), 0, 0, 1, 1}, {&__pyx_kp_s_dictionaries_in_missing_ranges_m, __pyx_k_dictionaries_in_missing_ranges_m, sizeof(__pyx_k_dictionaries_in_missing_ranges_m), 0, 0, 1, 0}, {&__pyx_n_s_drop, __pyx_k_drop, sizeof(__pyx_k_drop), 0, 0, 1, 1}, {&__pyx_n_s_dropna, __pyx_k_dropna, sizeof(__pyx_k_dropna), 0, 0, 1, 1}, {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, {&__pyx_n_s_dtypes, __pyx_k_dtypes, sizeof(__pyx_k_dtypes), 0, 0, 1, 1}, {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_expanduser, __pyx_k_expanduser, sizeof(__pyx_k_expanduser), 0, 0, 1, 1}, {&__pyx_kp_s_file_path_could_not_be_encoded_w, __pyx_k_file_path_could_not_be_encoded_w, sizeof(__pyx_k_file_path_could_not_be_encoded_w), 0, 0, 1, 0}, {&__pyx_kp_s_first_argument_must_be_a_pandas, __pyx_k_first_argument_must_be_a_pandas, sizeof(__pyx_k_first_argument_must_be_a_pandas), 0, 0, 1, 0}, {&__pyx_n_s_float, __pyx_k_float, sizeof(__pyx_k_float), 0, 0, 1, 1}, {&__pyx_n_s_float32, __pyx_k_float32, sizeof(__pyx_k_float32), 0, 0, 1, 1}, {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, {&__pyx_n_s_fsdecode, __pyx_k_fsdecode, sizeof(__pyx_k_fsdecode), 0, 0, 1, 1}, {&__pyx_n_s_fsencode, __pyx_k_fsencode, sizeof(__pyx_k_fsencode), 0, 0, 1, 1}, {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, {&__pyx_n_s_getfilesystemencoding, __pyx_k_getfilesystemencoding, sizeof(__pyx_k_getfilesystemencoding), 0, 0, 1, 1}, {&__pyx_n_s_hi, __pyx_k_hi, sizeof(__pyx_k_hi), 0, 0, 1, 1}, {&__pyx_n_s_iloc, __pyx_k_iloc, sizeof(__pyx_k_iloc), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_initializing, __pyx_k_initializing, sizeof(__pyx_k_initializing), 0, 0, 1, 1}, {&__pyx_n_s_int16, __pyx_k_int16, sizeof(__pyx_k_int16), 0, 0, 1, 1}, {&__pyx_n_s_int32, __pyx_k_int32, sizeof(__pyx_k_int32), 0, 0, 1, 1}, {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1}, {&__pyx_n_s_int8, __pyx_k_int8, sizeof(__pyx_k_int8), 0, 0, 1, 1}, {&__pyx_n_s_is_datetime64_any_dtype, __pyx_k_is_datetime64_any_dtype, sizeof(__pyx_k_is_datetime64_any_dtype), 0, 0, 1, 1}, {&__pyx_n_s_is_datetime64_ns_dtype, __pyx_k_is_datetime64_ns_dtype, sizeof(__pyx_k_is_datetime64_ns_dtype), 0, 0, 1, 1}, {&__pyx_n_s_isalpha, __pyx_k_isalpha, sizeof(__pyx_k_isalpha), 0, 0, 1, 1}, {&__pyx_n_s_isin, __pyx_k_isin, sizeof(__pyx_k_isin), 0, 0, 1, 1}, {&__pyx_n_s_isna, __pyx_k_isna, sizeof(__pyx_k_isna), 0, 0, 1, 1}, {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1}, {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1}, {&__pyx_n_s_left, __pyx_k_left, sizeof(__pyx_k_left), 0, 0, 1, 1}, {&__pyx_kp_s_length_of_column_labels_must_be, __pyx_k_length_of_column_labels_must_be, sizeof(__pyx_k_length_of_column_labels_must_be), 0, 0, 1, 0}, {&__pyx_n_s_libs, __pyx_k_libs, sizeof(__pyx_k_libs), 0, 0, 1, 1}, {&__pyx_n_s_lo, __pyx_k_lo, sizeof(__pyx_k_lo), 0, 0, 1, 1}, {&__pyx_n_s_loc, __pyx_k_loc, sizeof(__pyx_k_loc), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_kp_s_measure_for_variable_s_must_be_e, __pyx_k_measure_for_variable_s_must_be_e, sizeof(__pyx_k_measure_for_variable_s_must_be_e), 0, 0, 1, 0}, {&__pyx_n_s_min, __pyx_k_min, sizeof(__pyx_k_min), 0, 0, 1, 1}, {&__pyx_kp_s_missing_ranges_hi_and_lo_values, __pyx_k_missing_ranges_hi_and_lo_values, sizeof(__pyx_k_missing_ranges_hi_and_lo_values), 0, 0, 1, 0}, {&__pyx_kp_s_missing_ranges_hi_and_lo_values_2, __pyx_k_missing_ranges_hi_and_lo_values_2, sizeof(__pyx_k_missing_ranges_hi_and_lo_values_2), 0, 0, 1, 0}, {&__pyx_kp_s_missing_ranges_max_1_discrete_nu, __pyx_k_missing_ranges_max_1_discrete_nu, sizeof(__pyx_k_missing_ranges_max_1_discrete_nu), 0, 0, 1, 0}, {&__pyx_kp_s_missing_ranges_max_1_range_value, __pyx_k_missing_ranges_max_1_range_value, sizeof(__pyx_k_missing_ranges_max_1_range_value), 0, 0, 1, 0}, {&__pyx_kp_s_missing_ranges_max_3_discrete_nu, __pyx_k_missing_ranges_max_3_discrete_nu, sizeof(__pyx_k_missing_ranges_max_3_discrete_nu), 0, 0, 1, 0}, {&__pyx_kp_s_missing_ranges_max_3_string_valu, __pyx_k_missing_ranges_max_3_string_valu, sizeof(__pyx_k_missing_ranges_max_3_string_valu), 0, 0, 1, 0}, {&__pyx_kp_s_missing_ranges_string_values_len, __pyx_k_missing_ranges_string_values_len, sizeof(__pyx_k_missing_ranges_string_values_len), 0, 0, 1, 0}, {&__pyx_kp_s_missing_ranges_values_in_diction, __pyx_k_missing_ranges_values_in_diction, sizeof(__pyx_k_missing_ranges_values_in_diction), 0, 0, 1, 0}, {&__pyx_kp_s_missing_ranges_values_must_be_bo, __pyx_k_missing_ranges_values_must_be_bo, sizeof(__pyx_k_missing_ranges_values_must_be_bo), 0, 0, 1, 0}, {&__pyx_kp_s_missing_user_values_not_allowed, __pyx_k_missing_user_values_not_allowed, sizeof(__pyx_k_missing_user_values_not_allowed), 0, 0, 1, 0}, {&__pyx_kp_s_missing_user_values_supports_val, __pyx_k_missing_user_values_supports_val, sizeof(__pyx_k_missing_user_values_supports_val), 0, 0, 1, 0}, {&__pyx_kp_s_missing_user_values_values_in_di, __pyx_k_missing_user_values_values_in_di, sizeof(__pyx_k_missing_user_values_values_in_di), 0, 0, 1, 0}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, {&__pyx_n_s_nan, __pyx_k_nan, sizeof(__pyx_k_nan), 0, 0, 1, 1}, {&__pyx_n_s_nominal, __pyx_k_nominal, sizeof(__pyx_k_nominal), 0, 0, 1, 1}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_nt, __pyx_k_nt, sizeof(__pyx_k_nt), 0, 0, 1, 1}, {&__pyx_kp_s_numeric_missing_ranges_value_giv, __pyx_k_numeric_missing_ranges_value_giv, sizeof(__pyx_k_numeric_missing_ranges_value_giv), 0, 0, 1, 0}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1}, {&__pyx_n_s_ordinal, __pyx_k_ordinal, sizeof(__pyx_k_ordinal), 0, 0, 1, 1}, {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, {&__pyx_n_s_pandas, __pyx_k_pandas, sizeof(__pyx_k_pandas), 0, 0, 1, 1}, {&__pyx_n_s_pandas_api_types, __pyx_k_pandas_api_types, sizeof(__pyx_k_pandas_api_types), 0, 0, 1, 1}, {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1}, {&__pyx_kp_s_path_must_be_either_str_or_bytes, __pyx_k_path_must_be_either_str_or_bytes, sizeof(__pyx_k_path_must_be_either_str_or_bytes), 0, 0, 1, 0}, {&__pyx_n_s_pd, __pyx_k_pd, sizeof(__pyx_k_pd), 0, 0, 1, 1}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_readstat_parser, __pyx_k_readstat_parser, sizeof(__pyx_k_readstat_parser), 0, 0, 1, 1}, {&__pyx_n_s_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 0, 0, 1, 1}, {&__pyx_n_s_reset_index, __pyx_k_reset_index, sizeof(__pyx_k_reset_index), 0, 0, 1, 1}, {&__pyx_n_s_right, __pyx_k_right, sizeof(__pyx_k_right), 0, 0, 1, 1}, {&__pyx_n_s_round, __pyx_k_round, sizeof(__pyx_k_round), 0, 0, 1, 1}, {&__pyx_n_s_scale, __pyx_k_scale, sizeof(__pyx_k_scale), 0, 0, 1, 1}, {&__pyx_n_s_spec, __pyx_k_spec, sizeof(__pyx_k_spec), 0, 0, 1, 1}, {&__pyx_n_s_startswith, __pyx_k_startswith, sizeof(__pyx_k_startswith), 0, 0, 1, 1}, {&__pyx_n_s_string, __pyx_k_string, sizeof(__pyx_k_string), 0, 0, 1, 1}, {&__pyx_n_s_surrogateescape, __pyx_k_surrogateescape, sizeof(__pyx_k_surrogateescape), 0, 0, 1, 1}, {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_time, __pyx_k_time, sizeof(__pyx_k_time), 0, 0, 1, 1}, {&__pyx_n_s_timegm, __pyx_k_timegm, sizeof(__pyx_k_timegm), 0, 0, 1, 1}, {&__pyx_n_s_timestamps, __pyx_k_timestamps, sizeof(__pyx_k_timestamps), 0, 0, 1, 1}, {&__pyx_n_s_timetuple, __pyx_k_timetuple, sizeof(__pyx_k_timetuple), 0, 0, 1, 1}, {&__pyx_n_s_timezone, __pyx_k_timezone, sizeof(__pyx_k_timezone), 0, 0, 1, 1}, {&__pyx_n_s_timezone_2, __pyx_k_timezone_2, sizeof(__pyx_k_timezone_2), 0, 0, 1, 1}, {&__pyx_n_s_tolist, __pyx_k_tolist, sizeof(__pyx_k_tolist), 0, 0, 1, 1}, {&__pyx_n_s_total_seconds, __pyx_k_total_seconds, sizeof(__pyx_k_total_seconds), 0, 0, 1, 1}, {&__pyx_n_s_tslibs, __pyx_k_tslibs, sizeof(__pyx_k_tslibs), 0, 0, 1, 1}, {&__pyx_n_s_tzinfo, __pyx_k_tzinfo, sizeof(__pyx_k_tzinfo), 0, 0, 1, 1}, {&__pyx_n_s_uint16, __pyx_k_uint16, sizeof(__pyx_k_uint16), 0, 0, 1, 1}, {&__pyx_n_s_uint32, __pyx_k_uint32, sizeof(__pyx_k_uint32), 0, 0, 1, 1}, {&__pyx_n_s_uint64, __pyx_k_uint64, sizeof(__pyx_k_uint64), 0, 0, 1, 1}, {&__pyx_n_s_uint8, __pyx_k_uint8, sizeof(__pyx_k_uint8), 0, 0, 1, 1}, {&__pyx_n_s_union, __pyx_k_union, sizeof(__pyx_k_union), 0, 0, 1, 1}, {&__pyx_n_s_unknown, __pyx_k_unknown, sizeof(__pyx_k_unknown), 0, 0, 1, 1}, {&__pyx_kp_s_unknown_file_format, __pyx_k_unknown_file_format, sizeof(__pyx_k_unknown_file_format), 0, 0, 1, 0}, {&__pyx_n_s_upper, __pyx_k_upper, sizeof(__pyx_k_upper), 0, 0, 1, 1}, {&__pyx_n_s_utc, __pyx_k_utc, sizeof(__pyx_k_utc), 0, 0, 1, 1}, {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0}, {&__pyx_n_s_values, __pyx_k_values, sizeof(__pyx_k_values), 0, 0, 1, 1}, {&__pyx_kp_s_variable_name_s_contains_a_space, __pyx_k_variable_name_s_contains_a_space, sizeof(__pyx_k_variable_name_s_contains_a_space), 0, 0, 1, 0}, {&__pyx_kp_s_variable_name_s_is_of_type_s_and, __pyx_k_variable_name_s_is_of_type_s_and, sizeof(__pyx_k_variable_name_s_is_of_type_s_and), 0, 0, 1, 0}, {&__pyx_kp_s_variable_name_s_starts_with_an_i, __pyx_k_variable_name_s_starts_with_an_i, sizeof(__pyx_k_variable_name_s_starts_with_an_i), 0, 0, 1, 0}, {&__pyx_kp_s_variable_value_labels_type_of_La, __pyx_k_variable_value_labels_type_of_La, sizeof(__pyx_k_variable_value_labels_type_of_La), 0, 0, 1, 0}, {&__pyx_kp_s_variable_value_labels_type_of_Va, __pyx_k_variable_value_labels_type_of_Va, sizeof(__pyx_k_variable_value_labels_type_of_Va), 0, 0, 1, 0}, {&__pyx_kp_s_variable_value_labels_type_of_Va_2, __pyx_k_variable_value_labels_type_of_Va_2, sizeof(__pyx_k_variable_value_labels_type_of_Va_2), 0, 0, 1, 0}, {&__pyx_kp_s_variable_value_labels_type_of_Va_3, __pyx_k_variable_value_labels_type_of_Va_3, sizeof(__pyx_k_variable_value_labels_type_of_Va_3), 0, 0, 1, 0}, {&__pyx_kp_s_variable_value_labels_type_of_Va_4, __pyx_k_variable_value_labels_type_of_Va_4, sizeof(__pyx_k_variable_value_labels_type_of_Va_4), 0, 0, 1, 0}, {&__pyx_kp_s_variable_value_labels_value_for, __pyx_k_variable_value_labels_value_for, sizeof(__pyx_k_variable_value_labels_value_for), 0, 0, 1, 0}, {&__pyx_n_s_warn, __pyx_k_warn, sizeof(__pyx_k_warn), 0, 0, 1, 1}, {&__pyx_n_s_warnings, __pyx_k_warnings, sizeof(__pyx_k_warnings), 0, 0, 1, 1}, {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, {&__pyx_n_s_zip, __pyx_k_zip, sizeof(__pyx_k_zip), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; return __Pyx_InitStrings(__pyx_string_tab); } /* #### Code section: cached_builtins ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 58, __pyx_L1_error) __pyx_builtin_chr = __Pyx_GetBuiltinName(__pyx_n_s_chr); if (!__pyx_builtin_chr) __PYX_ERR(0, 58, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 199, __pyx_L1_error) __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_n_s_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 199, __pyx_L1_error) __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 231, __pyx_L1_error) __pyx_builtin_UnicodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeError); if (!__pyx_builtin_UnicodeError) __PYX_ERR(0, 638, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: cached_constants ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "pyreadstat/_readstat_writer.pyx":202 * * max_length = 0 * curseries = df.iloc[:, indx] # <<<<<<<<<<<<<< * curuser_missing = None * if missing_user_values: */ __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 202, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice_); __Pyx_GIVEREF(__pyx_slice_); /* "pyreadstat/_readstat_writer.pyx":640 * except UnicodeError: * warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) * filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") # <<<<<<<<<<<<<< * else: * if type(filename_path) == str: */ __pyx_tuple__3 = PyTuple_Pack(2, __pyx_kp_s_utf_8, __pyx_n_s_surrogateescape); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 640, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "pyreadstat/_readstat_writer.pyx":35 * from _readstat_parser cimport check_exit_status * * cdef set int_types = {int, np.dtype('int32'), np.dtype('int16'), np.dtype('int8'), np.dtype('uint8'), np.dtype('uint16'), # <<<<<<<<<<<<<< * np.int32, np.int16, np.int8, np.uint8, np.uint16} * cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} */ __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_int32); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_int16); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_int8); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); __pyx_tuple__9 = PyTuple_Pack(1, __pyx_n_s_uint8); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); __pyx_tuple__10 = PyTuple_Pack(1, __pyx_n_s_uint16); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); /* "pyreadstat/_readstat_writer.pyx":38 * np.int32, np.int16, np.int8, np.uint8, np.uint16} * cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} * cdef set float_types = {float, np.dtype('int64'), np.dtype('uint64'), np.dtype('uint32'), np.dtype('float'), # <<<<<<<<<<<<<< * np.dtype('float32'), np.int64, np.uint64, np.uint32, pd.Int64Dtype(), pd.UInt32Dtype(), pd.UInt64Dtype(), * pd.Float64Dtype(), pd.Float32Dtype()} */ __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_int64); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); __pyx_tuple__12 = PyTuple_Pack(1, __pyx_n_s_uint64); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__12); __Pyx_GIVEREF(__pyx_tuple__12); __pyx_tuple__13 = PyTuple_Pack(1, __pyx_n_s_uint32); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); __pyx_tuple__14 = PyTuple_Pack(1, __pyx_n_s_float); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__14); __Pyx_GIVEREF(__pyx_tuple__14); /* "pyreadstat/_readstat_writer.pyx":39 * cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} * cdef set float_types = {float, np.dtype('int64'), np.dtype('uint64'), np.dtype('uint32'), np.dtype('float'), * np.dtype('float32'), np.int64, np.uint64, np.uint32, pd.Int64Dtype(), pd.UInt32Dtype(), pd.UInt64Dtype(), # <<<<<<<<<<<<<< * pd.Float64Dtype(), pd.Float32Dtype()} * cdef set numeric_types = int_types.union(float_types).union(int_mixed_types) */ __pyx_tuple__15 = PyTuple_Pack(1, __pyx_n_s_float32); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15); /* "pyreadstat/_readstat_writer.pyx":56 * cdef double spss_offset_days = 141428 * cdef double sas_offset_days = 3653 * cdef object date_0 = datetime.datetime(1970,1,1).date() # <<<<<<<<<<<<<< * * cdef valid_user_missing_sas = [chr(x) for x in range(ord("A"), ord("Z")+1)] + ["_"] */ __pyx_tuple__16 = PyTuple_Pack(3, __pyx_int_1970, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__16); __Pyx_GIVEREF(__pyx_tuple__16); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } /* #### Code section: init_constants ### */ static CYTHON_SMALL_CODE int __Pyx_InitConstants(void) { __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_get.method_name = &__pyx_n_s_get; __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_items.method_name = &__pyx_n_s_items; __pyx_umethod_PyDict_Type_keys.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_keys.method_name = &__pyx_n_s_keys; __pyx_umethod_PySet_Type_union.type = (PyObject*)&PySet_Type; __pyx_umethod_PySet_Type_union.method_name = &__pyx_n_s_union; __pyx_umethod_PyString_Type_encode.type = (PyObject*)&PyString_Type; __pyx_umethod_PyString_Type_encode.method_name = &__pyx_n_s_encode; if (__Pyx_CreateStringTabAndInitStrings() < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_float_1e6 = PyFloat_FromDouble(1e6); if (unlikely(!__pyx_float_1e6)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_float_1e9 = PyFloat_FromDouble(1e9); if (unlikely(!__pyx_float_1e9)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_65 = PyInt_FromLong(65); if (unlikely(!__pyx_int_65)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_97 = PyInt_FromLong(97); if (unlikely(!__pyx_int_97)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1970 = PyInt_FromLong(1970); if (unlikely(!__pyx_int_1970)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_neg_9223056417655 = PyInt_FromString((char *)"-9223056417655", 0, 0); if (unlikely(!__pyx_int_neg_9223056417655)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: init_globals ### */ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { return 0; } /* #### Code section: init_module ### */ static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ static int __Pyx_modinit_global_init_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __pyx_v_10pyreadstat_16_readstat_writer_int_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_int_mixed_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_float_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_numeric_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_datetime_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_nat_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_pyrwriter_datetimelike_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_pandas_to_readstat_types = ((PyObject*)Py_None); Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_date_0 = Py_None; Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_sas = Py_None; Py_INCREF(Py_None); __pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_stata = Py_None; Py_INCREF(Py_None); __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(void) { __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ if (__Pyx_ExportFunction("convert_datetimelike_to_number", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_convert_datetimelike_to_number, "double (__pyx_t_10pyreadstat_16_readstat_writer_dst_file_format, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("get_datetimelike_format_for_readstat", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_get_datetimelike_format_for_readstat, "char *(__pyx_t_10pyreadstat_16_readstat_writer_dst_file_format, __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("get_pandas_str_series_max_length", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_get_pandas_str_series_max_length, "int (PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("check_series_all_same_types", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_check_series_all_same_types, "int (PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("get_pandas_column_types", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_get_pandas_column_types, "PyObject *(PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("write_bytes", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_write_bytes, "Py_ssize_t (void const *, size_t, void *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("open_file", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_open_file, "int (PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("close_file", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_close_file, "int (int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ExportFunction("run_write", (void (*)(void))__pyx_f_10pyreadstat_16_readstat_writer_run_write, "int (PyObject *, PyObject *, __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format, PyObject *, PyObject *, int, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_type_init_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_import_code(void) { __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule("pyreadstat._readstat_parser"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_ptype_10pyreadstat_16_readstat_parser_data_container = __Pyx_ImportType_3_0_9(__pyx_t_1, "pyreadstat._readstat_parser", "data_container", sizeof(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container),__Pyx_ImportType_CheckSize_Warn_3_0_9); if (!__pyx_ptype_10pyreadstat_16_readstat_parser_data_container) __PYX_ERR(1, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_variable_import_code(void) { __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __pyx_t_1 = PyImport_ImportModule("pyreadstat._readstat_parser"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "readstat_to_numpy_types", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_readstat_to_numpy_types, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_date_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_datetime_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_time_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_all_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_origin", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_datetime_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_date_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_time_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_all_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_origin", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_datetime_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_date_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_time_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_all_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_origin", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_function_import_code(void) { __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __pyx_t_1 = PyImport_ImportModule("pyreadstat._readstat_parser"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_ImportFunction_3_0_9(__pyx_t_1, "check_exit_status", (void (**)(void))&__pyx_f_10pyreadstat_16_readstat_parser_check_exit_status, "void (readstat_error_t)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } #if PY_MAJOR_VERSION >= 3 #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec__readstat_writer(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec__readstat_writer}, {0, NULL} }; #endif #ifdef __cplusplus namespace { struct PyModuleDef __pyx_moduledef = #else static struct PyModuleDef __pyx_moduledef = #endif { PyModuleDef_HEAD_INIT, "_readstat_writer", 0, /* m_doc */ #if CYTHON_PEP489_MULTI_PHASE_INIT 0, /* m_size */ #elif CYTHON_USE_MODULE_STATE sizeof(__pyx_mstate), /* m_size */ #else -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif #if CYTHON_USE_MODULE_STATE __pyx_m_traverse, /* m_traverse */ __pyx_m_clear, /* m_clear */ NULL /* m_free */ #else NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ #endif }; #ifdef __cplusplus } /* anonymous namespace */ #endif #endif #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #elif PY_MAJOR_VERSION < 3 #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" void #else #define __Pyx_PyMODINIT_FUNC void #endif #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif #if PY_MAJOR_VERSION < 3 __Pyx_PyMODINIT_FUNC init_readstat_writer(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC init_readstat_writer(void) #else __Pyx_PyMODINIT_FUNC PyInit__readstat_writer(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit__readstat_writer(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { #if PY_VERSION_HEX >= 0x030700A1 static PY_INT64_T main_interpreter_id = -1; PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); if (main_interpreter_id == -1) { main_interpreter_id = current_id; return (unlikely(current_id == -1)) ? -1 : 0; } else if (unlikely(main_interpreter_id != current_id)) #else static PyInterpreterState *main_interpreter = NULL; PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; if (!main_interpreter) { main_interpreter = current_interpreter; } else if (unlikely(main_interpreter != current_interpreter)) #endif { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *module, const char* from_name, const char* to_name, int allow_none) #else static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) #endif { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { #if CYTHON_COMPILING_IN_LIMITED_API result = PyModule_AddObject(module, to_name, value); #else result = PyDict_SetItemString(moddict, to_name, value); #endif } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; CYTHON_UNUSED_VAR(def); if (__Pyx_check_single_interpreter()) return NULL; if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; #if CYTHON_COMPILING_IN_LIMITED_API moddict = module; #else moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; #endif if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec__readstat_writer(PyObject *__pyx_pyinit_module) #endif #endif { int stringtab_initialized = 0; #if CYTHON_USE_MODULE_STATE int pystate_addmodule_run = 0; #endif PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; PyObject *__pyx_t_14 = NULL; PyObject *__pyx_t_15 = NULL; Py_ssize_t __pyx_t_16; PyObject *(*__pyx_t_17)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module '_readstat_writer' has already been imported. Re-initialisation is not supported."); return -1; } #elif PY_MAJOR_VERSION >= 3 if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_m = __pyx_pyinit_module; Py_INCREF(__pyx_m); #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("_readstat_writer", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #elif CYTHON_USE_MODULE_STATE __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) { int add_module_result = PyState_AddModule(__pyx_t_1, &__pyx_moduledef); __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "_readstat_writer" pseudovariable */ if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) pystate_addmodule_run = 1; } #else __pyx_m = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #endif #endif CYTHON_UNUSED_VAR(__pyx_t_1); __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_cython_runtime = __Pyx_PyImport_AddModuleRef((const char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__readstat_writer(void)", 0); if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pxy_PyFrame_Initialize_Offsets __Pxy_PyFrame_Initialize_Offsets(); #endif __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_AsyncGen_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS PyEval_InitThreads(); #endif /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) stringtab_initialized = 1; if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_pyreadstat___readstat_writer) { if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "pyreadstat._readstat_writer")) { if (unlikely((PyDict_SetItemString(modules, "pyreadstat._readstat_writer", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(); (void)__Pyx_modinit_variable_export_code(); if (unlikely((__Pyx_modinit_function_export_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) (void)__Pyx_modinit_type_init_code(); if (unlikely((__Pyx_modinit_type_import_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_variable_import_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_function_import_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "pyreadstat/_readstat_writer.pyx":18 * # limitations under the License. * # ############################################################################# * import os # <<<<<<<<<<<<<< * import warnings * import sys */ __pyx_t_2 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_os, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":19 * # ############################################################################# * import os * import warnings # <<<<<<<<<<<<<< * import sys * */ __pyx_t_2 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_warnings, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":20 * import os * import warnings * import sys # <<<<<<<<<<<<<< * * import numpy as np */ __pyx_t_2 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_sys, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":22 * import sys * * import numpy as np # <<<<<<<<<<<<<< * #cimport numpy as np * import pandas as pd */ __pyx_t_2 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":24 * import numpy as np * #cimport numpy as np * import pandas as pd # <<<<<<<<<<<<<< * from pandas.api.types import is_datetime64_any_dtype, is_datetime64_ns_dtype * import datetime */ __pyx_t_2 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_pandas, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pd, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":25 * #cimport numpy as np * import pandas as pd * from pandas.api.types import is_datetime64_any_dtype, is_datetime64_ns_dtype # <<<<<<<<<<<<<< * import datetime * import calendar */ __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_is_datetime64_any_dtype); __Pyx_GIVEREF(__pyx_n_s_is_datetime64_any_dtype); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_is_datetime64_any_dtype)) __PYX_ERR(0, 25, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_is_datetime64_ns_dtype); __Pyx_GIVEREF(__pyx_n_s_is_datetime64_ns_dtype); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_is_datetime64_ns_dtype)) __PYX_ERR(0, 25, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_pandas_api_types, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_is_datetime64_any_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_datetime64_any_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_is_datetime64_ns_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_datetime64_ns_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":26 * import pandas as pd * from pandas.api.types import is_datetime64_any_dtype, is_datetime64_ns_dtype * import datetime # <<<<<<<<<<<<<< * import calendar * from datetime import timezone as _timezone */ __pyx_t_3 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_datetime, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_datetime, __pyx_t_3) < 0) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":27 * from pandas.api.types import is_datetime64_any_dtype, is_datetime64_ns_dtype * import datetime * import calendar # <<<<<<<<<<<<<< * from datetime import timezone as _timezone * from libc.math cimport round, NAN */ __pyx_t_3 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_calendar, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_calendar, __pyx_t_3) < 0) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":28 * import datetime * import calendar * from datetime import timezone as _timezone # <<<<<<<<<<<<<< * from libc.math cimport round, NAN * */ __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_timezone_2); __Pyx_GIVEREF(__pyx_n_s_timezone_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_timezone_2)) __PYX_ERR(0, 28, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_datetime, __pyx_t_3, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_timezone_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_timezone, __pyx_t_3) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":32 * * from readstat_api cimport * * from _readstat_parser import ReadstatError, PyreadstatError # <<<<<<<<<<<<<< * from _readstat_parser cimport check_exit_status * */ __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_ReadstatError); __Pyx_GIVEREF(__pyx_n_s_ReadstatError); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ReadstatError)) __PYX_ERR(0, 32, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_PyreadstatError); __Pyx_GIVEREF(__pyx_n_s_PyreadstatError); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_PyreadstatError)) __PYX_ERR(0, 32, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_readstat_parser, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_ReadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ReadstatError, __pyx_t_2) < 0) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_PyreadstatError, __pyx_t_2) < 0) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":35 * from _readstat_parser cimport check_exit_status * * cdef set int_types = {int, np.dtype('int32'), np.dtype('int16'), np.dtype('int8'), np.dtype('uint8'), np.dtype('uint16'), # <<<<<<<<<<<<<< * np.int32, np.int16, np.int8, np.uint8, np.uint16} * cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} */ __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dtype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dtype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* "pyreadstat/_readstat_writer.pyx":36 * * cdef set int_types = {int, np.dtype('int32'), np.dtype('int16'), np.dtype('int8'), np.dtype('uint8'), np.dtype('uint16'), * np.int32, np.int16, np.int8, np.uint8, np.uint16} # <<<<<<<<<<<<<< * cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} * cdef set float_types = {float, np.dtype('int64'), np.dtype('uint64'), np.dtype('uint32'), np.dtype('float'), */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_int32); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_int16); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_int8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PySet_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PySet_Add(__pyx_t_7, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 35, __pyx_L1_error) if (PySet_Add(__pyx_t_7, __pyx_t_3) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_2) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_4) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_5) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_6) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_8) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_9) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_10) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_11) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (PySet_Add(__pyx_t_7, __pyx_t_12) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_int_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_int_types, ((PyObject*)__pyx_t_7)); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = 0; /* "pyreadstat/_readstat_writer.pyx":37 * cdef set int_types = {int, np.dtype('int32'), np.dtype('int16'), np.dtype('int8'), np.dtype('uint8'), np.dtype('uint16'), * np.int32, np.int16, np.int8, np.uint8, np.uint16} * cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} # <<<<<<<<<<<<<< * cdef set float_types = {float, np.dtype('int64'), np.dtype('uint64'), np.dtype('uint32'), np.dtype('float'), * np.dtype('float32'), np.int64, np.uint64, np.uint32, pd.Int64Dtype(), pd.UInt32Dtype(), pd.UInt64Dtype(), */ __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_pd); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_Int8Dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_pd); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_Int16Dtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_pd); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_Int32Dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_pd); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_UInt8Dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_pd); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_UInt16Dtype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PySet_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PySet_Add(__pyx_t_8, __pyx_t_7) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PySet_Add(__pyx_t_8, __pyx_t_12) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (PySet_Add(__pyx_t_8, __pyx_t_11) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (PySet_Add(__pyx_t_8, __pyx_t_10) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (PySet_Add(__pyx_t_8, __pyx_t_9) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_int_mixed_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_int_mixed_types, ((PyObject*)__pyx_t_8)); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; /* "pyreadstat/_readstat_writer.pyx":38 * np.int32, np.int16, np.int8, np.uint8, np.uint16} * cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} * cdef set float_types = {float, np.dtype('int64'), np.dtype('uint64'), np.dtype('uint32'), np.dtype('float'), # <<<<<<<<<<<<<< * np.dtype('float32'), np.int64, np.uint64, np.uint32, pd.Int64Dtype(), pd.UInt32Dtype(), pd.UInt64Dtype(), * pd.Float64Dtype(), pd.Float32Dtype()} */ __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dtype); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dtype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dtype); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; /* "pyreadstat/_readstat_writer.pyx":39 * cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} * cdef set float_types = {float, np.dtype('int64'), np.dtype('uint64'), np.dtype('uint32'), np.dtype('float'), * np.dtype('float32'), np.int64, np.uint64, np.uint32, pd.Int64Dtype(), pd.UInt32Dtype(), pd.UInt64Dtype(), # <<<<<<<<<<<<<< * pd.Float64Dtype(), pd.Float32Dtype()} * cdef set numeric_types = int_types.union(float_types).union(int_mixed_types) */ __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dtype); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_int64); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_uint32); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_pd); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_Int64Dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_UInt32Dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_UInt64Dtype); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; /* "pyreadstat/_readstat_writer.pyx":40 * cdef set float_types = {float, np.dtype('int64'), np.dtype('uint64'), np.dtype('uint32'), np.dtype('float'), * np.dtype('float32'), np.int64, np.uint64, np.uint32, pd.Int64Dtype(), pd.UInt32Dtype(), pd.UInt64Dtype(), * pd.Float64Dtype(), pd.Float32Dtype()} # <<<<<<<<<<<<<< * cdef set numeric_types = int_types.union(float_types).union(int_mixed_types) * cdef set datetime_types = {datetime.datetime}#, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, pd.DatetimeTZDtype, 'datetime64[ns, UTC]'} */ __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_pd); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_Float64Dtype); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_CallNoArg(__pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_pd); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_Float32Dtype); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = PySet_New(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); if (PySet_Add(__pyx_t_15, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 38, __pyx_L1_error) if (PySet_Add(__pyx_t_15, __pyx_t_8) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_9) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_10) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_11) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_12) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_6) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_5) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_4) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_7) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_2) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_3) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_13) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (PySet_Add(__pyx_t_15, __pyx_t_14) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_float_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_float_types, ((PyObject*)__pyx_t_15)); __Pyx_GIVEREF(__pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/_readstat_writer.pyx":41 * np.dtype('float32'), np.int64, np.uint64, np.uint32, pd.Int64Dtype(), pd.UInt32Dtype(), pd.UInt64Dtype(), * pd.Float64Dtype(), pd.Float32Dtype()} * cdef set numeric_types = int_types.union(float_types).union(int_mixed_types) # <<<<<<<<<<<<<< * cdef set datetime_types = {datetime.datetime}#, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, pd.DatetimeTZDtype, 'datetime64[ns, UTC]'} * cdef set nat_types = {datetime.datetime, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, datetime.time, datetime.date} */ __pyx_t_15 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_union, __pyx_v_10pyreadstat_16_readstat_writer_int_types, __pyx_v_10pyreadstat_16_readstat_writer_float_types); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_union); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_v_10pyreadstat_16_readstat_writer_int_mixed_types); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (!(likely(PySet_CheckExact(__pyx_t_15))||((__pyx_t_15) == Py_None) || __Pyx_RaiseUnexpectedTypeError("set", __pyx_t_15))) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_numeric_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_numeric_types, ((PyObject*)__pyx_t_15)); __Pyx_GIVEREF(__pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/_readstat_writer.pyx":42 * pd.Float64Dtype(), pd.Float32Dtype()} * cdef set numeric_types = int_types.union(float_types).union(int_mixed_types) * cdef set datetime_types = {datetime.datetime}#, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, pd.DatetimeTZDtype, 'datetime64[ns, UTC]'} # <<<<<<<<<<<<<< * cdef set nat_types = {datetime.datetime, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, datetime.time, datetime.date} * cdef set pyrwriter_datetimelike_types = {PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US} */ __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_datetime); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = PySet_New(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); if (PySet_Add(__pyx_t_15, __pyx_t_14) < 0) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_datetime_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_datetime_types, ((PyObject*)__pyx_t_15)); __Pyx_GIVEREF(__pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/_readstat_writer.pyx":43 * cdef set numeric_types = int_types.union(float_types).union(int_mixed_types) * cdef set datetime_types = {datetime.datetime}#, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, pd.DatetimeTZDtype, 'datetime64[ns, UTC]'} * cdef set nat_types = {datetime.datetime, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, datetime.time, datetime.date} # <<<<<<<<<<<<<< * cdef set pyrwriter_datetimelike_types = {PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US} * cdef set pywriter_numeric_types = {PYWRITER_DOUBLE, PYWRITER_INTEGER, PYWRITER_LOGICAL, PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME} */ __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_datetime); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_datetime64); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_pd); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_libs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tslibs); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_timestamps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Timestamp); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_date); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PySet_Add(__pyx_t_3, __pyx_t_14) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (PySet_Add(__pyx_t_3, __pyx_t_13) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (PySet_Add(__pyx_t_3, __pyx_t_15) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (PySet_Add(__pyx_t_3, __pyx_t_2) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PySet_Add(__pyx_t_3, __pyx_t_7) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_nat_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_nat_types, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":44 * cdef set datetime_types = {datetime.datetime}#, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, pd.DatetimeTZDtype, 'datetime64[ns, UTC]'} * cdef set nat_types = {datetime.datetime, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, datetime.time, datetime.date} * cdef set pyrwriter_datetimelike_types = {PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US} # <<<<<<<<<<<<<< * cdef set pywriter_numeric_types = {PYWRITER_DOUBLE, PYWRITER_INTEGER, PYWRITER_LOGICAL, PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME} * cdef dict pandas_to_readstat_types = {PYWRITER_DOUBLE: READSTAT_TYPE_DOUBLE, PYWRITER_INTEGER: READSTAT_TYPE_INT32, */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_13 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = PySet_New(0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); if (PySet_Add(__pyx_t_14, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PySet_Add(__pyx_t_14, __pyx_t_7) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PySet_Add(__pyx_t_14, __pyx_t_2) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PySet_Add(__pyx_t_14, __pyx_t_15) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (PySet_Add(__pyx_t_14, __pyx_t_13) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_pyrwriter_datetimelike_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_pyrwriter_datetimelike_types, ((PyObject*)__pyx_t_14)); __Pyx_GIVEREF(__pyx_t_14); __pyx_t_14 = 0; /* "pyreadstat/_readstat_writer.pyx":45 * cdef set nat_types = {datetime.datetime, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, datetime.time, datetime.date} * cdef set pyrwriter_datetimelike_types = {PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US} * cdef set pywriter_numeric_types = {PYWRITER_DOUBLE, PYWRITER_INTEGER, PYWRITER_LOGICAL, PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME} # <<<<<<<<<<<<<< * cdef dict pandas_to_readstat_types = {PYWRITER_DOUBLE: READSTAT_TYPE_DOUBLE, PYWRITER_INTEGER: READSTAT_TYPE_INT32, * PYWRITER_CHARACTER: READSTAT_TYPE_STRING, PYWRITER_LOGICAL: READSTAT_TYPE_INT32, */ __pyx_t_14 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DOUBLE); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_INTEGER); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_15 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_LOGICAL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_2 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySet_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PySet_Add(__pyx_t_4, __pyx_t_14) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (PySet_Add(__pyx_t_4, __pyx_t_13) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (PySet_Add(__pyx_t_4, __pyx_t_15) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (PySet_Add(__pyx_t_4, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PySet_Add(__pyx_t_4, __pyx_t_7) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PySet_Add(__pyx_t_4, __pyx_t_3) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_pywriter_numeric_types, ((PyObject*)__pyx_t_4)); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":46 * cdef set pyrwriter_datetimelike_types = {PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US} * cdef set pywriter_numeric_types = {PYWRITER_DOUBLE, PYWRITER_INTEGER, PYWRITER_LOGICAL, PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME} * cdef dict pandas_to_readstat_types = {PYWRITER_DOUBLE: READSTAT_TYPE_DOUBLE, PYWRITER_INTEGER: READSTAT_TYPE_INT32, # <<<<<<<<<<<<<< * PYWRITER_CHARACTER: READSTAT_TYPE_STRING, PYWRITER_LOGICAL: READSTAT_TYPE_INT32, * PYWRITER_OBJECT: READSTAT_TYPE_STRING, PYWRITER_DATE: READSTAT_TYPE_DOUBLE, */ __pyx_t_4 = __Pyx_PyDict_NewPresized(10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_DOUBLE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_4, __pyx_t_3, __pyx_t_7) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_INTEGER); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_INT32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_4, __pyx_t_7, __pyx_t_3) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":47 * cdef set pywriter_numeric_types = {PYWRITER_DOUBLE, PYWRITER_INTEGER, PYWRITER_LOGICAL, PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME} * cdef dict pandas_to_readstat_types = {PYWRITER_DOUBLE: READSTAT_TYPE_DOUBLE, PYWRITER_INTEGER: READSTAT_TYPE_INT32, * PYWRITER_CHARACTER: READSTAT_TYPE_STRING, PYWRITER_LOGICAL: READSTAT_TYPE_INT32, # <<<<<<<<<<<<<< * PYWRITER_OBJECT: READSTAT_TYPE_STRING, PYWRITER_DATE: READSTAT_TYPE_DOUBLE, * PYWRITER_DATETIME: READSTAT_TYPE_DOUBLE, PYWRITER_TIME: READSTAT_TYPE_DOUBLE, */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_STRING); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_4, __pyx_t_3, __pyx_t_7) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_LOGICAL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_INT32); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_4, __pyx_t_7, __pyx_t_3) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":48 * cdef dict pandas_to_readstat_types = {PYWRITER_DOUBLE: READSTAT_TYPE_DOUBLE, PYWRITER_INTEGER: READSTAT_TYPE_INT32, * PYWRITER_CHARACTER: READSTAT_TYPE_STRING, PYWRITER_LOGICAL: READSTAT_TYPE_INT32, * PYWRITER_OBJECT: READSTAT_TYPE_STRING, PYWRITER_DATE: READSTAT_TYPE_DOUBLE, # <<<<<<<<<<<<<< * PYWRITER_DATETIME: READSTAT_TYPE_DOUBLE, PYWRITER_TIME: READSTAT_TYPE_DOUBLE, * PYWRITER_DATETIME64_NS: READSTAT_TYPE_DOUBLE, PYWRITER_DATETIME64_US: READSTAT_TYPE_DOUBLE} */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_STRING); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_4, __pyx_t_3, __pyx_t_7) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_4, __pyx_t_7, __pyx_t_3) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":49 * PYWRITER_CHARACTER: READSTAT_TYPE_STRING, PYWRITER_LOGICAL: READSTAT_TYPE_INT32, * PYWRITER_OBJECT: READSTAT_TYPE_STRING, PYWRITER_DATE: READSTAT_TYPE_DOUBLE, * PYWRITER_DATETIME: READSTAT_TYPE_DOUBLE, PYWRITER_TIME: READSTAT_TYPE_DOUBLE, # <<<<<<<<<<<<<< * PYWRITER_DATETIME64_NS: READSTAT_TYPE_DOUBLE, PYWRITER_DATETIME64_US: READSTAT_TYPE_DOUBLE} * */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_DOUBLE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_4, __pyx_t_3, __pyx_t_7) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_4, __pyx_t_7, __pyx_t_3) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/_readstat_writer.pyx":50 * PYWRITER_OBJECT: READSTAT_TYPE_STRING, PYWRITER_DATE: READSTAT_TYPE_DOUBLE, * PYWRITER_DATETIME: READSTAT_TYPE_DOUBLE, PYWRITER_TIME: READSTAT_TYPE_DOUBLE, * PYWRITER_DATETIME64_NS: READSTAT_TYPE_DOUBLE, PYWRITER_DATETIME64_US: READSTAT_TYPE_DOUBLE} # <<<<<<<<<<<<<< * * cdef double spss_offset_secs = 12219379200 */ __pyx_t_3 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_DOUBLE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_4, __pyx_t_3, __pyx_t_7) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyInt_From_readstat_type_t(READSTAT_TYPE_DOUBLE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_4, __pyx_t_7, __pyx_t_3) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_pandas_to_readstat_types); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_pandas_to_readstat_types, ((PyObject*)__pyx_t_4)); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":52 * PYWRITER_DATETIME64_NS: READSTAT_TYPE_DOUBLE, PYWRITER_DATETIME64_US: READSTAT_TYPE_DOUBLE} * * cdef double spss_offset_secs = 12219379200 # <<<<<<<<<<<<<< * cdef double sas_offset_secs = 315619200 * cdef double spss_offset_days = 141428 */ __pyx_v_10pyreadstat_16_readstat_writer_spss_offset_secs = 12219379200.0; /* "pyreadstat/_readstat_writer.pyx":53 * * cdef double spss_offset_secs = 12219379200 * cdef double sas_offset_secs = 315619200 # <<<<<<<<<<<<<< * cdef double spss_offset_days = 141428 * cdef double sas_offset_days = 3653 */ __pyx_v_10pyreadstat_16_readstat_writer_sas_offset_secs = 315619200.0; /* "pyreadstat/_readstat_writer.pyx":54 * cdef double spss_offset_secs = 12219379200 * cdef double sas_offset_secs = 315619200 * cdef double spss_offset_days = 141428 # <<<<<<<<<<<<<< * cdef double sas_offset_days = 3653 * cdef object date_0 = datetime.datetime(1970,1,1).date() */ __pyx_v_10pyreadstat_16_readstat_writer_spss_offset_days = 141428.0; /* "pyreadstat/_readstat_writer.pyx":55 * cdef double sas_offset_secs = 315619200 * cdef double spss_offset_days = 141428 * cdef double sas_offset_days = 3653 # <<<<<<<<<<<<<< * cdef object date_0 = datetime.datetime(1970,1,1).date() * */ __pyx_v_10pyreadstat_16_readstat_writer_sas_offset_days = 3653.0; /* "pyreadstat/_readstat_writer.pyx":56 * cdef double spss_offset_days = 141428 * cdef double sas_offset_days = 3653 * cdef object date_0 = datetime.datetime(1970,1,1).date() # <<<<<<<<<<<<<< * * cdef valid_user_missing_sas = [chr(x) for x in range(ord("A"), ord("Z")+1)] + ["_"] */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_date_0); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_date_0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/_readstat_writer.pyx":58 * cdef object date_0 = datetime.datetime(1970,1,1).date() * * cdef valid_user_missing_sas = [chr(x) for x in range(ord("A"), ord("Z")+1)] + ["_"] # <<<<<<<<<<<<<< * cdef valid_user_missing_stata = [chr(x) for x in range(ord("a"), ord("z")+1)] * */ __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyInt_From_long((90 + 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_int_65); __Pyx_GIVEREF(__pyx_int_65); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_65)) __PYX_ERR(0, 58, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_7 = __pyx_t_3; __Pyx_INCREF(__pyx_t_7); __pyx_t_16 = 0; __pyx_t_17 = NULL; } else { __pyx_t_16 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_17 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 58, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_17)) { if (likely(PyList_CheckExact(__pyx_t_7))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 58, __pyx_L1_error) #endif if (__pyx_t_16 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_16); __Pyx_INCREF(__pyx_t_3); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 58, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 58, __pyx_L1_error) #endif if (__pyx_t_16 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_16); __Pyx_INCREF(__pyx_t_3); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 58, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_17(__pyx_t_7); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 58, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } if (PyDict_SetItem(__pyx_d, __pyx_n_s_x, __pyx_t_3) < 0) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_x); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_n_s__17); __Pyx_GIVEREF(__pyx_n_s__17); if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_n_s__17)) __PYX_ERR(0, 58, __pyx_L1_error); __pyx_t_2 = PyNumber_Add(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_sas); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_sas, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":59 * * cdef valid_user_missing_sas = [chr(x) for x in range(ord("A"), ord("Z")+1)] + ["_"] * cdef valid_user_missing_stata = [chr(x) for x in range(ord("a"), ord("z")+1)] # <<<<<<<<<<<<<< * * */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyInt_From_long((0x7A + 1)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_int_97); __Pyx_GIVEREF(__pyx_int_97); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_97)) __PYX_ERR(0, 59, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) { __pyx_t_4 = __pyx_t_7; __Pyx_INCREF(__pyx_t_4); __pyx_t_16 = 0; __pyx_t_17 = NULL; } else { __pyx_t_16 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 59, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; for (;;) { if (likely(!__pyx_t_17)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 59, __pyx_L1_error) #endif if (__pyx_t_16 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_16); __Pyx_INCREF(__pyx_t_7); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 59, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 59, __pyx_L1_error) #endif if (__pyx_t_16 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_16); __Pyx_INCREF(__pyx_t_7); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 59, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_17(__pyx_t_4); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 59, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_7); } if (PyDict_SetItem(__pyx_d, __pyx_n_s_x, __pyx_t_7) < 0) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_x); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_chr, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XGOTREF(__pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_stata); __Pyx_DECREF_SET(__pyx_v_10pyreadstat_16_readstat_writer_valid_user_missing_stata, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/_readstat_writer.pyx":1 * # cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # <<<<<<<<<<<<<< * # ###cython: profile=True * # ############################################################################# */ __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); if (__pyx_m) { if (__pyx_d && stringtab_initialized) { __Pyx_AddTraceback("init pyreadstat._readstat_writer", __pyx_clineno, __pyx_lineno, __pyx_filename); } #if !CYTHON_USE_MODULE_STATE Py_CLEAR(__pyx_m); #else Py_DECREF(__pyx_m); if (pystate_addmodule_run) { PyObject *tp, *value, *tb; PyErr_Fetch(&tp, &value, &tb); PyState_RemoveModule(&__pyx_moduledef); PyErr_Restore(tp, value, tb); } #endif } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init pyreadstat._readstat_writer"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #elif PY_MAJOR_VERSION >= 3 return __pyx_m; #else return; #endif } /* #### Code section: cleanup_globals ### */ /* #### Code section: cleanup_module ### */ /* #### Code section: main_method ### */ /* #### Code section: utility_code_pragmas ### */ #ifdef _MSC_VER #pragma warning( push ) /* Warning 4127: conditional expression is constant * Cython uses constant conditional expressions to allow in inline functions to be optimized at * compile-time, so this warning is not useful */ #pragma warning( disable : 4127 ) #endif /* #### Code section: utility_code_def ### */ /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i= 0x030C00A6 PyObject *current_exception = tstate->current_exception; if (unlikely(!current_exception)) return 0; exc_type = (PyObject*) Py_TYPE(current_exception); if (exc_type == err) return 1; #else exc_type = tstate->curexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(exc_type); #endif if (unlikely(PyTuple_Check(err))) { result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); } else { result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(exc_type); #endif return result; } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject *tmp_value; assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); if (value) { #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) #endif PyException_SetTraceback(value, tb); } tmp_value = tstate->current_exception; tstate->current_exception = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject* exc_value; exc_value = tstate->current_exception; tstate->current_exception = 0; *value = exc_value; *type = NULL; *tb = NULL; if (exc_value) { *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); #if CYTHON_COMPILING_IN_CPYTHON *tb = ((PyBaseExceptionObject*) exc_value)->traceback; Py_XINCREF(*tb); #else *tb = PyException_GetTraceback(exc_value); #endif } #else *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif } #endif /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #endif /* PyObjectGetAttrStrNoError */ #if __PYX_LIMITED_VERSION_HEX < 0x030d00A1 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 (void) PyObject_GetOptionalAttr(obj, attr_name, &result); return result; #else #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); } #endif result = __Pyx_PyObject_GetAttrStr(obj, attr_name); if (unlikely(!result)) { __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; #endif } /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_b, name); if (unlikely(!result) && !PyErr_Occurred()) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } else if (unlikely(PyErr_Occurred())) { return NULL; } #elif CYTHON_COMPILING_IN_LIMITED_API if (unlikely(!__pyx_m)) { return NULL; } result = PyObject_GetAttr(__pyx_m, name); if (likely(result)) { return result; } #else result = PyDict_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } #endif #else result = PyObject_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = Py_TYPE(func)->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; #endif result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL && !CYTHON_VECTORCALL static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; assert(globals != NULL); /* XXX Perhaps we should create a specialized PyFrame_New() that doesn't take locals, but does take builtins without sanity checking them. */ assert(tstate != NULL); f = PyFrame_New(tstate, co, globals, NULL); if (f == NULL) { return NULL; } fastlocals = __Pyx_PyFrame_GetLocalsplus(f); for (i = 0; i < na; i++) { Py_INCREF(*args); fastlocals[i] = *args++; } result = PyEval_EvalFrameEx(f,0); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; return result; } static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); PyObject *closure; #if PY_MAJOR_VERSION >= 3 PyObject *kwdefs; #endif PyObject *kwtuple, **k; PyObject **d; Py_ssize_t nd; Py_ssize_t nk; PyObject *result; assert(kwargs == NULL || PyDict_Check(kwargs)); nk = kwargs ? PyDict_Size(kwargs) : 0; #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) { return NULL; } #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) { return NULL; } #endif if ( #if PY_MAJOR_VERSION >= 3 co->co_kwonlyargcount == 0 && #endif likely(kwargs == NULL || nk == 0) && co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { if (argdefs == NULL && co->co_argcount == nargs) { result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); goto done; } else if (nargs == 0 && argdefs != NULL && co->co_argcount == Py_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ args = &PyTuple_GET_ITEM(argdefs, 0); result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); goto done; } } if (kwargs != NULL) { Py_ssize_t pos, i; kwtuple = PyTuple_New(2 * nk); if (kwtuple == NULL) { result = NULL; goto done; } k = &PyTuple_GET_ITEM(kwtuple, 0); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { Py_INCREF(k[i]); Py_INCREF(k[i+1]); i += 2; } nk = i / 2; } else { kwtuple = NULL; k = NULL; } closure = PyFunction_GET_CLOSURE(func); #if PY_MAJOR_VERSION >= 3 kwdefs = PyFunction_GET_KW_DEFAULTS(func); #endif if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); nd = Py_SIZE(argdefs); } else { d = NULL; nd = 0; } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, closure); #endif Py_XDECREF(kwtuple); done: Py_LeaveRecursiveCall(); return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); self = __Pyx_CyOrPyCFunction_GET_SELF(func); #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; #endif result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectFastCall */ #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs) { PyObject *argstuple; PyObject *result = 0; size_t i; argstuple = PyTuple_New((Py_ssize_t)nargs); if (unlikely(!argstuple)) return NULL; for (i = 0; i < nargs; i++) { Py_INCREF(args[i]); if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) < 0) goto bad; } result = __Pyx_PyObject_Call(func, argstuple, kwargs); bad: Py_DECREF(argstuple); return result; } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t _nargs, PyObject *kwargs) { Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); #if CYTHON_COMPILING_IN_CPYTHON if (nargs == 0 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) return __Pyx_PyObject_CallMethO(func, NULL); } else if (nargs == 1 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) return __Pyx_PyObject_CallMethO(func, args[0]); } #endif #if PY_VERSION_HEX < 0x030800B1 #if CYTHON_FAST_PYCCALL if (PyCFunction_Check(func)) { if (kwargs) { return _PyCFunction_FastCallDict(func, args, nargs, kwargs); } else { return _PyCFunction_FastCallKeywords(func, args, nargs, NULL); } } #if PY_VERSION_HEX >= 0x030700A1 if (!kwargs && __Pyx_IS_TYPE(func, &PyMethodDescr_Type)) { return _PyMethodDescr_FastCallKeywords(func, args, nargs, NULL); } #endif #endif #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs); } #endif #endif if (kwargs == NULL) { #if CYTHON_VECTORCALL #if PY_VERSION_HEX < 0x03090000 vectorcallfunc f = _PyVectorcall_Function(func); #else vectorcallfunc f = PyVectorcall_Function(func); #endif if (f) { return f(func, args, (size_t)nargs, NULL); } #elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL if (__Pyx_CyFunction_CheckExact(func)) { __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func); if (f) return f(func, args, (size_t)nargs, NULL); } #endif } if (nargs == 0) { return __Pyx_PyObject_Call(func, __pyx_empty_tuple, kwargs); } #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); #else return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); #endif } /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API return PyObject_RichCompareBool(s1, s2, equals); #else #if PY_MAJOR_VERSION < 3 PyObject* owned_ref = NULL; #endif int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); #if PY_MAJOR_VERSION < 3 if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { owned_ref = PyUnicode_FromObject(s2); if (unlikely(!owned_ref)) return -1; s2 = owned_ref; s2_is_unicode = 1; } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { owned_ref = PyUnicode_FromObject(s1); if (unlikely(!owned_ref)) return -1; s1 = owned_ref; s1_is_unicode = 1; } else if (((!s2_is_unicode) & (!s1_is_unicode))) { return __Pyx_PyBytes_Equals(s1, s2, equals); } #endif if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length; int kind; void *data1, *data2; if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; length = __Pyx_PyUnicode_GET_LENGTH(s1); if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; #if CYTHON_PEP393_ENABLED hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; #else hash1 = ((PyUnicodeObject*)s1)->hash; hash2 = ((PyUnicodeObject*)s2)->hash; #endif if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ); return_ne: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_NE); #endif } /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { __Pyx_PyThreadState_declare CYTHON_UNUSED_VAR(cause); Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyException_SetTraceback(value, tb); #elif CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #else PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* RaiseUnexpectedTypeError */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj) { __Pyx_TypeName obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME, expected, obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); return 0; } /* UnpackUnboundCMethod */ static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) { PyObject *result; PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args)); if (unlikely(!selfless_args)) return NULL; result = PyObject_Call(method, selfless_args, kwargs); Py_DECREF(selfless_args); return result; } static PyMethodDef __Pyx_UnboundCMethod_Def = { "CythonUnboundCMethod", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall), METH_VARARGS | METH_KEYWORDS, NULL }; static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { PyObject *method; method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); if (unlikely(!method)) return -1; target->method = method; #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) #else if (likely(!__Pyx_CyOrPyCFunction_Check(method))) #endif { PyMethodDescrObject *descr = (PyMethodDescrObject*) method; target->func = descr->d_method->ml_meth; target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); } else #endif #if CYTHON_COMPILING_IN_PYPY #else if (PyCFunction_Check(method)) #endif { PyObject *self; int self_found; #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY self = PyObject_GetAttrString(method, "__self__"); if (!self) { PyErr_Clear(); } #else self = PyCFunction_GET_SELF(method); #endif self_found = (self && self != Py_None); #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY Py_XDECREF(self); #endif if (self_found) { PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); if (unlikely(!unbound_method)) return -1; Py_DECREF(method); target->method = unbound_method; } } return 0; } /* CallUnboundCMethod1 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) { if (likely(cfunc->func)) { int flag = cfunc->flag; if (flag == METH_O) { return (*(cfunc->func))(self, arg); } else if ((PY_VERSION_HEX >= 0x030600B1) && flag == METH_FASTCALL) { #if PY_VERSION_HEX >= 0x030700A0 return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1); #else return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); #endif } else if ((PY_VERSION_HEX >= 0x030700A0) && flag == (METH_FASTCALL | METH_KEYWORDS)) { return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); } } return __Pyx__CallUnboundCMethod1(cfunc, self, arg); } #endif static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){ PyObject *args, *result = NULL; if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { args = PyTuple_New(1); if (unlikely(!args)) goto bad; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); if (cfunc->flag & METH_KEYWORDS) result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL); else result = (*cfunc->func)(self, args); } else { args = PyTuple_New(2); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg); PyTuple_SET_ITEM(args, 1, arg); result = __Pyx_PyObject_Call(cfunc->method, args, NULL); } #else args = PyTuple_Pack(2, self, arg); if (unlikely(!args)) goto bad; result = __Pyx_PyObject_Call(cfunc->method, args, NULL); #endif bad: Py_XDECREF(args); return result; } /* CallUnboundCMethod0 */ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { PyObject *args, *result = NULL; if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_ASSUME_SAFE_MACROS args = PyTuple_New(1); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); #else args = PyTuple_Pack(1, self); if (unlikely(!args)) goto bad; #endif result = __Pyx_PyObject_Call(cfunc->method, args, NULL); Py_DECREF(args); bad: return result; } /* py_dict_keys */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_keys, d); else return PyDict_Keys(d); } /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* IterFinish */ static CYTHON_INLINE int __Pyx_IterFinish(void) { PyObject* exc_type; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign exc_type = __Pyx_PyErr_CurrentExceptionType(); if (unlikely(exc_type)) { if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) return -1; __Pyx_PyErr_Clear(); return 0; } return 0; } /* UnpackItemEndCheck */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } return __Pyx_IterFinish(); } /* PyIntBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) { CYTHON_MAYBE_UNUSED_VAR(intval); CYTHON_MAYBE_UNUSED_VAR(inplace); CYTHON_UNUSED_VAR(zerodivision_check); #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long x; long a = PyInt_AS_LONG(op1); x = (long)((unsigned long)a + (unsigned long)b); if (likely((x^a) >= 0 || (x^b) >= 0)) return PyInt_FromLong(x); return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; #ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; #endif if (unlikely(__Pyx_PyLong_IsZero(op1))) { return __Pyx_NewRef(op2); } if (likely(__Pyx_PyLong_IsCompact(op1))) { a = __Pyx_PyLong_CompactValue(op1); } else { const digit* digits = __Pyx_PyLong_Digits(op1); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(op1); switch (size) { case -2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } x = a + b; return PyLong_FromLong(x); #ifdef HAVE_LONG_LONG long_long: llx = lla + llb; return PyLong_FromLongLong(llx); #endif } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; #if CYTHON_COMPILING_IN_LIMITED_API double a = __pyx_PyFloat_AsDouble(op1); #else double a = PyFloat_AS_DOUBLE(op1); #endif double result; PyFPE_START_PROTECT("add", return NULL) result = ((double)a) + (double)b; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); } #endif /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (unlikely(!j)) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; if (mm && mm->mp_subscript) { PyObject *r, *key = PyInt_FromSsize_t(i); if (unlikely(!key)) return NULL; r = mm->mp_subscript(o, key); Py_DECREF(key); return r; } if (likely(sm && sm->sq_item)) { if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { Py_ssize_t l = sm->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return sm->sq_item(o, i); } } #else if (is_list || !PyMapping_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } /* PyObjectCallOneArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *args[2] = {NULL, arg}; return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* ObjectGetItem */ #if CYTHON_USE_TYPE_SLOTS static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) { PyObject *runerr = NULL; Py_ssize_t key_value; key_value = __Pyx_PyIndex_AsSsize_t(index); if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); } if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { __Pyx_TypeName index_type_name = __Pyx_PyType_GetName(Py_TYPE(index)); PyErr_Clear(); PyErr_Format(PyExc_IndexError, "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name); __Pyx_DECREF_TypeName(index_type_name); } return NULL; } static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) { __Pyx_TypeName obj_type_name; if (likely(PyType_Check(obj))) { PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, __pyx_n_s_class_getitem); if (!meth) { PyErr_Clear(); } else { PyObject *result = __Pyx_PyObject_CallOneArg(meth, key); Py_DECREF(meth); return result; } } obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); return NULL; } static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) { PyTypeObject *tp = Py_TYPE(obj); PyMappingMethods *mm = tp->tp_as_mapping; PySequenceMethods *sm = tp->tp_as_sequence; if (likely(mm && mm->mp_subscript)) { return mm->mp_subscript(obj, key); } if (likely(sm && sm->sq_item)) { return __Pyx_PyObject_GetIndex(obj, key); } return __Pyx_PyObject_GetItem_Slow(obj, key); } #endif /* CallUnboundCMethod2 */ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1 static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) { if (likely(cfunc->func)) { PyObject *args[2] = {arg1, arg2}; if (cfunc->flag == METH_FASTCALL) { #if PY_VERSION_HEX >= 0x030700A0 return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2); #else return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL); #endif } #if PY_VERSION_HEX >= 0x030700A0 if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL); #endif } return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2); } #endif static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){ PyObject *args, *result = NULL; if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { args = PyTuple_New(2); if (unlikely(!args)) goto bad; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); if (cfunc->flag & METH_KEYWORDS) result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL); else result = (*cfunc->func)(self, args); } else { args = PyTuple_New(3); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg1); PyTuple_SET_ITEM(args, 1, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 2, arg2); result = __Pyx_PyObject_Call(cfunc->method, args, NULL); } #else args = PyTuple_Pack(3, self, arg1, arg2); if (unlikely(!args)) goto bad; result = __Pyx_PyObject_Call(cfunc->method, args, NULL); #endif bad: Py_XDECREF(args); return result; } /* dict_getitem_default */ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { PyObject* value; #if PY_MAJOR_VERSION >= 3 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000) value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (unlikely(PyErr_Occurred())) return NULL; value = default_value; } Py_INCREF(value); if ((1)); #else if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) { value = PyDict_GetItem(d, key); if (unlikely(!value)) { value = default_value; } Py_INCREF(value); } #endif else { if (default_value == Py_None) value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key); else value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value); } return value; } /* pyfrozenset_new */ static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) { if (it) { PyObject* result; #if CYTHON_COMPILING_IN_PYPY PyObject* args; args = PyTuple_Pack(1, it); if (unlikely(!args)) return NULL; result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL); Py_DECREF(args); return result; #else if (PyFrozenSet_CheckExact(it)) { Py_INCREF(it); return it; } result = PyFrozenSet_New(it); if (unlikely(!result)) return NULL; if ((PY_VERSION_HEX >= 0x031000A1) || likely(PySet_GET_SIZE(result))) return result; Py_DECREF(result); #endif } #if CYTHON_USE_TYPE_SLOTS return PyFrozenSet_Type.tp_new(&PyFrozenSet_Type, __pyx_empty_tuple, NULL); #else return PyObject_Call((PyObject*)&PyFrozenSet_Type, __pyx_empty_tuple, NULL); #endif } /* PySetContains */ static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) { int result = -1; if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) { PyObject *tmpkey; PyErr_Clear(); tmpkey = __Pyx_PyFrozenSet_New(key); if (tmpkey != NULL) { result = PySet_Contains(set, tmpkey); Py_DECREF(tmpkey); } } return result; } static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) { int result = PySet_Contains(set, key); if (unlikely(result < 0)) { result = __Pyx_PySet_ContainsUnhashable(set, key); } return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* DictGetItem */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { if (unlikely(PyTuple_Check(key))) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) { PyErr_SetObject(PyExc_KeyError, args); Py_DECREF(args); } } else { PyErr_SetObject(PyExc_KeyError, key); } } return NULL; } Py_INCREF(value); return value; } #endif /* py_dict_items */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d); else return PyDict_Items(d); } /* UnicodeAsUCS4 */ static CYTHON_INLINE Py_UCS4 __Pyx_PyUnicode_AsPy_UCS4(PyObject* x) { Py_ssize_t length; #if CYTHON_PEP393_ENABLED length = PyUnicode_GET_LENGTH(x); if (likely(length == 1)) { return PyUnicode_READ_CHAR(x, 0); } #else length = PyUnicode_GET_SIZE(x); if (likely(length == 1)) { return PyUnicode_AS_UNICODE(x)[0]; } #if Py_UNICODE_SIZE == 2 else if (PyUnicode_GET_SIZE(x) == 2) { Py_UCS4 high_val = PyUnicode_AS_UNICODE(x)[0]; if (high_val >= 0xD800 && high_val <= 0xDBFF) { Py_UCS4 low_val = PyUnicode_AS_UNICODE(x)[1]; if (low_val >= 0xDC00 && low_val <= 0xDFFF) { return 0x10000 + (((high_val & ((1<<10)-1)) << 10) | (low_val & ((1<<10)-1))); } } } #endif #endif PyErr_Format(PyExc_ValueError, "only single character unicode strings can be converted to Py_UCS4, " "got length %" CYTHON_FORMAT_SSIZE_T "d", length); return (Py_UCS4)-1; } /* object_ord */ static long __Pyx__PyObject_Ord(PyObject* c) { Py_ssize_t size; if (PyBytes_Check(c)) { size = PyBytes_GET_SIZE(c); if (likely(size == 1)) { return (unsigned char) PyBytes_AS_STRING(c)[0]; } #if PY_MAJOR_VERSION < 3 } else if (PyUnicode_Check(c)) { return (long)__Pyx_PyUnicode_AsPy_UCS4(c); #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) } else if (PyByteArray_Check(c)) { size = PyByteArray_GET_SIZE(c); if (likely(size == 1)) { return (unsigned char) PyByteArray_AS_STRING(c)[0]; } #endif } else { __Pyx_TypeName c_type_name = __Pyx_PyType_GetName(Py_TYPE(c)); PyErr_Format(PyExc_TypeError, "ord() expected string of length 1, but " __Pyx_FMT_TYPENAME " found", c_type_name); __Pyx_DECREF_TypeName(c_type_name); return (long)(Py_UCS4)-1; } PyErr_Format(PyExc_TypeError, "ord() expected a character, but string of length %zd found", size); return (long)(Py_UCS4)-1; } /* PyIntCompare */ static CYTHON_INLINE int __Pyx_PyInt_BoolNeObjC(PyObject *op1, PyObject *op2, long intval, long inplace) { CYTHON_MAYBE_UNUSED_VAR(intval); CYTHON_UNUSED_VAR(inplace); if (op1 == op2) { return 0; } #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long a = PyInt_AS_LONG(op1); return (a != b); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { int unequal; unsigned long uintval; Py_ssize_t size = __Pyx_PyLong_DigitCount(op1); const digit* digits = __Pyx_PyLong_Digits(op1); if (intval == 0) { return (__Pyx_PyLong_IsZero(op1) != 1); } else if (intval < 0) { if (__Pyx_PyLong_IsNonNeg(op1)) return 1; intval = -intval; } else { if (__Pyx_PyLong_IsNeg(op1)) return 1; } uintval = (unsigned long) intval; #if PyLong_SHIFT * 4 < SIZEOF_LONG*8 if (uintval >> (PyLong_SHIFT * 4)) { unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); } else #endif #if PyLong_SHIFT * 3 < SIZEOF_LONG*8 if (uintval >> (PyLong_SHIFT * 3)) { unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); } else #endif #if PyLong_SHIFT * 2 < SIZEOF_LONG*8 if (uintval >> (PyLong_SHIFT * 2)) { unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); } else #endif #if PyLong_SHIFT * 1 < SIZEOF_LONG*8 if (uintval >> (PyLong_SHIFT * 1)) { unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); } else #endif unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK)); return (unequal != 0); } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; #if CYTHON_COMPILING_IN_LIMITED_API double a = __pyx_PyFloat_AsDouble(op1); #else double a = PyFloat_AS_DOUBLE(op1); #endif return ((double)a != (double)b); } return __Pyx_PyObject_IsTrueAndDecref( PyObject_RichCompare(op1, op2, Py_NE)); } /* WriteUnraisableException */ static void __Pyx_WriteUnraisable(const char *name, int clineno, int lineno, const char *filename, int full_traceback, int nogil) { PyObject *old_exc, *old_val, *old_tb; PyObject *ctx; __Pyx_PyThreadState_declare #ifdef WITH_THREAD PyGILState_STATE state; if (nogil) state = PyGILState_Ensure(); else state = (PyGILState_STATE)0; #endif CYTHON_UNUSED_VAR(clineno); CYTHON_UNUSED_VAR(lineno); CYTHON_UNUSED_VAR(filename); CYTHON_MAYBE_UNUSED_VAR(nogil); __Pyx_PyThreadState_assign __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); if (full_traceback) { Py_XINCREF(old_exc); Py_XINCREF(old_val); Py_XINCREF(old_tb); __Pyx_ErrRestore(old_exc, old_val, old_tb); PyErr_PrintEx(1); } #if PY_MAJOR_VERSION < 3 ctx = PyString_FromString(name); #else ctx = PyUnicode_FromString(name); #endif __Pyx_ErrRestore(old_exc, old_val, old_tb); if (!ctx) { PyErr_WriteUnraisable(Py_None); } else { PyErr_WriteUnraisable(ctx); Py_DECREF(ctx); } #ifdef WITH_THREAD if (nogil) PyGILState_Release(state); #endif } /* RaiseUnboundLocalError */ static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); } /* GetAttr */ static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { #if CYTHON_USE_TYPE_SLOTS #if PY_MAJOR_VERSION >= 3 if (likely(PyUnicode_Check(n))) #else if (likely(PyString_Check(n))) #endif return __Pyx_PyObject_GetAttrStr(o, n); #endif return PyObject_GetAttr(o, n); } /* HasAttr */ #if __PYX_LIMITED_VERSION_HEX < 0x030d00A1 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { PyObject *r; if (unlikely(!__Pyx_PyBaseString_Check(n))) { PyErr_SetString(PyExc_TypeError, "hasattr(): attribute name must be string"); return -1; } r = __Pyx_GetAttr(o, n); if (!r) { PyErr_Clear(); return 0; } else { Py_DECREF(r); return 1; } } #endif /* GetTopmostException */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate) { _PyErr_StackItem *exc_info = tstate->exc_info; while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) && exc_info->previous_item != NULL) { exc_info = exc_info->previous_item; } return exc_info; } #endif /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); PyObject *exc_value = exc_info->exc_value; if (exc_value == NULL || exc_value == Py_None) { *value = NULL; *type = NULL; *tb = NULL; } else { *value = exc_value; Py_INCREF(*value); *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); *tb = PyException_GetTraceback(exc_value); } #elif CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); *type = exc_info->exc_type; *value = exc_info->exc_value; *tb = exc_info->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #endif } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = tstate->exc_info; PyObject *tmp_value = exc_info->exc_value; exc_info->exc_value = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = type; exc_info->exc_value = value; exc_info->exc_traceback = tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } #endif /* GetException */ #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif { PyObject *local_type = NULL, *local_value, *local_tb = NULL; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; #if PY_VERSION_HEX >= 0x030C00A6 local_value = tstate->current_exception; tstate->current_exception = 0; if (likely(local_value)) { local_type = (PyObject*) Py_TYPE(local_value); Py_INCREF(local_type); local_tb = PyException_GetTraceback(local_value); } #else local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_FAST_THREAD_STATE && PY_VERSION_HEX >= 0x030C00A6 if (unlikely(tstate->current_exception)) #elif CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE #if CYTHON_USE_EXC_INFO_STACK { _PyErr_StackItem *exc_info = tstate->exc_info; #if PY_VERSION_HEX >= 0x030B00a4 tmp_value = exc_info->exc_value; exc_info->exc_value = local_value; tmp_type = NULL; tmp_tb = NULL; Py_XDECREF(local_type); Py_XDECREF(local_tb); #else tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = local_type; exc_info->exc_value = local_value; exc_info->exc_traceback = local_tb; #endif } #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } /* PyFloatBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyFloat_DivideObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) { const double b = floatval; double a, result; CYTHON_UNUSED_VAR(inplace); CYTHON_UNUSED_VAR(zerodivision_check); if (likely(PyFloat_CheckExact(op1))) { #if CYTHON_COMPILING_IN_LIMITED_API a = __pyx_PyFloat_AsDouble(op1); #else a = PyFloat_AS_DOUBLE(op1); #endif } else #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { a = (double) PyInt_AS_LONG(op1); } else #endif if (likely(PyLong_CheckExact(op1))) { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsZero(op1)) { a = 0.0; } else if (__Pyx_PyLong_IsCompact(op1)) { a = (double) __Pyx_PyLong_CompactValue(op1); } else { const digit* digits = __Pyx_PyLong_Digits(op1); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(op1); switch (size) { case -2: case 2: if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) { a = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { if (size == -2) a = -a; break; } } CYTHON_FALLTHROUGH; case -3: case 3: if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) { a = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { if (size == -3) a = -a; break; } } CYTHON_FALLTHROUGH; case -4: case 4: if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) { a = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) { if (size == -4) a = -a; break; } } CYTHON_FALLTHROUGH; default: #endif a = PyLong_AsDouble(op1); if (unlikely(a == -1.0 && PyErr_Occurred())) return NULL; #if CYTHON_USE_PYLONG_INTERNALS } } #endif } else { return (inplace ? __Pyx_PyNumber_InPlaceDivide(op1, op2) : __Pyx_PyNumber_Divide(op1, op2)); } PyFPE_START_PROTECT("divide", return NULL) result = a / b; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } #endif /* SwapException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = tstate->exc_info; tmp_value = exc_info->exc_value; exc_info->exc_value = *value; if (tmp_value == NULL || tmp_value == Py_None) { Py_XDECREF(tmp_value); tmp_value = NULL; tmp_type = NULL; tmp_tb = NULL; } else { tmp_type = (PyObject*) Py_TYPE(tmp_value); Py_INCREF(tmp_type); #if CYTHON_COMPILING_IN_CPYTHON tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback; Py_XINCREF(tmp_tb); #else tmp_tb = PyException_GetTraceback(tmp_value); #endif } #elif CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = *type; exc_info->exc_value = *value; exc_info->exc_traceback = *tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #endif /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType_3_0_9 #define __PYX_HAVE_RT_ImportType_3_0_9 static PyTypeObject *__Pyx_ImportType_3_0_9(PyObject *module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_9 check_size) { PyObject *result = 0; char warning[200]; Py_ssize_t basicsize; Py_ssize_t itemsize; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; PyObject *py_itemsize; #endif result = PyObject_GetAttrString(module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #if !CYTHON_COMPILING_IN_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; itemsize = ((PyTypeObject *)result)->tp_itemsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; py_itemsize = PyObject_GetAttrString(result, "__itemsize__"); if (!py_itemsize) goto bad; itemsize = PyLong_AsSsize_t(py_itemsize); Py_DECREF(py_itemsize); py_itemsize = 0; if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (itemsize) { if (size % alignment) { alignment = size % alignment; } if (itemsize < (Py_ssize_t)alignment) itemsize = (Py_ssize_t)alignment; } if ((size_t)(basicsize + itemsize) < size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize+itemsize); goto bad; } if (check_size == __Pyx_ImportType_CheckSize_Error_3_0_9 && ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd-%zd from PyObject", module_name, class_name, size, basicsize, basicsize+itemsize); goto bad; } else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_0_9 && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(result); return NULL; } #endif /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *module = 0; PyObject *empty_dict = 0; PyObject *empty_list = 0; #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (unlikely(!py_import)) goto bad; if (!from_list) { empty_list = PyList_New(0); if (unlikely(!empty_list)) goto bad; from_list = empty_list; } #endif empty_dict = PyDict_New(); if (unlikely(!empty_dict)) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.') != NULL) { module = PyImport_ImportModuleLevelObject( name, __pyx_d, empty_dict, from_list, 1); if (unlikely(!module)) { if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (unlikely(!py_level)) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, __pyx_d, empty_dict, from_list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, __pyx_d, empty_dict, from_list, level); #endif } } bad: Py_XDECREF(empty_dict); Py_XDECREF(empty_list); #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif return module; } /* ImportDottedModule */ #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx__ImportDottedModule_Error(PyObject *name, PyObject *parts_tuple, Py_ssize_t count) { PyObject *partial_name = NULL, *slice = NULL, *sep = NULL; if (unlikely(PyErr_Occurred())) { PyErr_Clear(); } if (likely(PyTuple_GET_SIZE(parts_tuple) == count)) { partial_name = name; } else { slice = PySequence_GetSlice(parts_tuple, 0, count); if (unlikely(!slice)) goto bad; sep = PyUnicode_FromStringAndSize(".", 1); if (unlikely(!sep)) goto bad; partial_name = PyUnicode_Join(sep, slice); } PyErr_Format( #if PY_MAJOR_VERSION < 3 PyExc_ImportError, "No module named '%s'", PyString_AS_STRING(partial_name)); #else #if PY_VERSION_HEX >= 0x030600B1 PyExc_ModuleNotFoundError, #else PyExc_ImportError, #endif "No module named '%U'", partial_name); #endif bad: Py_XDECREF(sep); Py_XDECREF(slice); Py_XDECREF(partial_name); return NULL; } #endif #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx__ImportDottedModule_Lookup(PyObject *name) { PyObject *imported_module; #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) return NULL; imported_module = __Pyx_PyDict_GetItemStr(modules, name); Py_XINCREF(imported_module); #else imported_module = PyImport_GetModule(name); #endif return imported_module; } #endif #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple) { Py_ssize_t i, nparts; nparts = PyTuple_GET_SIZE(parts_tuple); for (i=1; i < nparts && module; i++) { PyObject *part, *submodule; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS part = PyTuple_GET_ITEM(parts_tuple, i); #else part = PySequence_ITEM(parts_tuple, i); #endif submodule = __Pyx_PyObject_GetAttrStrNoError(module, part); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(part); #endif Py_DECREF(module); module = submodule; } if (unlikely(!module)) { return __Pyx__ImportDottedModule_Error(name, parts_tuple, i); } return module; } #endif static PyObject *__Pyx__ImportDottedModule(PyObject *name, PyObject *parts_tuple) { #if PY_MAJOR_VERSION < 3 PyObject *module, *from_list, *star = __pyx_n_s__4; CYTHON_UNUSED_VAR(parts_tuple); from_list = PyList_New(1); if (unlikely(!from_list)) return NULL; Py_INCREF(star); PyList_SET_ITEM(from_list, 0, star); module = __Pyx_Import(name, from_list, 0); Py_DECREF(from_list); return module; #else PyObject *imported_module; PyObject *module = __Pyx_Import(name, NULL, 0); if (!parts_tuple || unlikely(!module)) return module; imported_module = __Pyx__ImportDottedModule_Lookup(name); if (likely(imported_module)) { Py_DECREF(module); return imported_module; } PyErr_Clear(); return __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple); #endif } static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030400B1 PyObject *module = __Pyx__ImportDottedModule_Lookup(name); if (likely(module)) { PyObject *spec = __Pyx_PyObject_GetAttrStrNoError(module, __pyx_n_s_spec); if (likely(spec)) { PyObject *unsafe = __Pyx_PyObject_GetAttrStrNoError(spec, __pyx_n_s_initializing); if (likely(!unsafe || !__Pyx_PyObject_IsTrue(unsafe))) { Py_DECREF(spec); spec = NULL; } Py_XDECREF(unsafe); } if (likely(!spec)) { PyErr_Clear(); return module; } Py_DECREF(spec); Py_DECREF(module); } else if (PyErr_Occurred()) { PyErr_Clear(); } #endif return __Pyx__ImportDottedModule(name, parts_tuple); } /* ImportDottedModuleRelFirst */ static PyObject *__Pyx_ImportDottedModuleRelFirst(PyObject *name, PyObject *parts_tuple) { PyObject *module; PyObject *from_list = NULL; #if PY_MAJOR_VERSION < 3 PyObject *star = __pyx_n_s__4; from_list = PyList_New(1); if (unlikely(!from_list)) return NULL; Py_INCREF(star); PyList_SET_ITEM(from_list, 0, star); #endif module = __Pyx_Import(name, from_list, -1); Py_XDECREF(from_list); if (module) { #if PY_MAJOR_VERSION >= 3 if (parts_tuple) { module = __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple); } #endif return module; } if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) return NULL; PyErr_Clear(); return __Pyx_ImportDottedModule(name, parts_tuple); } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { const char* module_name_str = 0; PyObject* module_name = 0; PyObject* module_dot = 0; PyObject* full_name = 0; PyErr_Clear(); module_name_str = PyModule_GetName(module); if (unlikely(!module_name_str)) { goto modbad; } module_name = PyUnicode_FromString(module_name_str); if (unlikely(!module_name)) { goto modbad; } module_dot = PyUnicode_Concat(module_name, __pyx_kp_u__5); if (unlikely(!module_dot)) { goto modbad; } full_name = PyUnicode_Concat(module_dot, name); if (unlikely(!full_name)) { goto modbad; } #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) goto modbad; value = PyObject_GetItem(modules, full_name); } #else value = PyImport_GetModule(full_name); #endif modbad: Py_XDECREF(full_name); Py_XDECREF(module_dot); Py_XDECREF(module_name); } if (unlikely(!value)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } /* PyObjectCallNoArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { PyObject *arg[2] = {NULL, NULL}; return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* CLineInTraceback */ #ifndef CYTHON_CLINE_IN_TRACEBACK static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline; PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif CYTHON_MAYBE_UNUSED_VAR(tstate); if (unlikely(!__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, *cython_runtime_dict, __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) } else #endif { PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStrNoError(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { PyErr_Clear(); use_cline = NULL; } } if (!use_cline) { c_line = 0; (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ #if !CYTHON_COMPILING_IN_LIMITED_API static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #endif /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, PyObject *firstlineno, PyObject *name) { PyObject *replace = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; replace = PyObject_GetAttrString(code, "replace"); if (likely(replace)) { PyObject *result; result = PyObject_Call(replace, __pyx_empty_tuple, scratch_dict); Py_DECREF(replace); return result; } PyErr_Clear(); #if __PYX_LIMITED_VERSION_HEX < 0x030780000 { PyObject *compiled = NULL, *result = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "code", code))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "type", (PyObject*)(&PyType_Type)))) return NULL; compiled = Py_CompileString( "out = type(code)(\n" " code.co_argcount, code.co_kwonlyargcount, code.co_nlocals, code.co_stacksize,\n" " code.co_flags, code.co_code, code.co_consts, code.co_names,\n" " code.co_varnames, code.co_filename, co_name, co_firstlineno,\n" " code.co_lnotab)\n", "", Py_file_input); if (!compiled) return NULL; result = PyEval_EvalCode(compiled, scratch_dict, scratch_dict); Py_DECREF(compiled); if (!result) PyErr_Print(); Py_DECREF(result); result = PyDict_GetItemString(scratch_dict, "out"); if (result) Py_INCREF(result); return result; } #else return NULL; #endif } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; PyObject *replace = NULL, *getframe = NULL, *frame = NULL; PyObject *exc_type, *exc_value, *exc_traceback; int success = 0; if (c_line) { (void) __pyx_cfilenm; (void) __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); } PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); code_object = Py_CompileString("_getframe()", filename, Py_eval_input); if (unlikely(!code_object)) goto bad; py_py_line = PyLong_FromLong(py_line); if (unlikely(!py_py_line)) goto bad; py_funcname = PyUnicode_FromString(funcname); if (unlikely(!py_funcname)) goto bad; dict = PyDict_New(); if (unlikely(!dict)) goto bad; { PyObject *old_code_object = code_object; code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); Py_DECREF(old_code_object); } if (unlikely(!code_object)) goto bad; getframe = PySys_GetObject("_getframe"); if (unlikely(!getframe)) goto bad; if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; frame = PyEval_EvalCode(code_object, dict, dict); if (unlikely(!frame) || frame == Py_None) goto bad; success = 1; bad: PyErr_Restore(exc_type, exc_value, exc_traceback); Py_XDECREF(code_object); Py_XDECREF(py_py_line); Py_XDECREF(py_funcname); Py_XDECREF(dict); Py_XDECREF(replace); if (success) { PyTraceBack_Here( (struct _frame*)frame); } Py_XDECREF(frame); } #else static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = NULL; PyObject *py_funcname = NULL; #if PY_MAJOR_VERSION < 3 PyObject *py_srcfile = NULL; py_srcfile = PyString_FromString(filename); if (!py_srcfile) goto bad; #endif if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; funcname = PyUnicode_AsUTF8(py_funcname); if (!funcname) goto bad; #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); if (!py_funcname) goto bad; #endif } #if PY_MAJOR_VERSION < 3 py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); #else py_code = PyCode_NewEmpty(filename, funcname, py_line); #endif Py_XDECREF(py_funcname); return py_code; bad: Py_XDECREF(py_funcname); #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_srcfile); #endif return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) { /* If the code object creation fails, then we should clear the fetched exception references and propagate the new exception */ Py_XDECREF(ptype); Py_XDECREF(pvalue); Py_XDECREF(ptraceback); goto bad; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #endif /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type neg_one = (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) -1, const_zero = (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_readstat_type_t(readstat_type_t value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const readstat_type_t neg_one = (readstat_type_t) -1, const_zero = (readstat_type_t) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(readstat_type_t) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(readstat_type_t) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(readstat_type_t) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(readstat_type_t) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(readstat_type_t) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(readstat_type_t), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(readstat_type_t)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntFromPy */ static CYTHON_INLINE readstat_type_t __Pyx_PyInt_As_readstat_type_t(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const readstat_type_t neg_one = (readstat_type_t) -1, const_zero = (readstat_type_t) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(readstat_type_t) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(readstat_type_t, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (readstat_type_t) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(readstat_type_t) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) >= 2 * PyLong_SHIFT)) { return (readstat_type_t) (((((readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0])); } } break; case 3: if ((8 * sizeof(readstat_type_t) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) >= 3 * PyLong_SHIFT)) { return (readstat_type_t) (((((((readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0])); } } break; case 4: if ((8 * sizeof(readstat_type_t) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) >= 4 * PyLong_SHIFT)) { return (readstat_type_t) (((((((((readstat_type_t)digits[3]) << PyLong_SHIFT) | (readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (readstat_type_t) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(readstat_type_t) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(readstat_type_t, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(readstat_type_t) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(readstat_type_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(readstat_type_t) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 2 * PyLong_SHIFT)) { return (readstat_type_t) (((readstat_type_t)-1)*(((((readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case 2: if ((8 * sizeof(readstat_type_t) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 2 * PyLong_SHIFT)) { return (readstat_type_t) ((((((readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case -3: if ((8 * sizeof(readstat_type_t) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 3 * PyLong_SHIFT)) { return (readstat_type_t) (((readstat_type_t)-1)*(((((((readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case 3: if ((8 * sizeof(readstat_type_t) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 3 * PyLong_SHIFT)) { return (readstat_type_t) ((((((((readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case -4: if ((8 * sizeof(readstat_type_t) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 4 * PyLong_SHIFT)) { return (readstat_type_t) (((readstat_type_t)-1)*(((((((((readstat_type_t)digits[3]) << PyLong_SHIFT) | (readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; case 4: if ((8 * sizeof(readstat_type_t) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(readstat_type_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(readstat_type_t) - 1 > 4 * PyLong_SHIFT)) { return (readstat_type_t) ((((((((((readstat_type_t)digits[3]) << PyLong_SHIFT) | (readstat_type_t)digits[2]) << PyLong_SHIFT) | (readstat_type_t)digits[1]) << PyLong_SHIFT) | (readstat_type_t)digits[0]))); } } break; } } #endif if ((sizeof(readstat_type_t) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(readstat_type_t, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(readstat_type_t) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(readstat_type_t, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available, cannot convert large enums"); return (readstat_type_t) -1; } else { readstat_type_t val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (readstat_type_t) -1; val = __Pyx_PyInt_As_readstat_type_t(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to readstat_type_t"); return (readstat_type_t) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to readstat_type_t"); return (readstat_type_t) -1; } /* CIntFromPy */ static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(int32_t) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int32_t) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int32_t, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(int32_t) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) >= 2 * PyLong_SHIFT)) { return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); } } break; case 3: if ((8 * sizeof(int32_t) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) >= 3 * PyLong_SHIFT)) { return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); } } break; case 4: if ((8 * sizeof(int32_t) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) >= 4 * PyLong_SHIFT)) { return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int32_t) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(int32_t) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int32_t, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT)) { return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); } } break; case 2: if ((8 * sizeof(int32_t) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT)) { return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); } } break; case -3: if ((8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT)) { return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); } } break; case 3: if ((8 * sizeof(int32_t) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT)) { return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); } } break; case -4: if ((8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT)) { return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); } } break; case 4: if ((8 * sizeof(int32_t) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT)) { return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); } } break; } } #endif if ((sizeof(int32_t) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(int32_t) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int32_t, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { int32_t val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int ret = -1; #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; long idigit; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (unlikely(!PyLong_CheckExact(v))) { PyObject *tmp = v; v = PyNumber_Long(v); assert(PyLong_CheckExact(v)); Py_DECREF(tmp); if (unlikely(!v)) return (int32_t) -1; } #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(x) == 0) return (int32_t) 0; is_negative = Py_SIZE(x) < 0; #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int32_t) -1; is_negative = result == 1; } #endif if (is_unsigned && unlikely(is_negative)) { goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); if (unlikely(!stepval)) return (int32_t) -1; } else { stepval = __Pyx_NewRef(v); } val = (int32_t) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(int32_t) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; val |= ((int32_t) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(stepval) == 0) goto unpacking_done; #endif } idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(int32_t) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((int32_t) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 unpacking_done: #endif if (!is_unsigned) { if (unlikely(val & (((int32_t) 1) << (sizeof(int32_t) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif Py_DECREF(v); if (likely(!ret)) return val; } return (int32_t) -1; } } else { int32_t val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int32_t) -1; val = __Pyx_PyInt_As_int32_t(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int32_t"); return (int32_t) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int32_t"); return (int32_t) -1; } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(int) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(int) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } } #endif if ((sizeof(int) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int ret = -1; #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; long idigit; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (unlikely(!PyLong_CheckExact(v))) { PyObject *tmp = v; v = PyNumber_Long(v); assert(PyLong_CheckExact(v)); Py_DECREF(tmp); if (unlikely(!v)) return (int) -1; } #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(x) == 0) return (int) 0; is_negative = Py_SIZE(x) < 0; #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; is_negative = result == 1; } #endif if (is_unsigned && unlikely(is_negative)) { goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); if (unlikely(!stepval)) return (int) -1; } else { stepval = __Pyx_NewRef(v); } val = (int) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; val |= ((int) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(stepval) == 0) goto unpacking_done; #endif } idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((int) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 unpacking_done: #endif if (!is_unsigned) { if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif Py_DECREF(v); if (likely(!ret)) return val; } return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* CIntFromPy */ static CYTHON_INLINE __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type neg_one = (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) -1, const_zero = (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) >= 2 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) (((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0])); } } break; case 3: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) >= 3 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) (((((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0])); } } break; case 4: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) >= 4 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) (((((((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[3]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 2 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) (((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)-1)*(((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0]))); } } break; case 2: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 2 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) ((((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0]))); } } break; case -3: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 3 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) (((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)-1)*(((((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0]))); } } break; case 3: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 3 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) ((((((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0]))); } } break; case -4: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 4 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) (((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)-1)*(((((((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[3]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0]))); } } break; case 4: if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) - 1 > 4 * PyLong_SHIFT)) { return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) ((((((((((__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[3]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[2]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[1]) << PyLong_SHIFT) | (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type)digits[0]))); } } break; } } #endif if ((sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } PyErr_SetString(PyExc_RuntimeError, "_PyLong_AsByteArray() not available, cannot convert large enums"); return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) -1; } else { __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) -1; val = __Pyx_PyInt_As___pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type"); return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type"); return (__pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type) -1; } /* FormatTypeName */ #if CYTHON_COMPILING_IN_LIMITED_API static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp) { PyObject *name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_n_s_name_2); if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) { PyErr_Clear(); Py_XDECREF(name); name = __Pyx_NewRef(__pyx_n_s__18); } return name; } #endif /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(long) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(long) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } } #endif if ((sizeof(long) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int ret = -1; #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; long idigit; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (unlikely(!PyLong_CheckExact(v))) { PyObject *tmp = v; v = PyNumber_Long(v); assert(PyLong_CheckExact(v)); Py_DECREF(tmp); if (unlikely(!v)) return (long) -1; } #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(x) == 0) return (long) 0; is_negative = Py_SIZE(x) < 0; #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; is_negative = result == 1; } #endif if (is_unsigned && unlikely(is_negative)) { goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); if (unlikely(!stepval)) return (long) -1; } else { stepval = __Pyx_NewRef(v); } val = (long) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; val |= ((long) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(stepval) == 0) goto unpacking_done; #endif } idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((long) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 unpacking_done: #endif if (!is_unsigned) { if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif Py_DECREF(v); if (likely(!ret)) return val; } return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (cls == a || cls == b) return 1; mro = cls->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { PyObject *base = PyTuple_GET_ITEM(mro, i); if (base == (PyObject *)a || base == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); } #if PY_MAJOR_VERSION == 2 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { PyObject *exception, *value, *tb; int res; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&exception, &value, &tb); res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } if (!res) { res = PyObject_IsSubclass(err, exc_type2); if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } } __Pyx_ErrRestore(exception, value, tb); return res; } #else static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { if (exc_type1) { return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); } else { return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } } #endif static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i= 0x030B00A4 return Py_Version & ~0xFFUL; #else const char* rt_version = Py_GetVersion(); unsigned long version = 0; unsigned long factor = 0x01000000UL; unsigned int digit = 0; int i = 0; while (factor) { while ('0' <= rt_version[i] && rt_version[i] <= '9') { digit = digit * 10 + (unsigned int) (rt_version[i] - '0'); ++i; } version += factor * digit; if (rt_version[i] != '.') break; digit = 0; factor >>= 8; ++i; } return version; #endif } static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { const unsigned long MAJOR_MINOR = 0xFFFF0000UL; if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) return 0; if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) return 1; { char message[200]; PyOS_snprintf(message, sizeof(message), "compile time Python version %d.%d " "of module '%.100s' " "%s " "runtime version %d.%d", (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), __Pyx_MODULE_NAME, (allow_newer) ? "was newer than" : "does not match", (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) ); return PyErr_WarnEx(NULL, message, 1); } } /* FunctionExport */ static int __Pyx_ExportFunction(const char *name, void (*f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { void (*fp)(void); void *p; } tmp; d = PyObject_GetAttrString(__pyx_m, (char *)"__pyx_capi__"); if (!d) { PyErr_Clear(); d = PyDict_New(); if (!d) goto bad; Py_INCREF(d); if (PyModule_AddObject(__pyx_m, (char *)"__pyx_capi__", d) < 0) goto bad; } tmp.fp = f; cobj = PyCapsule_New(tmp.p, sig, 0); if (!cobj) goto bad; if (PyDict_SetItemString(d, name, cobj) < 0) goto bad; Py_DECREF(cobj); Py_DECREF(d); return 0; bad: Py_XDECREF(cobj); Py_XDECREF(d); return -1; } /* VoidPtrImport */ #ifndef __PYX_HAVE_RT_ImportVoidPtr_3_0_9 #define __PYX_HAVE_RT_ImportVoidPtr_3_0_9 static int __Pyx_ImportVoidPtr_3_0_9(PyObject *module, const char *name, void **p, const char *sig) { PyObject *d = 0; PyObject *cobj = 0; d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); if (!d) goto bad; cobj = PyDict_GetItemString(d, name); if (!cobj) { PyErr_Format(PyExc_ImportError, "%.200s does not export expected C variable %.200s", PyModule_GetName(module), name); goto bad; } if (!PyCapsule_IsValid(cobj, sig)) { PyErr_Format(PyExc_TypeError, "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj)); goto bad; } *p = PyCapsule_GetPointer(cobj, sig); if (!(*p)) goto bad; Py_DECREF(d); return 0; bad: Py_XDECREF(d); return -1; } #endif /* FunctionImport */ #ifndef __PYX_HAVE_RT_ImportFunction_3_0_9 #define __PYX_HAVE_RT_ImportFunction_3_0_9 static int __Pyx_ImportFunction_3_0_9(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { void (*fp)(void); void *p; } tmp; d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); if (!d) goto bad; cobj = PyDict_GetItemString(d, funcname); if (!cobj) { PyErr_Format(PyExc_ImportError, "%.200s does not export expected C function %.200s", PyModule_GetName(module), funcname); goto bad; } if (!PyCapsule_IsValid(cobj, sig)) { PyErr_Format(PyExc_TypeError, "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); goto bad; } tmp.p = PyCapsule_GetPointer(cobj, sig); *f = tmp.fp; if (!(*f)) goto bad; Py_DECREF(d); return 0; bad: Py_XDECREF(d); return -1; } #endif /* InitStrings */ #if PY_MAJOR_VERSION >= 3 static int __Pyx_InitString(__Pyx_StringTabEntry t, PyObject **str) { if (t.is_unicode | t.is_str) { if (t.intern) { *str = PyUnicode_InternFromString(t.s); } else if (t.encoding) { *str = PyUnicode_Decode(t.s, t.n - 1, t.encoding, NULL); } else { *str = PyUnicode_FromStringAndSize(t.s, t.n - 1); } } else { *str = PyBytes_FromStringAndSize(t.s, t.n - 1); } if (!*str) return -1; if (PyObject_Hash(*str) == -1) return -1; return 0; } #endif static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION >= 3 __Pyx_InitString(*t, t->p); #else if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) return -1; #endif ++t; } return 0; } #include static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { size_t len = strlen(s); if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "byte string is too long"); return -1; } return (Py_ssize_t) len; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return __Pyx_PyUnicode_FromStringAndSize(c_str, len); } static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return PyByteArray_FromStringAndSize(c_str, len); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #if !CYTHON_PEP393_ENABLED static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; } #else static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif } #endif #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_LIMITED_API) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { __Pyx_TypeName result_type_name = __Pyx_PyType_GetName(Py_TYPE(result)); #if PY_MAJOR_VERSION >= 3 if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " "The ability to return an instance of a strict subclass of int is deprecated, " "and may be removed in a future version of Python.", result_type_name)) { __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } __Pyx_DECREF_TypeName(result_type_name); return result; } #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type " __Pyx_FMT_TYPENAME ")", type_name, type_name, result_type_name); __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x) || PyLong_Check(x))) #else if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; res = m->nb_long(x); } #else if (likely(m && m->nb_int)) { name = "int"; res = m->nb_int(x); } #endif #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Int(x); } #endif if (likely(res)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else if (unlikely(!PyLong_CheckExact(res))) { #endif return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(b); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS if (likely(__Pyx_PyLong_IsCompact(b))) { return __Pyx_PyLong_CompactValue(b); } else { const digit* digits = __Pyx_PyLong_Digits(b); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); #if PY_MAJOR_VERSION < 3 } else if (likely(PyInt_CheckExact(o))) { return PyInt_AS_LONG(o); #endif } else { Py_ssize_t ival; PyObject *x; x = PyNumber_Index(o); if (!x) return -1; ival = PyInt_AsLong(x); Py_DECREF(x); return ival; } } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } /* #### Code section: utility_code_pragmas_end ### */ #ifdef _MSC_VER #pragma warning( pop ) #endif /* #### Code section: end ### */ #endif /* Py_PYTHON_H */ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/pyreadstat/_readstat_writer.pxd0000644023477200000240000000655114574360757022073 0ustar00fajardoostaffs# cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# from libc.stddef cimport wchar_t from readstat_api cimport * #cdef int write_test() cdef extern from "readstat_io_unistd.h": cdef struct unistd_io_ctx_t "unistd_io_ctx_s": pass cdef extern from "conditional_includes.h": int _wsopen(const wchar_t *filename, int oflag, int shflag, int pmode) int O_RDONLY int O_BINARY int O_WRONLY int O_CREAT int O_TRUNC int _O_RDONLY int _O_BINARY int _O_WRONLY int _O_CREAT int _O_TRUNC int _SH_DENYRW # Denies read and write access to a file. int _SH_DENYWR # Denies write access to a file. int _SH_DENYRD # Denies read access to a file. int _SH_DENYNO int _S_IWRITE int _S_IREAD int open(const char *path, int oflag, int mode) int _close(int fd) cdef extern from "Python.h": wchar_t* PyUnicode_AsWideCharString(object, Py_ssize_t *) except NULL cdef extern from "conditional_includes.h": int _close(int fd) ssize_t _write(int fd, const void *buf, size_t nbyte) int close(int fd) ssize_t write(int fd, const void *buf, size_t nbyte) ctypedef enum dst_file_format: FILE_FORMAT_SAS7BDAT FILE_FORMAT_SAS7BCAT FILE_FORMAT_XPORT FILE_FORMAT_SAV FILE_FORMAT_DTA FILE_FORMAT_POR ctypedef enum pywriter_variable_type: PYWRITER_DOUBLE PYWRITER_INTEGER PYWRITER_CHARACTER PYWRITER_LOGICAL PYWRITER_OBJECT PYWRITER_DATE PYWRITER_DATETIME PYWRITER_TIME PYWRITER_DATETIME64_NS PYWRITER_DATETIME64_US cdef double convert_datetimelike_to_number(dst_file_format file_format, pywriter_variable_type curtype, object curval) except * cdef char * get_datetimelike_format_for_readstat(dst_file_format file_format, pywriter_variable_type curtype) cdef int get_pandas_str_series_max_length(object series, dict value_labels) cdef int check_series_all_same_types(object series, object type_to_check) cdef list get_pandas_column_types(object df, dict missing_user_values, dict variable_value_labels) cdef ssize_t write_bytes(const void *data, size_t _len, void *ctx) #cdef void check_exit_status(readstat_error_t retcode) except * cdef int open_file(bytes filename_path) cdef int close_file(int fd) cdef int run_write(df, object filename_path, dst_file_format file_format, str file_label, object column_labels, int file_format_version, str note, str table_name, dict variable_value_labels, dict missing_ranges, dict missing_user_values, dict variable_alignment, dict variable_display_width, dict variable_measure, dict variable_format, bint row_compression) except * ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350845.0 pyreadstat-1.2.7/pyreadstat/_readstat_writer.pyx0000644023477200000240000011461114574360775022115 0ustar00fajardoostaffs# cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # ###cython: profile=True # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# import os import warnings import sys import numpy as np #cimport numpy as np import pandas as pd from pandas.api.types import is_datetime64_any_dtype, is_datetime64_ns_dtype import datetime import calendar from datetime import timezone as _timezone from libc.math cimport round, NAN from readstat_api cimport * from _readstat_parser import ReadstatError, PyreadstatError from _readstat_parser cimport check_exit_status cdef set int_types = {int, np.dtype('int32'), np.dtype('int16'), np.dtype('int8'), np.dtype('uint8'), np.dtype('uint16'), np.int32, np.int16, np.int8, np.uint8, np.uint16} cdef set int_mixed_types = {pd.Int8Dtype(), pd.Int16Dtype(), pd.Int32Dtype(), pd.UInt8Dtype(), pd.UInt16Dtype()} cdef set float_types = {float, np.dtype('int64'), np.dtype('uint64'), np.dtype('uint32'), np.dtype('float'), np.dtype('float32'), np.int64, np.uint64, np.uint32, pd.Int64Dtype(), pd.UInt32Dtype(), pd.UInt64Dtype(), pd.Float64Dtype(), pd.Float32Dtype()} cdef set numeric_types = int_types.union(float_types).union(int_mixed_types) cdef set datetime_types = {datetime.datetime}#, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, pd.DatetimeTZDtype, 'datetime64[ns, UTC]'} cdef set nat_types = {datetime.datetime, np.datetime64, pd._libs.tslibs.timestamps.Timestamp, datetime.time, datetime.date} cdef set pyrwriter_datetimelike_types = {PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME, PYWRITER_DATETIME64_NS, PYWRITER_DATETIME64_US} cdef set pywriter_numeric_types = {PYWRITER_DOUBLE, PYWRITER_INTEGER, PYWRITER_LOGICAL, PYWRITER_DATE, PYWRITER_DATETIME, PYWRITER_TIME} cdef dict pandas_to_readstat_types = {PYWRITER_DOUBLE: READSTAT_TYPE_DOUBLE, PYWRITER_INTEGER: READSTAT_TYPE_INT32, PYWRITER_CHARACTER: READSTAT_TYPE_STRING, PYWRITER_LOGICAL: READSTAT_TYPE_INT32, PYWRITER_OBJECT: READSTAT_TYPE_STRING, PYWRITER_DATE: READSTAT_TYPE_DOUBLE, PYWRITER_DATETIME: READSTAT_TYPE_DOUBLE, PYWRITER_TIME: READSTAT_TYPE_DOUBLE, PYWRITER_DATETIME64_NS: READSTAT_TYPE_DOUBLE, PYWRITER_DATETIME64_US: READSTAT_TYPE_DOUBLE} cdef double spss_offset_secs = 12219379200 cdef double sas_offset_secs = 315619200 cdef double spss_offset_days = 141428 cdef double sas_offset_days = 3653 cdef object date_0 = datetime.datetime(1970,1,1).date() cdef valid_user_missing_sas = [chr(x) for x in range(ord("A"), ord("Z")+1)] + ["_"] cdef valid_user_missing_stata = [chr(x) for x in range(ord("a"), ord("z")+1)] cdef double convert_datetimelike_to_number(dst_file_format file_format, pywriter_variable_type curtype, object curval) except *: """ converts a datime like python/pandas object to a float """ cdef double offset_days, tstamp if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: offset_days = spss_offset_days offset_secs = spss_offset_secs else: offset_days = sas_offset_days offset_secs = sas_offset_secs if curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS: # get timestamp in seconds if type(curval) == pd._libs.tslibs.timestamps.Timestamp: curval = curval.asm8 if type(curval) == datetime.datetime: #tstamp = curval.replace(tzinfo=timezone.utc).timestamp() # works only in python 3 tstamp = calendar.timegm(curval.replace(tzinfo=_timezone.utc).timetuple()) elif type(curval) == np.datetime64: if curval.dtype.name == "datetime64[ns]": tstamp = round(curval.astype(float)/1e9) elif curval.dtype.name == "datetime64[us]": tstamp = round(curval.astype(float)/1e6) elif curval.dtype.name == "datetime64[ms]": tstamp = round(curval.astype(float)/1e3) tstamp += offset_secs if file_format == FILE_FORMAT_DTA: # stata stores in milliseconds tstamp *= 1000 elif curtype == PYWRITER_DATE: if type(curval) == datetime.date: days = curval - date_0 tstamp = days.days tstamp += offset_days if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: # spss stores in seconds tstamp *= 86400 elif curtype == PYWRITER_TIME: if type(curval) == datetime.time: tdelta = datetime.datetime.combine(datetime.date.min, curval) - datetime.datetime.min tstamp = tdelta.total_seconds() #tstamp += offset * 86400 if file_format == FILE_FORMAT_DTA: # stata stores in milliseconds tstamp *= 1000 return tstamp cdef char * get_datetimelike_format_for_readstat(dst_file_format file_format, pywriter_variable_type curtype): """ gives back a string with the format of the variable (according to the final application) to be used by readstat """ if curtype == PYWRITER_DATE: if file_format == FILE_FORMAT_DTA: return "%td" #elif file_format == FILE_FORMAT_SAV: # return "DATE11" else: return "DATE" elif curtype == PYWRITER_DATETIME or curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: if file_format == FILE_FORMAT_DTA: return "%tc" #elif file_format == FILE_FORMAT_SAV: # return "DATETIME20" else: return "DATETIME" elif curtype == PYWRITER_TIME: if file_format == FILE_FORMAT_DTA: return "%tcHH:MM:SS" else: return "TIME" else: raise PyreadstatError("Unknown pywriter variable format") cdef int get_pandas_str_series_max_length(object series, dict value_labels): """ For a pandas string series get the max length of the strings. Assumes there is no NaN among the elements. """ values = series.values cdef str val cdef bytes temp cdef int max_length = 1 cdef int curlen cdef list labels for val in values: temp = val.encode("utf-8") curlen = len(temp) if curlen > max_length: max_length = curlen if value_labels: labels = list(value_labels.keys()) for lab in labels: curlen = len(str(lab)) if curlen > max_length: max_length = curlen return max_length cdef int check_series_all_same_types(object series, object type_to_check): """ 1 if all elements in a series are of type type_to_check, 0 otherwise """ values = series.values for val in values: if type(val) != type_to_check: return 0 return 1 cdef list get_pandas_column_types(object df, dict missing_user_values, dict variable_value_labels): """ From a pandas data frame, get a list with tuples column types as first element, max_length as second and is_missing as third. max_lenght is the max length of a string or string representation of an object, 0 for numeric types. is_missing flags wether the series has missing values (1) or not (0) """ cdef int max_length cdef list types = df.dtypes.values.tolist() cdef list columns = df.columns.values.tolist() cdef list result = list() cdef int equal, is_missing if variable_value_labels is None: variable_value_labels = dict() for indx, (col_name, col_type) in enumerate(zip(columns, types)): max_length = 0 curseries = df.iloc[:, indx] curuser_missing = None if missing_user_values: curuser_missing = missing_user_values.get(col_name) # recover original type for categories if type(col_type) is pd.core.dtypes.dtypes.CategoricalDtype: col_type = np.asarray(curseries).dtype if col_type in int_types: result.append((PYWRITER_INTEGER, 0,0)) elif col_type in float_types: if np.any(pd.isna(curseries)): result.append((PYWRITER_DOUBLE, 0, 1)) else: result.append((PYWRITER_DOUBLE, 0, 0)) elif col_type == bool: result.append((PYWRITER_LOGICAL, 0,0)) # np.datetime64[ns] elif is_datetime64_ns_dtype(df[col_name]): if np.any(pd.isna(curseries)): result.append((PYWRITER_DATETIME64_NS, 0,1)) else: result.append((PYWRITER_DATETIME64_NS, 0,0)) elif col_type == np.dtype(' 8: msg = "missing_ranges: string values length must not be larger than 8" raise PyreadstatError(msg) check_exit_status(readstat_variable_add_missing_string_value(variable, hi))#.encode("utf-8"))) discrete_strings += 1 else: #check_exit_status(readstat_variable_add_missing_string_range(variable, lo, hi)) msg = "missing_ranges: hi and lo values must be both the same for string type" raise PyreadstatError(msg) else: msg = "missing_ranges: hi and lo values must be both either of numeric or string type" raise PyreadstatError(msg) else: if type(cur_range) in numeric_types: if vartype not in pywriter_numeric_types: msg = "numeric missing_ranges value given for non numeric variable %s" %variablename raise PyreadstatError(msg) check_exit_status(readstat_variable_add_missing_double_value(variable, cur_range)) discrete_values += 1 elif type(cur_range) == str: if vartype != PYWRITER_CHARACTER and vartype != PYWRITER_OBJECT: msg = "character missing_ranges value given for non character variable %s" %variablename raise PyreadstatError(msg) if len(cur_range) > 8: msg = "missing_ranges: string values length must not be larger than 8" raise PyreadstatError(msg) check_exit_status(readstat_variable_add_missing_string_value(variable, cur_range))#.encode("utf-8"))) discrete_strings += 1 else: msg = "missing_ranges: values must be both either of numeric or string type" raise PyreadstatError(msg) if discrete_strings > 3: msg = "missing_ranges: max 3 string values per variable allowed" raise PyreadstatError(msg) if range_values: if range_values > 1: msg = "missing_ranges: max 1 range value per variable allowed" raise PyreadstatError(msg) if discrete_values > 1: msg = "missing_ranges: max 1 discrete numeric value if combined with 1 range value per variable allowed" raise PyreadstatError(msg) if discrete_values >3: msg = "missing_ranges: max 3 discrete numeric values per variable allowed" raise PyreadstatError(msg) cdef void set_variable_alignment(readstat_variable_t *variable, str alignment_str, str var_name) except *: """ Sets the variable alignment, ineffective on SPSS, STATA and XPORT (what about SAS7bdat?) """ cdef readstat_alignment_t alignment if alignment_str == "right": alignment = READSTAT_ALIGNMENT_RIGHT elif alignment_str == "left": alignment = READSTAT_ALIGNMENT_LEFT elif alignment_str == "center": alignment = READSTAT_ALIGNMENT_CENTER elif alignment_str == "unknown": alignment = READSTAT_ALIGNMENT_UNKNOWN else: msg = "alignment for variable %s must be either right, center, left or unknown got %s instead" % (var_name, alignment_str) raise PyreadstatError(msg) readstat_variable_set_alignment(variable, alignment) cdef void set_variable_display_width(readstat_variable_t *variable, int display_width, str var_name) except *: """ Sets the variable display width (SPSS). Not effective on STATA. (what about SAS7BDAT?) """ readstat_variable_set_display_width(variable, display_width) cdef void set_variable_measure(readstat_variable_t *variable, str measure_str, str var_name) except *: """ sets the variable measure type (SPSS). Not effective on STATA. """ cdef readstat_measure_t measure if measure_str == "nominal": measure = READSTAT_MEASURE_NOMINAL elif measure_str == "ordinal": measure = READSTAT_MEASURE_ORDINAL elif measure_str == "scale": measure = READSTAT_MEASURE_SCALE elif measure_str == "unknown": measure = READSTAT_MEASURE_UNKNOWN else: msg = "measure for variable %s must be either nominal, ordinal, scale or unknown got %s instead" % (var_name, measure_str) raise PyreadstatError(msg) readstat_variable_set_measure(variable, measure); cdef ssize_t write_bytes(const void *data, size_t _len, void *ctx) noexcept: """ for the writer an explicit function to write must be defined """ cdef int fd fd = (ctx)[0] if os.name=='nt': return _write(fd, data, _len) else: return write(fd, data, _len) cdef void _check_exit_status(readstat_error_t retcode) except *: """ transforms a readstat exit status to a python error if status is not READSTAT OK """ cdef char * err_readstat cdef str err_message if retcode != READSTAT_OK: err_readstat = readstat_error_message(retcode) err_message = err_readstat raise ReadstatError(err_message) cdef int open_file(bytes filename_path): cdef int fd cdef int flags cdef Py_ssize_t length cdef bytes filename_bytes cdef char *path if os.name == "nt": filename_str = os.fsdecode(filename_path) u16_path = PyUnicode_AsWideCharString(filename_str, &length) flags = _O_WRONLY | _O_CREAT | _O_BINARY | _O_TRUNC fd = _wsopen(u16_path, flags, _SH_DENYRW, _S_IREAD | _S_IWRITE) else: #filename_bytes = filename_path.encode("utf-8") path = filename_path flags = O_WRONLY | O_CREAT | O_TRUNC fd = open(path, flags, 0644) return fd cdef int close_file(int fd): if os.name == "nt": return _close(fd) else: return close(fd) cdef int run_write(df, object filename_path, dst_file_format file_format, str file_label, object column_labels, int file_format_version, str note, str table_name, dict variable_value_labels, dict missing_ranges, dict missing_user_values, dict variable_alignment, dict variable_display_width, dict variable_measure, dict variable_format, bint row_compression) except *: """ main entry point for writing all formats. Some parameters are specific for certain file type and are even incompatible between them. This function relies on the caller to select the right combination of parameters, not checking them otherwise. """ if not isinstance(df, pd.DataFrame): raise PyreadstatError("first argument must be a pandas data frame") if variable_value_labels: for k,v in variable_value_labels.items(): if type(v) != dict: msg = "variable_value_labels: value for key %s must be dict, got %s" % (k, str(type(v))) raise PyreadstatError(msg) if missing_user_values: if file_format == FILE_FORMAT_DTA: valid_user_missing = valid_user_missing_stata elif file_format == FILE_FORMAT_SAS7BDAT or file_format == FILE_FORMAT_SAS7BCAT: valid_user_missing = valid_user_missing_sas for key, missing_values in missing_user_values.items(): if not isinstance(missing_values, list): msg = "missing_user_values: values in dictionary must be list" raise PyreadstatError(msg) for val in missing_values: if val not in valid_user_missing: msg = "missing_user_values supports values a to z for Stata and A to Z and _ for SAS, got %s instead" % str(val) raise PyreadstatError(msg) cdef readstat_error_t retcode cdef char *err_readstat cdef str err_message cdef readstat_writer_t *writer cdef bytes file_label_bytes cdef char *file_labl cdef list col_names = df.columns.values.tolist() if len(col_names) != len(set(col_names)): msg = "Non unique column names detected in the dataframe!" raise PyreadstatError(msg) for variable_name in col_names: if type(variable_name) != str: raise PyreadstatError("variable name '%s' is of type %s and it must be str (not starting with numbers!)" % (variable_name, str(type(variable_name)))) if not variable_name[0].isalpha(): raise PyreadstatError("variable name '%s' starts with an illegal (non-alphabetic) character: '%s' (ordinal %s)" % (variable_name, variable_name[0], ord(variable_name[0]))) if " " in variable_name: raise PyreadstatError("variable name '%s' contains a space, which is not allowed" % variable_name) if file_format == FILE_FORMAT_POR: col_names = [x.upper() for x in col_names] cdef list col_types = get_pandas_column_types(df, missing_user_values, variable_value_labels) cdef int row_count = len(df) cdef int col_count = len(col_names) cdef dict col_names_to_types = {k:v[0] for k,v in zip(col_names, col_types)} cdef readstat_variable_t *variable cdef pywriter_variable_type curtype cdef int max_length cdef char *curformat cdef str tempformat cdef int col_indx cdef bytes cur_col_label cdef int col_label_count = 0 cdef readstat_variable_t *tempvar cdef int row_indx cdef str curvalstr cdef double dtimelikeval #cdef np.ndarray values cdef object values cdef dict value_labels cdef int lblset_cnt = 0 cdef readstat_label_set_t *label_set cdef list col_label_temp cdef bint hasdatetime64 cdef list pywriter_types cdef object df2 cdef float mulfac, conv2secs if hasattr(os, 'fsencode'): try: filename_path = os.fsencode(filename_path) except UnicodeError: warnings.warn("file path could not be encoded with %s which is set as your system encoding, trying to encode it as utf-8. Please set your system encoding correctly." % sys.getfilesystemencoding()) filename_bytes = os.fsdecode(filename_path).encode("utf-8", "surrogateescape") else: if type(filename_path) == str: filename_bytes = filename_path.encode('utf-8') elif type(filename_path) == bytes: filename_bytes = filename_path else: raise PyreadstatError("path must be either str or bytes") filename_path = os.path.expanduser(filename_path) cdef int fd = open_file(filename_path) writer = readstat_writer_init() try: check_exit_status(readstat_set_data_writer(writer, write_bytes)) if file_label: file_label_bytes = file_label.encode("utf-8") file_labl = file_label_bytes check_exit_status(readstat_writer_set_file_label(writer, file_labl)) if note: readstat_add_note(writer, note.encode("utf-8")) if file_format_version > -1: check_exit_status(readstat_writer_set_file_format_version(writer, file_format_version)) if row_compression: check_exit_status(readstat_writer_set_compression(writer, READSTAT_COMPRESS_ROWS)) # table name is used only for xpt files if table_name: table_name_bytes = table_name.encode("utf-8") tab_name = table_name_bytes check_exit_status(readstat_writer_set_table_name(writer, tab_name)) # add variables if column_labels: if type(column_labels) != list and type(column_labels) != dict: raise PyreadstatError("column_labels must be either list or dict!") if type(column_labels) == dict: col_label_temp = list() for col_indx in range(col_count): variable_name = col_names[col_indx] if variable_name in column_labels.keys(): col_label_temp.append(column_labels[variable_name]) else: col_label_temp.append(None) column_labels = col_label_temp col_label_count = len(column_labels) if col_label_count != col_count: raise PyreadstatError("length of column labels must be the same as number of columns") for col_indx in range(col_count): curtype, max_length, _ = col_types[col_indx] variable_name = col_names[col_indx] variable = readstat_add_variable(writer, variable_name.encode("utf-8"), pandas_to_readstat_types[curtype], max_length) if variable_format: tempformat = variable_format.get(variable_name) if tempformat: readstat_variable_set_format(variable, tempformat.encode("utf-8")) if curtype in pyrwriter_datetimelike_types and (variable_format is None or variable_name not in variable_format.keys()): curformat = get_datetimelike_format_for_readstat(file_format, curtype) readstat_variable_set_format(variable, curformat) if col_label_count: if column_labels[col_indx] is not None: if type(column_labels[col_indx]) != str: raise PyreadstatError("Column labels must be strings") cur_col_label = column_labels[col_indx].encode("utf-8") readstat_variable_set_label(variable, cur_col_label) if variable_value_labels: value_labels = variable_value_labels.get(variable_name) if value_labels: labelset_name = variable_name + str(lblset_cnt) lblset_cnt += 1 curuser_missing = None if missing_user_values: curuser_missing = missing_user_values.get(variable_name) label_set = set_value_label(writer, value_labels, labelset_name, col_names_to_types[variable_name], file_format, variable_name, curuser_missing) readstat_variable_set_label_set(variable, label_set) if missing_ranges: cur_ranges = missing_ranges.get(variable_name) if cur_ranges: if not isinstance(cur_ranges, list): msg = "missing_ranges: values in dictionary must be list" raise PyreadstatError(msg) add_missing_ranges(cur_ranges, variable, curtype, variable_name) if variable_alignment: # At the moment this is ineffective for sav and dta (the function runs but in # the resulting file all alignments are still unknown) cur_alignment = variable_alignment.get(variable_name) if cur_alignment: set_variable_alignment(variable, cur_alignment, variable_name) if variable_display_width: cur_display_width = variable_display_width.get(variable_name) if cur_display_width: set_variable_display_width(variable, cur_display_width, variable_name) if variable_measure: cur_measure = variable_measure.get(variable_name) if cur_measure: set_variable_measure(variable, cur_measure, variable_name) # start writing if file_format == FILE_FORMAT_SAS7BCAT: check_exit_status(readstat_begin_writing_sas7bcat(writer, &fd)) elif file_format == FILE_FORMAT_DTA: check_exit_status(readstat_begin_writing_dta(writer, &fd, row_count)) elif file_format == FILE_FORMAT_SAV: check_exit_status(readstat_begin_writing_sav(writer, &fd, row_count)) elif file_format == FILE_FORMAT_POR: check_exit_status(readstat_begin_writing_por(writer, &fd, row_count)) elif file_format == FILE_FORMAT_SAS7BDAT: check_exit_status(readstat_begin_writing_sas7bdat(writer, &fd, row_count)) elif file_format == FILE_FORMAT_XPORT: check_exit_status(readstat_begin_writing_xport(writer, &fd, row_count)) else: raise PyreadstatError("unknown file format") # validation check_exit_status(readstat_validate_metadata(writer)) for col_indx in range(col_count): tempvar = readstat_get_variable(writer, col_indx) check_exit_status(readstat_validate_variable(writer, tempvar)) # vectorized transform of datetime64ns columns pywriter_types = [x[0] for x in col_types] hasdatetime64 = PYWRITER_DATETIME64_NS in pywriter_types or PYWRITER_DATETIME64_US in pywriter_types if hasdatetime64: if file_format == FILE_FORMAT_SAV or file_format == FILE_FORMAT_POR: offset_secs = spss_offset_secs else: offset_secs = sas_offset_secs mulfac = 1.0 if file_format == FILE_FORMAT_DTA: # stata stores in milliseconds mulfac = 1000.0 df2 = df.copy() for col_indx in range(col_count): if pywriter_types[col_indx] == PYWRITER_DATETIME64_NS: df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac #df2.iloc[:, col_indx] = (np.round(df2.iloc[:, col_indx].values.astype(object).astype(np.float64)/1e9) + offset_secs) * mulfac elif pywriter_types[col_indx] == PYWRITER_DATETIME64_US: df2[df2.columns[col_indx]] = (np.round(df2.iloc[:, col_indx].values.astype(np.float64)/1e6) + offset_secs) * mulfac df2.loc[df2[df2.columns[col_indx]]==-9223056417655, df2.columns[col_indx]] = np.nan else: df2 = df # inserting rowcnt = 0 for row in df2.values: check_exit_status(readstat_begin_row(writer)) for col_indx in range(col_count): tempvar = readstat_get_variable(writer, col_indx) curval = row[col_indx] curtype = pywriter_types[col_indx] is_missing = col_types[col_indx][2] curuser_missing = None if missing_user_values: curuser_missing = missing_user_values.get(col_names[col_indx]) if is_missing: #if curval is None or (type(curval) in numeric_types and np.isnan(curval)): if pd.isna(curval): check_exit_status(readstat_insert_missing_value(writer, tempvar)) continue if curuser_missing and curtype in pywriter_numeric_types: if curval in curuser_missing: check_exit_status(readstat_insert_tagged_missing_value(writer, tempvar, ord(curval))) continue if curtype == PYWRITER_DOUBLE: check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) elif curtype == PYWRITER_INTEGER: check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) elif curtype == PYWRITER_LOGICAL: check_exit_status(readstat_insert_int32_value(writer, tempvar, curval)) elif curtype == PYWRITER_CHARACTER: check_exit_status(readstat_insert_string_value(writer, tempvar, curval.encode("utf-8"))) elif curtype == PYWRITER_OBJECT: curvalstr = str(curval) check_exit_status(readstat_insert_string_value(writer, tempvar, curvalstr.encode("utf-8"))) elif curtype == PYWRITER_DATETIME64_NS or curtype == PYWRITER_DATETIME64_US: check_exit_status(readstat_insert_double_value(writer, tempvar, curval)) elif curtype in pyrwriter_datetimelike_types: dtimelikeval = convert_datetimelike_to_number(file_format, curtype, curval) check_exit_status(readstat_insert_double_value(writer, tempvar, dtimelikeval)) else: raise PyreadstatError("Unknown data format to insert") check_exit_status(readstat_end_row(writer)) rowcnt += 1 check_exit_status(readstat_end_writing(writer)) except: raise finally: readstat_writer_free(writer) close_file(fd) return 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/pyreadstat/conditional_includes.h0000644023477200000240000000254214574360757022352 0ustar00fajardoostaffs/* The include and declarations in this file exists because when cython translates to c it cannot translate an IF UNAME_SYSNAME=="Windows" to * a c #ifdef. That means the resulting c file will be different if produced on windows or on unix. We want our c files to be portable and * therefore do the right includes for windows here, and just declare dummy symbols for unix. */ #ifdef _WIN32 #include #include #include #include // Stuff for handling paths with international characters on windows void assign_fd(void *io_ctx, int fd) { ((unistd_io_ctx_t*)io_ctx)->fd = fd; } //ssize_t write(int fd, const void *buf, size_t nbyte){return 0;}; //int close(int fd); #else #include #include #include //int open(const char *path, int oflag, int mode); //int close(int fd); int _wsopen(const wchar_t *filename, int oflag, int shflag, int pmode){ return 0; }; int _O_RDONLY; int _O_BINARY; int _O_WRONLY; int _O_TRUNC; int _O_CREAT; int _SH_DENYRW; int _SH_DENYWR; int _SH_DENYRD; int _SH_DENYNO; int _S_IWRITE; int _S_IREAD; void assign_fd(void *io_ctx, int fd){}; int _close(int fd){ return 0; }; ssize_t _write(int fd, const void *buf, size_t nbyte){return 0;}; #endif ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350845.0 pyreadstat-1.2.7/pyreadstat/pyfunctions.py0000644023477200000240000001206414574360775020743 0ustar00fajardoostaffs""" Functions written in pure python """ from copy import deepcopy import pandas as pd # Functions to deal with value labels def set_value_labels(dataframe, metadata, formats_as_category=True, formats_as_ordered_category=False): """ Changes the values in the dataframe according to the value formats in the metadata. It will return a copy of the dataframe. If no appropiate formats were found, the result will be an unchanged copy of the original dataframe. Parameters ---------- dataframe : pandas dataframe resulting from parsing a file metadata : dictionary resulting from parsing a file formats_as_category : bool, optional defaults to True. If True the variables having formats will be transformed into pandas categories. formats_as_ordered_category : bool, optional defaults to False. If True the variables having formats will be transformed into pandas ordered categories. it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of the value of formats_as_category. Returns ------- df_copy : pandas dataframe a copy of the original dataframe with the values changed, if appropiate formats were found, unaltered otherwise """ df_copy = dataframe.copy() if metadata.value_labels and metadata.variable_to_label: for var_name, label_name in metadata.variable_to_label.items(): labels = metadata.value_labels.get(label_name) if labels: if var_name in df_copy.columns: df_copy[var_name] = df_copy[var_name].apply(lambda x: labels.get(x, x)) if formats_as_ordered_category: categories = list(set(labels.values())) original_values = list(labels.keys()) original_values.sort() revdict= dict() for orival in original_values: curcat = labels.get(orival) if not revdict.get(curcat): revdict[curcat] = orival categories.sort(key=revdict.get) df_copy[var_name] = pd.Categorical( df_copy[var_name], ordered = True, categories = categories ) elif formats_as_category: df_copy[var_name] = df_copy[var_name].astype("category") return df_copy def set_catalog_to_sas(sas_dataframe, sas_metadata, catalog_metadata, formats_as_category=True, formats_as_ordered_category=False): """ Changes the values in the dataframe and sas_metadata according to the formats in the catalog. It will return a copy of the dataframe and metadata. If no appropriate formats were found, the result will be an unchanged copy of the original dataframe. Parameters ---------- sas_dataframe : pandas dataframe resulting from parsing a sas7bdat file sas_metadata : pyreadstat metadata object resulting from parsing a sas7bdat file catalog_metadata : pyreadstat metadata object resulting from parsing a sas7bcat (catalog) file formats_as_category : bool, optional defaults to True. If True the variables having formats will be transformed into pandas categories. formats_as_ordered_category : bool, optional defaults to False. If True the variables having formats will be transformed into pandas ordered categories. it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of the value of formats_as_category. Returns ------- df_copy : pandas dataframe a copy of the original dataframe with the values changed, if appropriate formats were found, unaltered otherwise metadata : dict a copy of the original sas_metadata enriched with catalog information if found, otherwise unaltered """ if catalog_metadata.value_labels and sas_metadata.variable_to_label: catalog_metadata_copy = deepcopy(catalog_metadata) metadata = deepcopy(sas_metadata) metadata.value_labels = catalog_metadata_copy.value_labels df_copy = set_value_labels(sas_dataframe, metadata, formats_as_category=formats_as_category, formats_as_ordered_category=formats_as_ordered_category) variable_value_labels = dict() for var_name, var_label in metadata.variable_to_label.items(): current_labels = catalog_metadata_copy.value_labels.get(var_label) if current_labels: variable_value_labels[var_name] = current_labels metadata.variable_value_labels = variable_value_labels else: df_copy = sas_dataframe.copy() metadata = deepcopy(sas_metadata) return df_copy, metadata ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418354.0 pyreadstat-1.2.7/pyreadstat/pyreadstat.c0000644023477200000240000346002214574564662020341 0ustar00fajardoostaffs/* Generated by Cython 3.0.9 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ "pyreadstat/conditional_includes.h", "src/readstat.h", "src/readstat_io_unistd.h" ], "extra_compile_args": [ "-Ireadstat", "-DHAVE_ZLIB=1" ], "include_dirs": [ "pyreadstat", "src", "src/stata", "src/spss", "src/sas", "." ], "libraries": [ "m", "z" ], "name": "pyreadstat.pyreadstat", "sources": [ "pyreadstat/pyreadstat.pyx", "./src/CKHashTable.c", "./src/readstat_bits.c", "./src/readstat_convert.c", "./src/readstat_error.c", "./src/readstat_io_unistd.c", "./src/readstat_malloc.c", "./src/readstat_metadata.c", "./src/readstat_parser.c", "./src/readstat_value.c", "./src/readstat_variable.c", "./src/readstat_writer.c", "./src/sas/ieee.c", "./src/sas/readstat_sas.c", "./src/sas/readstat_sas7bcat_read.c", "./src/sas/readstat_sas7bcat_write.c", "./src/sas/readstat_sas7bdat_read.c", "./src/sas/readstat_sas7bdat_write.c", "./src/sas/readstat_sas_rle.c", "./src/sas/readstat_xport.c", "./src/sas/readstat_xport_parse_format.c", "./src/sas/readstat_xport_read.c", "./src/sas/readstat_xport_write.c", "./src/spss/readstat_por.c", "./src/spss/readstat_por_parse.c", "./src/spss/readstat_por_read.c", "./src/spss/readstat_por_write.c", "./src/spss/readstat_sav.c", "./src/spss/readstat_sav_compress.c", "./src/spss/readstat_sav_parse.c", "./src/spss/readstat_sav_parse_timestamp.c", "./src/spss/readstat_sav_read.c", "./src/spss/readstat_sav_write.c", "./src/spss/readstat_spss.c", "./src/spss/readstat_spss_parse.c", "./src/spss/readstat_zsav_compress.c", "./src/spss/readstat_zsav_read.c", "./src/spss/readstat_zsav_write.c", "./src/stata/readstat_dta.c", "./src/stata/readstat_dta_parse_timestamp.c", "./src/stata/readstat_dta_read.c", "./src/stata/readstat_dta_write.c" ] }, "module_name": "pyreadstat.pyreadstat" } END: Cython Metadata */ #ifndef PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif /* PY_SSIZE_T_CLEAN */ #if defined(CYTHON_LIMITED_API) && 0 #ifndef Py_LIMITED_API #if CYTHON_LIMITED_API+0 > 0x03030000 #define Py_LIMITED_API CYTHON_LIMITED_API #else #define Py_LIMITED_API 0x03030000 #endif #endif #endif #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. #elif PY_VERSION_HEX < 0x02070000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) #error Cython requires Python 2.7+ or Python 3.3+. #else #if defined(CYTHON_LIMITED_API) && CYTHON_LIMITED_API #define __PYX_EXTRA_ABI_MODULE_NAME "limited" #else #define __PYX_EXTRA_ABI_MODULE_NAME "" #endif #define CYTHON_ABI "3_0_9" __PYX_EXTRA_ABI_MODULE_NAME #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "." #define CYTHON_HEX_VERSION 0x030009F0 #define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall #endif #ifndef __cdecl #define __cdecl #endif #ifndef __fastcall #define __fastcall #endif #endif #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif #define __PYX_COMMA , #ifndef HAVE_LONG_LONG #define HAVE_LONG_LONG #endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX #if defined(GRAALVM_PYTHON) /* For very preliminary testing purposes. Most variables are set the same as PyPy. The existence of this section does not imply that anything works or is even tested */ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 1 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3) #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(PYPY_VERSION) #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #undef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 1 #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS (PY_MAJOR_VERSION >= 3) #endif #if PY_VERSION_HEX < 0x03090000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1 && PYPY_VERSION_NUM >= 0x07030C00) #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(CYTHON_LIMITED_API) #ifdef Py_LIMITED_API #undef __PYX_LIMITED_VERSION_HEX #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API #endif #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 1 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #undef CYTHON_CLINE_IN_TRACEBACK #define CYTHON_CLINE_IN_TRACEBACK 0 #undef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 0 #undef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 1 #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #undef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #endif #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #undef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 0 #undef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 0 #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_GIL #define CYTHON_FAST_GIL 0 #undef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #undef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 1 #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 #endif #elif defined(Py_GIL_DISABLED) || defined(Py_NOGIL) #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 0 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 1 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #undef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 0 #ifndef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 1 #endif #undef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 0 #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #undef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 0 #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #undef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 0 #undef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 0 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 1 #endif #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #else #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #define CYTHON_COMPILING_IN_LIMITED_API 0 #define CYTHON_COMPILING_IN_GRAAL 0 #define CYTHON_COMPILING_IN_NOGIL 0 #ifndef CYTHON_USE_TYPE_SLOTS #define CYTHON_USE_TYPE_SLOTS 1 #endif #ifndef CYTHON_USE_TYPE_SPECS #define CYTHON_USE_TYPE_SPECS 0 #endif #ifndef CYTHON_USE_PYTYPE_LOOKUP #define CYTHON_USE_PYTYPE_LOOKUP 1 #endif #if PY_MAJOR_VERSION < 3 #undef CYTHON_USE_ASYNC_SLOTS #define CYTHON_USE_ASYNC_SLOTS 0 #elif !defined(CYTHON_USE_ASYNC_SLOTS) #define CYTHON_USE_ASYNC_SLOTS 1 #endif #ifndef CYTHON_USE_PYLONG_INTERNALS #define CYTHON_USE_PYLONG_INTERNALS 1 #endif #ifndef CYTHON_USE_PYLIST_INTERNALS #define CYTHON_USE_PYLIST_INTERNALS 1 #endif #ifndef CYTHON_USE_UNICODE_INTERNALS #define CYTHON_USE_UNICODE_INTERNALS 1 #endif #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 #undef CYTHON_USE_UNICODE_WRITER #define CYTHON_USE_UNICODE_WRITER 0 #elif !defined(CYTHON_USE_UNICODE_WRITER) #define CYTHON_USE_UNICODE_WRITER 1 #endif #ifndef CYTHON_AVOID_BORROWED_REFS #define CYTHON_AVOID_BORROWED_REFS 0 #endif #ifndef CYTHON_ASSUME_SAFE_MACROS #define CYTHON_ASSUME_SAFE_MACROS 1 #endif #ifndef CYTHON_UNPACK_METHODS #define CYTHON_UNPACK_METHODS 1 #endif #ifndef CYTHON_FAST_THREAD_STATE #define CYTHON_FAST_THREAD_STATE 1 #endif #ifndef CYTHON_FAST_GIL #define CYTHON_FAST_GIL (PY_MAJOR_VERSION < 3 || PY_VERSION_HEX >= 0x03060000 && PY_VERSION_HEX < 0x030C00A6) #endif #ifndef CYTHON_METH_FASTCALL #define CYTHON_METH_FASTCALL (PY_VERSION_HEX >= 0x030700A1) #endif #ifndef CYTHON_FAST_PYCALL #define CYTHON_FAST_PYCALL 1 #endif #ifndef CYTHON_PEP487_INIT_SUBCLASS #define CYTHON_PEP487_INIT_SUBCLASS 1 #endif #if PY_VERSION_HEX < 0x03050000 #undef CYTHON_PEP489_MULTI_PHASE_INIT #define CYTHON_PEP489_MULTI_PHASE_INIT 0 #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT) #define CYTHON_PEP489_MULTI_PHASE_INIT 1 #endif #ifndef CYTHON_USE_MODULE_STATE #define CYTHON_USE_MODULE_STATE 0 #endif #if PY_VERSION_HEX < 0x030400a1 #undef CYTHON_USE_TP_FINALIZE #define CYTHON_USE_TP_FINALIZE 0 #elif !defined(CYTHON_USE_TP_FINALIZE) #define CYTHON_USE_TP_FINALIZE 1 #endif #if PY_VERSION_HEX < 0x030600B1 #undef CYTHON_USE_DICT_VERSIONS #define CYTHON_USE_DICT_VERSIONS 0 #elif !defined(CYTHON_USE_DICT_VERSIONS) #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5) #endif #if PY_VERSION_HEX < 0x030700A3 #undef CYTHON_USE_EXC_INFO_STACK #define CYTHON_USE_EXC_INFO_STACK 0 #elif !defined(CYTHON_USE_EXC_INFO_STACK) #define CYTHON_USE_EXC_INFO_STACK 1 #endif #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 #endif #endif #if !defined(CYTHON_FAST_PYCCALL) #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if !defined(CYTHON_VECTORCALL) #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL && PY_VERSION_HEX >= 0x030800B1) #endif #define CYTHON_BACKPORT_VECTORCALL (CYTHON_METH_FASTCALL && PY_VERSION_HEX < 0x030800B1) #if CYTHON_USE_PYLONG_INTERNALS #if PY_MAJOR_VERSION < 3 #include "longintrepr.h" #endif #undef SHIFT #undef BASE #undef MASK #ifdef SIZEOF_VOID_P enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; #endif #endif #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __has_cpp_attribute #define __has_cpp_attribute(x) 0 #endif #ifndef CYTHON_RESTRICT #if defined(__GNUC__) #define CYTHON_RESTRICT __restrict__ #elif defined(_MSC_VER) && _MSC_VER >= 1400 #define CYTHON_RESTRICT __restrict #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_RESTRICT restrict #else #define CYTHON_RESTRICT #endif #endif #ifndef CYTHON_UNUSED #if defined(__cplusplus) /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(maybe_unused) #define CYTHON_UNUSED [[maybe_unused]] #endif #endif #endif #endif #ifndef CYTHON_UNUSED # if defined(__GNUC__) # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) # define CYTHON_UNUSED __attribute__ ((__unused__)) # else # define CYTHON_UNUSED # endif #endif #ifndef CYTHON_UNUSED_VAR # if defined(__cplusplus) template void CYTHON_UNUSED_VAR( const T& ) { } # else # define CYTHON_UNUSED_VAR(x) (void)(x) # endif #endif #ifndef CYTHON_MAYBE_UNUSED_VAR #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x) #endif #ifndef CYTHON_NCP_UNUSED # if CYTHON_COMPILING_IN_CPYTHON # define CYTHON_NCP_UNUSED # else # define CYTHON_NCP_UNUSED CYTHON_UNUSED # endif #endif #ifndef CYTHON_USE_CPP_STD_MOVE #if defined(__cplusplus) && (\ __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)) #define CYTHON_USE_CPP_STD_MOVE 1 #else #define CYTHON_USE_CPP_STD_MOVE 0 #endif #endif #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) #ifdef _MSC_VER #ifndef _MSC_STDINT_H_ #if _MSC_VER < 1300 typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #else typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; #endif #endif #if _MSC_VER < 1300 #ifdef _WIN64 typedef unsigned long long __pyx_uintptr_t; #else typedef unsigned int __pyx_uintptr_t; #endif #else #ifdef _WIN64 typedef unsigned __int64 __pyx_uintptr_t; #else typedef unsigned __int32 __pyx_uintptr_t; #endif #endif #else #include typedef uintptr_t __pyx_uintptr_t; #endif #ifndef CYTHON_FALLTHROUGH #if defined(__cplusplus) /* for clang __has_cpp_attribute(fallthrough) is true even before C++17 * but leads to warnings with -pedantic, since it is a C++17 feature */ #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L) #if __has_cpp_attribute(fallthrough) #define CYTHON_FALLTHROUGH [[fallthrough]] #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_cpp_attribute(clang::fallthrough) #define CYTHON_FALLTHROUGH [[clang::fallthrough]] #elif __has_cpp_attribute(gnu::fallthrough) #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] #endif #endif #endif #ifndef CYTHON_FALLTHROUGH #if __has_attribute(fallthrough) #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) #else #define CYTHON_FALLTHROUGH #endif #endif #if defined(__clang__) && defined(__apple_build_version__) #if __apple_build_version__ < 7000000 #undef CYTHON_FALLTHROUGH #define CYTHON_FALLTHROUGH #endif #endif #endif #ifdef __cplusplus template struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);}; #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL::value) #else #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0) #endif #if CYTHON_COMPILING_IN_PYPY == 1 #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x030A0000) #else #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000) #endif #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer)) #ifndef CYTHON_INLINE #if defined(__clang__) #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) #elif defined(__GNUC__) #define CYTHON_INLINE __inline__ #elif defined(_MSC_VER) #define CYTHON_INLINE __inline #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define CYTHON_INLINE inline #else #define CYTHON_INLINE #endif #endif #define __PYX_BUILD_PY_SSIZE_T "n" #define CYTHON_FORMAT_SSIZE_T "z" #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_DefaultClassType PyClass_Type #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_BUILTIN_MODULE_NAME "builtins" #define __Pyx_DefaultClassType PyType_Type #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE PyObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyObject *exception_table = NULL; PyObject *types_module=NULL, *code_type=NULL, *result=NULL; #if __PYX_LIMITED_VERSION_HEX < 0x030B0000 PyObject *version_info; PyObject *py_minor_version = NULL; #endif long minor_version = 0; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); #if __PYX_LIMITED_VERSION_HEX >= 0x030B0000 minor_version = 11; #else if (!(version_info = PySys_GetObject("version_info"))) goto end; if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end; minor_version = PyLong_AsLong(py_minor_version); Py_DECREF(py_minor_version); if (minor_version == -1 && PyErr_Occurred()) goto end; #endif if (!(types_module = PyImport_ImportModule("types"))) goto end; if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end; if (minor_version <= 7) { (void)p; result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOO", a, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else if (minor_version <= 10) { result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOO", a,p, k, l, s, f, code, c, n, v, fn, name, fline, lnos, fv, cell); } else { if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end; result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOO", a,p, k, l, s, f, code, c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell); } end: Py_XDECREF(code_type); Py_XDECREF(exception_table); Py_XDECREF(types_module); if (type) { PyErr_Restore(type, value, traceback); } return result; } #ifndef CO_OPTIMIZED #define CO_OPTIMIZED 0x0001 #endif #ifndef CO_NEWLOCALS #define CO_NEWLOCALS 0x0002 #endif #ifndef CO_VARARGS #define CO_VARARGS 0x0004 #endif #ifndef CO_VARKEYWORDS #define CO_VARKEYWORDS 0x0008 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x0200 #endif #ifndef CO_GENERATOR #define CO_GENERATOR 0x0020 #endif #ifndef CO_COROUTINE #define CO_COROUTINE 0x0080 #endif #elif PY_VERSION_HEX >= 0x030B0000 static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int p, int k, int l, int s, int f, PyObject *code, PyObject *c, PyObject* n, PyObject *v, PyObject *fv, PyObject *cell, PyObject* fn, PyObject *name, int fline, PyObject *lnos) { PyCodeObject *result; PyObject *empty_bytes = PyBytes_FromStringAndSize("", 0); if (!empty_bytes) return NULL; result = #if PY_VERSION_HEX >= 0x030C0000 PyUnstable_Code_NewWithPosOnlyArgs #else PyCode_NewWithPosOnlyArgs #endif (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, empty_bytes); Py_DECREF(empty_bytes); return result; } #elif PY_VERSION_HEX >= 0x030800B2 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #else #define __Pyx_PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif #endif #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE) #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type) #else #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is) #define __Pyx_Py_Is(x, y) Py_Is(x, y) #else #define __Pyx_Py_Is(x, y) ((x) == (y)) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone) #define __Pyx_Py_IsNone(ob) Py_IsNone(ob) #else #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue) #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob) #else #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True) #endif #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse) #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob) #else #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False) #endif #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj)) #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o) #else #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o) #endif #ifndef CO_COROUTINE #define CO_COROUTINE 0x80 #endif #ifndef CO_ASYNC_GENERATOR #define CO_ASYNC_GENERATOR 0x200 #endif #ifndef Py_TPFLAGS_CHECKTYPES #define Py_TPFLAGS_CHECKTYPES 0 #endif #ifndef Py_TPFLAGS_HAVE_INDEX #define Py_TPFLAGS_HAVE_INDEX 0 #endif #ifndef Py_TPFLAGS_HAVE_NEWBUFFER #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif #ifndef Py_TPFLAGS_SEQUENCE #define Py_TPFLAGS_SEQUENCE 0 #endif #ifndef Py_TPFLAGS_MAPPING #define Py_TPFLAGS_MAPPING 0 #endif #ifndef METH_STACKLESS #define METH_STACKLESS 0 #endif #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) #ifndef METH_FASTCALL #define METH_FASTCALL 0x80 #endif typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames); #else #if PY_VERSION_HEX >= 0x030d00A4 # define __Pyx_PyCFunctionFast PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords #else # define __Pyx_PyCFunctionFast _PyCFunctionFast # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords #endif #endif #if CYTHON_METH_FASTCALL #define __Pyx_METH_FASTCALL METH_FASTCALL #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords #else #define __Pyx_METH_FASTCALL METH_VARARGS #define __Pyx_PyCFunction_FastCall PyCFunction #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords #endif #if CYTHON_VECTORCALL #define __pyx_vectorcallfunc vectorcallfunc #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n)) #elif CYTHON_BACKPORT_VECTORCALL typedef PyObject *(*__pyx_vectorcallfunc)(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames); #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET ((size_t)1 << (8 * sizeof(size_t) - 1)) #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(((size_t)(n)) & ~__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET)) #else #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0 #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n)) #endif #if PY_MAJOR_VERSION >= 0x030900B1 #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func) #else #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func) #endif #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func) #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth) #elif !CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags) static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) { return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self; } #endif static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void *cfunc) { #if CYTHON_COMPILING_IN_LIMITED_API return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc; #else return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; #endif } #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc) #if __PYX_LIMITED_VERSION_HEX < 0x030900B1 #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b)) typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *); #else #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b) #define __Pyx_PyCMethod PyCMethod #endif #ifndef METH_METHOD #define METH_METHOD 0x200 #endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) #define PyObject_Malloc(s) PyMem_Malloc(s) #define PyObject_Free(p) PyMem_Free(p) #define PyObject_Realloc(p) PyMem_Realloc(p) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) #else #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyThreadState_Current PyThreadState_Get() #elif !CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_Current PyThreadState_GET() #elif PY_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked() #elif PY_VERSION_HEX >= 0x03060000 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() #elif PY_VERSION_HEX >= 0x03000000 #define __Pyx_PyThreadState_Current PyThreadState_GET() #else #define __Pyx_PyThreadState_Current _PyThreadState_Current #endif #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE void *__Pyx_PyModule_GetState(PyObject *op) { void *result; result = PyModule_GetState(op); if (!result) Py_FatalError("Couldn't find the module state"); return result; } #endif #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE(obj), name, func_ctype) #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name)) #else #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name) #endif #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) #include "pythread.h" #define Py_tss_NEEDS_INIT 0 typedef int Py_tss_t; static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { *key = PyThread_create_key(); return 0; } static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); *key = Py_tss_NEEDS_INIT; return key; } static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { PyObject_Free(key); } static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { return *key != Py_tss_NEEDS_INIT; } static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { PyThread_delete_key(*key); *key = Py_tss_NEEDS_INIT; } static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { return PyThread_set_key_value(*key, value); } static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { return PyThread_get_key_value(*key); } #endif #if PY_MAJOR_VERSION < 3 #if CYTHON_COMPILING_IN_PYPY #if PYPY_VERSION_NUM < 0x07030600 #if defined(__cplusplus) && __cplusplus >= 201402L [[deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")]] #elif defined(__GNUC__) || defined(__clang__) __attribute__ ((__deprecated__("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6"))) #elif defined(_MSC_VER) __declspec(deprecated("`with nogil:` inside a nogil function will not release the GIL in PyPy2 < 7.3.6")) #endif static CYTHON_INLINE int PyGILState_Check(void) { return 0; } #else // PYPY_VERSION_NUM < 0x07030600 #endif // PYPY_VERSION_NUM < 0x07030600 #else static CYTHON_INLINE int PyGILState_Check(void) { PyThreadState * tstate = _PyThreadState_Current; return tstate && (tstate == PyGILState_GetThisThreadState()); } #endif #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000 || defined(_PyDict_NewPresized) #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) #else #define __Pyx_PyDict_NewPresized(n) PyDict_New() #endif #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) #else #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B4 && PY_VERSION_HEX < 0x030d0000 && CYTHON_USE_UNICODE_INTERNALS #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) { PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name); if (res == NULL) PyErr_Clear(); return res; } #elif PY_MAJOR_VERSION >= 3 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000) #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError #define __Pyx_PyDict_GetItemStr PyDict_GetItem #else static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) { #if CYTHON_COMPILING_IN_PYPY return PyDict_GetItem(dict, name); #else PyDictEntry *ep; PyDictObject *mp = (PyDictObject*) dict; long hash = ((PyStringObject *) name)->ob_shash; assert(hash != -1); ep = (mp->ma_lookup)(mp, name, hash); if (ep == NULL) { return NULL; } return ep->me_value; #endif } #define __Pyx_PyDict_GetItemStr PyDict_GetItem #endif #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags) #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0) #define __Pyx_PyObject_GetIterNextFunc(obj) (Py_TYPE(obj)->tp_iternext) #else #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp)) #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature) #define __Pyx_PyObject_GetIterNextFunc(obj) PyIter_Next #endif #if CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_SetItemOnTypeDict(tp, k, v) PyObject_GenericSetAttr((PyObject*)tp, k, v) #else #define __Pyx_SetItemOnTypeDict(tp, k, v) PyDict_SetItem(tp->tp_dict, k, v) #endif #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX >= 0x03080000 #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\ PyTypeObject *type = Py_TYPE((PyObject*)obj);\ assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\ PyObject_GC_Del(obj);\ Py_DECREF(type);\ } #else #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj) #endif #if CYTHON_COMPILING_IN_LIMITED_API #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GetLength(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U) #define __Pyx_PyUnicode_KIND(u) ((void)u, (0)) #define __Pyx_PyUnicode_DATA(u) ((void*)u) #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i)) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u)) #elif PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_READY(op) (0) #else #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #endif #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u)) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch) #if PY_VERSION_HEX >= 0x030C0000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) #else #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) #else #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #endif #endif #else #define CYTHON_PEP393_ENABLED 0 #define PyUnicode_1BYTE_KIND 1 #define PyUnicode_2BYTE_KIND 2 #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535U : 1114111U) #define __Pyx_PyUnicode_KIND(u) ((int)sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = (Py_UNICODE) ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) #endif #if CYTHON_COMPILING_IN_PYPY #if !defined(PyUnicode_DecodeUnicodeEscape) #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors) #endif #if !defined(PyUnicode_Contains) || (PY_MAJOR_VERSION == 2 && PYPY_VERSION_NUM < 0x07030500) #undef PyUnicode_Contains #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif #if !defined(PyByteArray_Check) #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) #endif #if !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) #else #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) #endif #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) #define PyObject_ASCII(o) PyObject_Repr(o) #endif #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #ifndef PyObject_Unicode #define PyObject_Unicode PyObject_Str #endif #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) #else #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) #endif #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_PySequence_ListKeepNew(obj)\ (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj)) #else #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj) #endif #ifndef PySet_CheckExact #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type) #endif #if PY_VERSION_HEX >= 0x030900A4 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) #else #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) #endif #if CYTHON_ASSUME_SAFE_MACROS #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i) #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0)) #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0)) #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o) #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o) #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o) #else #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i) #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v) #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v) #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o) #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o) #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o) #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o) #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o) #endif #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name) #else static CYTHON_INLINE PyObject *__Pyx_PyImport_AddModuleRef(const char *name) { PyObject *module = PyImport_AddModule(name); Py_XINCREF(module); return module; } #endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type #define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) PyLong_CheckExact(op) #define __Pyx_Py3Int_Check(op) PyLong_Check(op) #define __Pyx_Py3Int_CheckExact(op) PyLong_CheckExact(op) #define PyInt_FromString PyLong_FromString #define PyInt_FromUnicode PyLong_FromUnicode #define PyInt_FromLong PyLong_FromLong #define PyInt_FromSize_t PyLong_FromSize_t #define PyInt_FromSsize_t PyLong_FromSsize_t #define PyInt_AsLong PyLong_AsLong #define PyInt_AS_LONG PyLong_AS_LONG #define PyInt_AsSsize_t PyLong_AsSsize_t #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #define PyNumber_Int PyNumber_Long #else #define __Pyx_Py3Int_Check(op) (PyLong_Check(op) || PyInt_Check(op)) #define __Pyx_Py3Int_CheckExact(op) (PyLong_CheckExact(op) || PyInt_CheckExact(op)) #endif #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY #ifndef PyUnicode_InternFromString #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) #endif #endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t #else #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t #endif #if CYTHON_USE_ASYNC_SLOTS #if PY_VERSION_HEX >= 0x030500B1 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif #else #define __Pyx_PyType_AsAsync(obj) NULL #endif #ifndef __Pyx_PyAsyncMethodsStruct typedef struct { unaryfunc am_await; unaryfunc am_aiter; unaryfunc am_anext; } __Pyx_PyAsyncMethodsStruct; #endif #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) #if !defined(_USE_MATH_DEFINES) #define _USE_MATH_DEFINES #endif #endif #include #ifdef NAN #define __PYX_NAN() ((float) NAN) #else static CYTHON_INLINE float __PYX_NAN() { float value; memset(&value, 0xFF, sizeof(value)); return value; } #endif #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) #define __Pyx_truncl trunc #else #define __Pyx_truncl truncl #endif #define __PYX_MARK_ERR_POS(f_index, lineno) \ { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } #define __PYX_ERR(f_index, lineno, Ln_error) \ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } #ifdef CYTHON_EXTERN_C #undef __PYX_EXTERN_C #define __PYX_EXTERN_C CYTHON_EXTERN_C #elif defined(__PYX_EXTERN_C) #ifdef _MSC_VER #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.") #else #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead. #endif #else #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" #else #define __PYX_EXTERN_C extern #endif #endif #define __PYX_HAVE__pyreadstat__pyreadstat #define __PYX_HAVE_API__pyreadstat__pyreadstat /* Early includes */ #include #include #include #include "readstat.h" #include "readstat_io_unistd.h" #include "conditional_includes.h" #ifdef _OPENMP #include #endif /* _OPENMP */ #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 1 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) #define __PYX_DEFAULT_STRING_ENCODING "utf8" #define __Pyx_PyObject_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyObject_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #define __Pyx_uchar_cast(c) ((unsigned char)c) #define __Pyx_long_cast(x) ((long)x) #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ (sizeof(type) < sizeof(Py_ssize_t)) ||\ (sizeof(type) > sizeof(Py_ssize_t) &&\ likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX) &&\ (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ v == (type)PY_SSIZE_T_MIN))) ||\ (sizeof(type) == sizeof(Py_ssize_t) &&\ (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ v == (type)PY_SSIZE_T_MAX))) ) static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { return (size_t) i < (size_t) limit; } #if defined (__cplusplus) && __cplusplus >= 201103L #include #define __Pyx_sst_abs(value) std::abs(value) #elif SIZEOF_INT >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) #elif defined (_MSC_VER) #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) #define __Pyx_sst_abs(value) __builtin_llabs(value) #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s); static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*); #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #if PY_MAJOR_VERSION < 3 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize #else #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o) #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); #define __Pyx_PySequence_Tuple(obj)\ (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); #if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) #endif #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) #else #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) #endif #if CYTHON_USE_PYLONG_INTERNALS #if PY_VERSION_HEX >= 0x030C00A7 #ifndef _PyLong_SIGN_MASK #define _PyLong_SIGN_MASK 3 #endif #ifndef _PyLong_NON_SIZE_BITS #define _PyLong_NON_SIZE_BITS 3 #endif #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK) #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0) #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x)) #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1) #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0) #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_SignedDigitCount(x)\ ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x)) #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue) #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x) #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x) #else #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS)) #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0]) #endif typedef Py_ssize_t __Pyx_compact_pylong; typedef size_t __Pyx_compact_upylong; #else #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0) #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0) #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0) #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0) #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0]) #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x)) #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x) #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1) #define __Pyx_PyLong_CompactValue(x)\ ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0])) typedef sdigit __Pyx_compact_pylong; typedef digit __Pyx_compact_upylong; #endif #if PY_VERSION_HEX >= 0x030C00A5 #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit) #else #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit) #endif #endif #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII #include static int __Pyx_sys_getdefaultencoding_not_ascii; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; PyObject* ascii_chars_u = NULL; PyObject* ascii_chars_b = NULL; const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; if (strcmp(default_encoding_c, "ascii") == 0) { __Pyx_sys_getdefaultencoding_not_ascii = 0; } else { char ascii_chars[128]; int c; for (c = 0; c < 128; c++) { ascii_chars[c] = (char) c; } __Pyx_sys_getdefaultencoding_not_ascii = 1; ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); if (!ascii_chars_u) goto bad; ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { PyErr_Format( PyExc_ValueError, "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", default_encoding_c); goto bad; } Py_DECREF(ascii_chars_u); Py_DECREF(ascii_chars_b); } Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); Py_XDECREF(ascii_chars_u); Py_XDECREF(ascii_chars_b); return -1; } #endif #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) #else #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #include static char* __PYX_DEFAULT_STRING_ENCODING; static int __Pyx_init_sys_getdefaultencoding_params(void) { PyObject* sys; PyObject* default_encoding = NULL; char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); if (!default_encoding_c) goto bad; __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); Py_DECREF(default_encoding); return 0; bad: Py_XDECREF(default_encoding); return -1; } #endif #endif /* Test for GCC > 2.95 */ #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #else /* !__GNUC__ or GCC < 2.95 */ #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } #if !CYTHON_USE_MODULE_STATE static PyObject *__pyx_m = NULL; #endif static int __pyx_lineno; static int __pyx_clineno = 0; static const char * __pyx_cfilenm = __FILE__; static const char *__pyx_filename; /* #### Code section: filename_table ### */ static const char *__pyx_f[] = { "pyreadstat/pyreadstat.pyx", "pyreadstat/_readstat_parser.pxd", }; /* #### Code section: utility_code_proto_before_types ### */ /* ForceInitThreads.proto */ #ifndef __PYX_FORCE_INIT_THREADS #define __PYX_FORCE_INIT_THREADS 0 #endif /* #### Code section: numeric_typedefs ### */ /* #### Code section: complex_type_declarations ### */ /* #### Code section: type_declarations ### */ /*--- Type declarations ---*/ struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container; struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks; /* "_readstat_parser.pxd":22 * * # Definitions of enum types * ctypedef enum py_file_extension: # <<<<<<<<<<<<<< * FILE_EXT_SAV * FILE_EXT_SAS7BDAT */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension { __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAV, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BDAT, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_DTA, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_XPORT, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_POR, __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BCAT }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension; /* "_readstat_parser.pxd":30 * FILE_EXT_SAS7BCAT * * ctypedef enum py_file_format: # <<<<<<<<<<<<<< * FILE_FORMAT_SAS * FILE_FORMAT_SPSS */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_format { __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS, __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS, __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_t_10pyreadstat_16_readstat_parser_py_file_format; /* "_readstat_parser.pxd":35 * FILE_FORMAT_STATA * * ctypedef enum py_datetime_format: # <<<<<<<<<<<<<< * DATE_FORMAT_NOTADATE * DATE_FORMAT_DATE */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format { __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_NOTADATE, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATE, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_DATETIME, __pyx_e_10pyreadstat_16_readstat_parser_DATE_FORMAT_TIME }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format __pyx_t_10pyreadstat_16_readstat_parser_py_datetime_format; /* "_readstat_parser.pxd":41 * DATE_FORMAT_TIME * * ctypedef enum py_variable_format: # <<<<<<<<<<<<<< * VAR_FORMAT_STRING * VAR_FORMAT_LONG */ enum __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format { __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_STRING, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_LONG, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_FLOAT, __pyx_e_10pyreadstat_16_readstat_parser_VAR_FORMAT_MISSING }; typedef enum __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format __pyx_t_10pyreadstat_16_readstat_parser_py_variable_format; /* "_readstat_writer.pxd":56 * ssize_t write(int fd, const void *buf, size_t nbyte) * * ctypedef enum dst_file_format: # <<<<<<<<<<<<<< * FILE_FORMAT_SAS7BDAT * FILE_FORMAT_SAS7BCAT */ enum __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format { __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAS7BDAT, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAS7BCAT, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_XPORT, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAV, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_POR }; typedef enum __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format; /* "_readstat_writer.pxd":64 * FILE_FORMAT_POR * * ctypedef enum pywriter_variable_type: # <<<<<<<<<<<<<< * PYWRITER_DOUBLE * PYWRITER_INTEGER */ enum __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type { __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DOUBLE, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_INTEGER, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_CHARACTER, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_LOGICAL, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_OBJECT, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATE, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_TIME, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_NS, __pyx_e_10pyreadstat_16_readstat_writer_PYWRITER_DATETIME64_US }; typedef enum __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type __pyx_t_10pyreadstat_16_readstat_writer_pywriter_variable_type; /* "_readstat_parser.pxd":49 * # Definitions of extension types * * cdef class data_container: # <<<<<<<<<<<<<< * """ * This extension type holds all the data we need to get from our file from */ struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container { PyObject_HEAD int n_obs; int n_vars; int max_n_obs; PyObject *col_data; PyObject *col_data_len; PyObject *col_names; PyObject *col_labels; PyObject *col_dtypes; PyObject *col_numpy_dtypes; PyObject *col_dtypes_isobject; PyObject *col_dytpes_isfloat; PyObject *col_formats; PyObject *col_formats_original; PyObject *origin; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format file_format; int is_unkown_number_rows; PyObject *file_label; PyObject *file_encoding; int metaonly; int dates_as_pandas; PyObject *label_to_var_name; PyObject *labels_raw; PyObject *notes; PyObject *user_encoding; PyObject *table_name; int filter_cols; PyObject *use_cols; int usernan; PyObject *missing_ranges; PyObject *missing_user_values; PyObject *variable_storage_width; PyObject *variable_display_width; PyObject *variable_alignment; PyObject *variable_measure; int no_datetime_conversion; int ctime; int mtime; }; /* "pyreadstat/pyreadstat.pyx":538 * # convenience functions to read in chunks * * def read_file_in_chunks(read_function, file_path, chunksize=100000, offset=0, limit=0, # <<<<<<<<<<<<<< * multiprocess=False, num_processes=4, num_rows=None, **kwargs): * """ */ struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks { PyObject_HEAD PyObject *__pyx_v__; PyObject *__pyx_v_chunksize; PyObject *__pyx_v_df; PyObject *__pyx_v_file_path; PyObject *__pyx_v_kwargs; PyObject *__pyx_v_limit; PyObject *__pyx_v_meta; PyObject *__pyx_v_multiprocess; PyObject *__pyx_v_num_processes; PyObject *__pyx_v_num_rows; PyObject *__pyx_v_numrows; PyObject *__pyx_v_offset; PyObject *__pyx_v_read_function; }; /* #### Code section: utility_code_proto ### */ /* --- Runtime support code (head) --- */ /* Refnanny.proto */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif #if CYTHON_REFNANNY typedef struct { void (*INCREF)(void*, PyObject*, Py_ssize_t); void (*DECREF)(void*, PyObject*, Py_ssize_t); void (*GOTREF)(void*, PyObject*, Py_ssize_t); void (*GIVEREF)(void*, PyObject*, Py_ssize_t); void* (*SetupContext)(const char*, Py_ssize_t, const char*); void (*FinishContext)(void**); } __Pyx_RefNannyAPIStruct; static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; #ifdef WITH_THREAD #define __Pyx_RefNannySetupContext(name, acquire_gil)\ if (acquire_gil) {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ PyGILState_Release(__pyx_gilstate_save);\ } else {\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\ } #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #else #define __Pyx_RefNannySetupContext(name, acquire_gil)\ __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__)) #define __Pyx_RefNannyFinishContextNogil() __Pyx_RefNannyFinishContext() #endif #define __Pyx_RefNannyFinishContextNogil() {\ PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ __Pyx_RefNannyFinishContext();\ PyGILState_Release(__pyx_gilstate_save);\ } #define __Pyx_RefNannyFinishContext()\ __Pyx_RefNanny->FinishContext(&__pyx_refnanny) #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__)) #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0) #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0) #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0) #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0) #else #define __Pyx_RefNannyDeclarations #define __Pyx_RefNannySetupContext(name, acquire_gil) #define __Pyx_RefNannyFinishContextNogil() #define __Pyx_RefNannyFinishContext() #define __Pyx_INCREF(r) Py_INCREF(r) #define __Pyx_DECREF(r) Py_DECREF(r) #define __Pyx_GOTREF(r) #define __Pyx_GIVEREF(r) #define __Pyx_XINCREF(r) Py_XINCREF(r) #define __Pyx_XDECREF(r) Py_XDECREF(r) #define __Pyx_XGOTREF(r) #define __Pyx_XGIVEREF(r) #endif #define __Pyx_Py_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; Py_XDECREF(tmp);\ } while (0) #define __Pyx_XDECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_XDECREF(tmp);\ } while (0) #define __Pyx_DECREF_SET(r, v) do {\ PyObject *tmp = (PyObject *) r;\ r = v; __Pyx_DECREF(tmp);\ } while (0) #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyErrExceptionMatches.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); #else #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) #endif /* PyThreadStateGet.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; #if PY_VERSION_HEX >= 0x030C00A6 #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL) #else #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL) #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type) #endif #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL) #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #endif #else #define __Pyx_PyErr_Clear() PyErr_Clear() #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif /* PyObjectGetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif /* PyObjectGetAttrStrNoError.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); /* GetBuiltinName.proto */ static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* TupleAndListFromArray.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n); static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n); #endif /* IncludeStringH.proto */ #include /* BytesEquals.proto */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /* UnicodeEquals.proto */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /* fastcall.proto */ #if CYTHON_AVOID_BORROWED_REFS #define __Pyx_Arg_VARARGS(args, i) PySequence_GetItem(args, i) #elif CYTHON_ASSUME_SAFE_MACROS #define __Pyx_Arg_VARARGS(args, i) PyTuple_GET_ITEM(args, i) #else #define __Pyx_Arg_VARARGS(args, i) PyTuple_GetItem(args, i) #endif #if CYTHON_AVOID_BORROWED_REFS #define __Pyx_Arg_NewRef_VARARGS(arg) __Pyx_NewRef(arg) #define __Pyx_Arg_XDECREF_VARARGS(arg) Py_XDECREF(arg) #else #define __Pyx_Arg_NewRef_VARARGS(arg) arg #define __Pyx_Arg_XDECREF_VARARGS(arg) #endif #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds) #define __Pyx_KwValues_VARARGS(args, nargs) NULL #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s) #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw) #if CYTHON_METH_FASTCALL #define __Pyx_Arg_FASTCALL(args, i) args[i] #define __Pyx_NumKwargs_FASTCALL(kwds) PyTuple_GET_SIZE(kwds) #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs)) static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues); #else #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw) #endif #define __Pyx_Arg_NewRef_FASTCALL(arg) arg /* no-op, __Pyx_Arg_FASTCALL is direct and this needs to have the same reference counting */ #define __Pyx_Arg_XDECREF_FASTCALL(arg) #else #define __Pyx_Arg_FASTCALL __Pyx_Arg_VARARGS #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS #define __Pyx_Arg_NewRef_FASTCALL(arg) __Pyx_Arg_NewRef_VARARGS(arg) #define __Pyx_Arg_XDECREF_FASTCALL(arg) __Pyx_Arg_XDECREF_VARARGS(arg) #endif #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS #define __Pyx_ArgsSlice_VARARGS(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_VARARGS(args, start), stop - start) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(&__Pyx_Arg_FASTCALL(args, start), stop - start) #else #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop) #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop) #endif /* RaiseDoubleKeywords.proto */ static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /* ParseKeywords.proto */ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject *const *kwvalues, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /* RaiseArgTupleInvalid.proto */ static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /* ArgTypeTest.proto */ #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\ __Pyx__ArgTypeTest(obj, type, name, exact)) static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* RaiseTooManyValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); /* RaiseNeedMoreValuesToUnpack.proto */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); /* IterFinish.proto */ static CYTHON_INLINE int __Pyx_IterFinish(void); /* UnpackItemEndCheck.proto */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /* PyObjectSetAttrStr.proto */ #if CYTHON_USE_TYPE_SLOTS #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) #endif /* PyDictVersioning.proto */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ (version_var) = __PYX_GET_DICT_VERSION(dict);\ (cache_var) = (value); #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ (VAR) = __pyx_dict_cached_value;\ } else {\ (VAR) = __pyx_dict_cached_value = (LOOKUP);\ __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ }\ } static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); #else #define __PYX_GET_DICT_VERSION(dict) (0) #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); #endif /* GetModuleGlobalName.proto */ #if CYTHON_USE_DICT_VERSIONS #define __Pyx_GetModuleGlobalName(var, name) do {\ static PY_UINT64_T __pyx_dict_version = 0;\ static PyObject *__pyx_dict_cached_value = NULL;\ (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\ PY_UINT64_T __pyx_dict_version;\ PyObject *__pyx_dict_cached_value;\ (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ } while(0) static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); #else #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); #endif /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); #else #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) #endif /* RaiseException.proto */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /* PyDictContains.proto */ static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) { int result = PyDict_Contains(dict, item); return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* py_dict_pop.proto */ static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value); /* UnpackUnboundCMethod.proto */ typedef struct { PyObject *type; PyObject **method_name; PyCFunction func; PyObject *method; int flag; } __Pyx_CachedCFunction; /* CallUnboundCMethod2.proto */ static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1 static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2); #else #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2) #endif /* CallUnboundCMethod1.proto */ static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg); #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg); #else #define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg) #endif /* PyFunctionFastCall.proto */ #if CYTHON_FAST_PYCALL #if !CYTHON_VECTORCALL #define __Pyx_PyFunction_FastCall(func, args, nargs)\ __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); #endif #define __Pyx_BUILD_ASSERT_EXPR(cond)\ (sizeof(char [1 - 2*!(cond)]) - 1) #ifndef Py_MEMBER_SIZE #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) #endif #if !CYTHON_VECTORCALL #if PY_VERSION_HEX >= 0x03080000 #include "frameobject.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #define __Pxy_PyFrame_Initialize_Offsets() #define __Pyx_PyFrame_GetLocalsplus(frame) ((frame)->f_localsplus) #else static size_t __pyx_pyframe_localsplus_offset = 0; #include "frameobject.h" #define __Pxy_PyFrame_Initialize_Offsets()\ ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) #define __Pyx_PyFrame_GetLocalsplus(frame)\ (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) #endif #endif #endif /* PyObjectCallMethO.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); #endif /* PyObjectFastCall.proto */ #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL) static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs); /* PyObjectCallNoArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); /* PyObjectCallOneArg.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); /* PyObjectGetMethod.proto */ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); /* PyObjectCallMethod0.proto */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name); /* RaiseNoneIterError.proto */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); /* UnpackTupleError.proto */ static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index); /* UnpackTuple2.proto */ #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\ (likely(is_tuple || PyTuple_Check(tuple)) ?\ (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\ __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\ (__Pyx_UnpackTupleError(tuple, 2), -1)) :\ __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple)) static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple); static int __Pyx_unpack_tuple2_generic( PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple); /* dict_iter.proto */ static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name, Py_ssize_t* p_orig_length, int* p_is_dict); static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos, PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict); /* MergeKeywords.proto */ static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping); /* pybytes_as_double.proto */ static double __Pyx_SlowPyString_AsDouble(PyObject *obj); static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length); static CYTHON_INLINE double __Pyx_PyBytes_AsDouble(PyObject *obj) { char* as_c_string; Py_ssize_t size; #if CYTHON_ASSUME_SAFE_MACROS as_c_string = PyBytes_AS_STRING(obj); size = PyBytes_GET_SIZE(obj); #else if (PyBytes_AsStringAndSize(obj, &as_c_string, &size) < 0) { return (double)-1; } #endif return __Pyx__PyBytes_AsDouble(obj, as_c_string, size); } static CYTHON_INLINE double __Pyx_PyByteArray_AsDouble(PyObject *obj) { char* as_c_string; Py_ssize_t size; #if CYTHON_ASSUME_SAFE_MACROS as_c_string = PyByteArray_AS_STRING(obj); size = PyByteArray_GET_SIZE(obj); #else as_c_string = PyByteArray_AsString(obj); if (as_c_string == NULL) { return (double)-1; } size = PyByteArray_Size(obj); #endif return __Pyx__PyBytes_AsDouble(obj, as_c_string, size); } /* pyunicode_as_double.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS static const char* __Pyx__PyUnicode_AsDouble_Copy(const void* data, const int kind, char* buffer, Py_ssize_t start, Py_ssize_t end) { int last_was_punctuation; Py_ssize_t i; last_was_punctuation = 1; for (i=start; i <= end; i++) { Py_UCS4 chr = PyUnicode_READ(kind, data, i); int is_punctuation = (chr == '_') | (chr == '.'); *buffer = (char)chr; buffer += (chr != '_'); if (unlikely(chr > 127)) goto parse_failure; if (unlikely(last_was_punctuation & is_punctuation)) goto parse_failure; last_was_punctuation = is_punctuation; } if (unlikely(last_was_punctuation)) goto parse_failure; *buffer = '\0'; return buffer; parse_failure: return NULL; } static double __Pyx__PyUnicode_AsDouble_inf_nan(const void* data, int kind, Py_ssize_t start, Py_ssize_t length) { int matches = 1; Py_UCS4 chr; Py_UCS4 sign = PyUnicode_READ(kind, data, start); int is_signed = (sign == '-') | (sign == '+'); start += is_signed; length -= is_signed; switch (PyUnicode_READ(kind, data, start)) { #ifdef Py_NAN case 'n': case 'N': if (unlikely(length != 3)) goto parse_failure; chr = PyUnicode_READ(kind, data, start+1); matches &= (chr == 'a') | (chr == 'A'); chr = PyUnicode_READ(kind, data, start+2); matches &= (chr == 'n') | (chr == 'N'); if (unlikely(!matches)) goto parse_failure; return (sign == '-') ? -Py_NAN : Py_NAN; #endif case 'i': case 'I': if (unlikely(length < 3)) goto parse_failure; chr = PyUnicode_READ(kind, data, start+1); matches &= (chr == 'n') | (chr == 'N'); chr = PyUnicode_READ(kind, data, start+2); matches &= (chr == 'f') | (chr == 'F'); if (likely(length == 3 && matches)) return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL; if (unlikely(length != 8)) goto parse_failure; chr = PyUnicode_READ(kind, data, start+3); matches &= (chr == 'i') | (chr == 'I'); chr = PyUnicode_READ(kind, data, start+4); matches &= (chr == 'n') | (chr == 'N'); chr = PyUnicode_READ(kind, data, start+5); matches &= (chr == 'i') | (chr == 'I'); chr = PyUnicode_READ(kind, data, start+6); matches &= (chr == 't') | (chr == 'T'); chr = PyUnicode_READ(kind, data, start+7); matches &= (chr == 'y') | (chr == 'Y'); if (unlikely(!matches)) goto parse_failure; return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL; case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': break; default: goto parse_failure; } return 0.0; parse_failure: return -1.0; } static double __Pyx_PyUnicode_AsDouble_WithSpaces(PyObject *obj) { double value; const char *last; char *end; Py_ssize_t start, length = PyUnicode_GET_LENGTH(obj); const int kind = PyUnicode_KIND(obj); const void* data = PyUnicode_DATA(obj); start = 0; while (Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, start))) start++; while (start < length - 1 && Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, length - 1))) length--; length -= start; if (unlikely(length <= 0)) goto fallback; value = __Pyx__PyUnicode_AsDouble_inf_nan(data, kind, start, length); if (unlikely(value == -1.0)) goto fallback; if (value != 0.0) return value; if (length < 40) { char number[40]; last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length); if (unlikely(!last)) goto fallback; value = PyOS_string_to_double(number, &end, NULL); } else { char *number = (char*) PyMem_Malloc((length + 1) * sizeof(char)); if (unlikely(!number)) goto fallback; last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length); if (unlikely(!last)) { PyMem_Free(number); goto fallback; } value = PyOS_string_to_double(number, &end, NULL); PyMem_Free(number); } if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) { return value; } fallback: return __Pyx_SlowPyString_AsDouble(obj); } #endif static CYTHON_INLINE double __Pyx_PyUnicode_AsDouble(PyObject *obj) { #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS if (unlikely(__Pyx_PyUnicode_READY(obj) == -1)) return (double)-1; if (likely(PyUnicode_IS_ASCII(obj))) { const char *s; Py_ssize_t length; s = PyUnicode_AsUTF8AndSize(obj, &length); return __Pyx__PyBytes_AsDouble(obj, s, length); } return __Pyx_PyUnicode_AsDouble_WithSpaces(obj); #else return __Pyx_SlowPyString_AsDouble(obj); #endif } /* pystring_as_double.proto */ static CYTHON_INLINE double __Pyx_PyString_AsDouble(PyObject *obj) { #if PY_MAJOR_VERSION >= 3 (void)__Pyx_PyBytes_AsDouble; return __Pyx_PyUnicode_AsDouble(obj); #else (void)__Pyx_PyUnicode_AsDouble; return __Pyx_PyBytes_AsDouble(obj); #endif } /* PyIntCompare.proto */ static CYTHON_INLINE int __Pyx_PyInt_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace); /* ListCompAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len)) { Py_INCREF(x); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 L->ob_item[len] = x; #else PyList_SET_ITEM(list, len, x); #endif __Pyx_SET_SIZE(list, len + 1); return 0; } return PyList_Append(list, x); } #else #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) #endif /* PyIntBinop.proto */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); #else #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) #endif /* ListAppend.proto */ #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { PyListObject* L = (PyListObject*) list; Py_ssize_t len = Py_SIZE(list); if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { Py_INCREF(x); #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 L->ob_item[len] = x; #else PyList_SET_ITEM(list, len, x); #endif __Pyx_SET_SIZE(list, len + 1); return 0; } return PyList_Append(list, x); } #else #define __Pyx_PyList_Append(L,x) PyList_Append(L,x) #endif /* GetTopmostException.proto */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); #endif /* SaveResetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); #else #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) #endif /* GetException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); #endif /* SwapException.proto */ #if CYTHON_FAST_THREAD_STATE #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); #endif /* dict_getitem_default.proto */ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value); /* StrEquals.proto */ #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals #else #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals #endif /* GetItemInt.proto */ #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ __Pyx_GetItemInt_Generic(o, to_py_func(i)))) #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* ObjectGetItem.proto */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key); #else #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) #endif /* py_dict_items.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d); /* CallUnboundCMethod0.proto */ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self); #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_CallUnboundCMethod0(cfunc, self)\ (likely((cfunc)->func) ?\ (likely((cfunc)->flag == METH_NOARGS) ? (*((cfunc)->func))(self, NULL) :\ (PY_VERSION_HEX >= 0x030600B1 && likely((cfunc)->flag == METH_FASTCALL) ?\ (PY_VERSION_HEX >= 0x030700A0 ?\ (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0) :\ (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL)) :\ (PY_VERSION_HEX >= 0x030700A0 && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ?\ (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, &__pyx_empty_tuple, 0, NULL) :\ (likely((cfunc)->flag == (METH_VARARGS | METH_KEYWORDS)) ? ((*(PyCFunctionWithKeywords)(void*)(PyCFunction)(cfunc)->func)(self, __pyx_empty_tuple, NULL)) :\ ((cfunc)->flag == METH_VARARGS ? (*((cfunc)->func))(self, __pyx_empty_tuple) :\ __Pyx__CallUnboundCMethod0(cfunc, self)))))) :\ __Pyx__CallUnboundCMethod0(cfunc, self)) #else #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self) #endif /* py_dict_keys.proto */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d); /* PySequenceContains.proto */ static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { int result = PySequence_Contains(seq, item); return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } /* PyObject_Str.proto */ #define __Pyx_PyObject_Str(obj)\ (likely(PyString_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj)) /* RaiseUnexpectedTypeError.proto */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj); /* DictGetItem.proto */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key); #define __Pyx_PyObject_Dict_GetItem(obj, name)\ (likely(PyDict_CheckExact(obj)) ?\ __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name)) #else #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name) #endif /* IncludeStructmemberH.proto */ #include /* FixUpExtensionType.proto */ #if CYTHON_USE_TYPE_SPECS static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type); #endif /* ValidateBasesTuple.proto */ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases); #endif /* PyType_Ready.proto */ CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t); /* PyObject_GenericGetAttrNoDict.proto */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr #endif /* TypeImport.proto */ #ifndef __PYX_HAVE_RT_ImportType_proto_3_0_9 #define __PYX_HAVE_RT_ImportType_proto_3_0_9 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #include #endif #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || __cplusplus >= 201103L #define __PYX_GET_STRUCT_ALIGNMENT_3_0_9(s) alignof(s) #else #define __PYX_GET_STRUCT_ALIGNMENT_3_0_9(s) sizeof(void*) #endif enum __Pyx_ImportType_CheckSize_3_0_9 { __Pyx_ImportType_CheckSize_Error_3_0_9 = 0, __Pyx_ImportType_CheckSize_Warn_3_0_9 = 1, __Pyx_ImportType_CheckSize_Ignore_3_0_9 = 2 }; static PyTypeObject *__Pyx_ImportType_3_0_9(PyObject* module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_9 check_size); #endif /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /* ImportDottedModule.proto */ static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple); #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple); #endif /* ImportDottedModuleRelFirst.proto */ static PyObject *__Pyx_ImportDottedModuleRelFirst(PyObject *name, PyObject *parts_tuple); /* ImportFrom.proto */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /* FetchSharedCythonModule.proto */ static PyObject *__Pyx_FetchSharedCythonABIModule(void); /* FetchCommonType.proto */ #if !CYTHON_USE_TYPE_SPECS static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); #else static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec *spec, PyObject *bases); #endif /* PyMethodNew.proto */ #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { PyObject *typesModule=NULL, *methodType=NULL, *result=NULL; CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); typesModule = PyImport_ImportModule("types"); if (!typesModule) return NULL; methodType = PyObject_GetAttrString(typesModule, "MethodType"); Py_DECREF(typesModule); if (!methodType) return NULL; result = PyObject_CallFunctionObjArgs(methodType, func, self, NULL); Py_DECREF(methodType); return result; } #elif PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) { CYTHON_UNUSED_VAR(typ); if (!self) return __Pyx_NewRef(func); return PyMethod_New(func, self); } #else #define __Pyx_PyMethod_New PyMethod_New #endif /* PyVectorcallFastCallDict.proto */ #if CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw); #endif /* CythonFunctionShared.proto */ #define __Pyx_CyFunction_USED #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 #define __Pyx_CYFUNCTION_COROUTINE 0x08 #define __Pyx_CyFunction_GetClosure(f)\ (((__pyx_CyFunctionObject *) (f))->func_closure) #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_GetClassObj(f)\ (((__pyx_CyFunctionObject *) (f))->func_classobj) #else #define __Pyx_CyFunction_GetClassObj(f)\ ((PyObject*) ((PyCMethodObject *) (f))->mm_class) #endif #define __Pyx_CyFunction_SetClassObj(f, classobj)\ __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj)) #define __Pyx_CyFunction_Defaults(type, f)\ ((type *)(((__pyx_CyFunctionObject *) (f))->defaults)) #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\ ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g) typedef struct { #if CYTHON_COMPILING_IN_LIMITED_API PyObject_HEAD PyObject *func; #elif PY_VERSION_HEX < 0x030900B1 PyCFunctionObject func; #else PyCMethodObject func; #endif #if CYTHON_BACKPORT_VECTORCALL __pyx_vectorcallfunc func_vectorcall; #endif #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_weakreflist; #endif PyObject *func_dict; PyObject *func_name; PyObject *func_qualname; PyObject *func_doc; PyObject *func_globals; PyObject *func_code; PyObject *func_closure; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API PyObject *func_classobj; #endif void *defaults; int defaults_pyobjects; size_t defaults_size; int flags; PyObject *defaults_tuple; PyObject *defaults_kwdict; PyObject *(*defaults_getter)(PyObject *); PyObject *func_annotations; PyObject *func_is_coroutine; } __pyx_CyFunctionObject; #undef __Pyx_CyOrPyCFunction_Check #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_CyFunctionType) #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_CyFunctionType, &PyCFunction_Type) #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_CyFunctionType) static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc); #undef __Pyx_IsSameCFunction #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc) static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj); static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m, size_t size, int pyobjects); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m, PyObject *dict); static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, PyObject *dict); static int __pyx_CyFunction_init(PyObject *module); #if CYTHON_METH_FASTCALL static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames); #if CYTHON_BACKPORT_VECTORCALL #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall) #else #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall) #endif #endif /* CythonFunction.proto */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject *globals, PyObject* code); /* CLineInTraceback.proto */ #ifdef CYTHON_CLINE_IN_TRACEBACK #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) #else static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); #endif /* CodeObjectCache.proto */ #if !CYTHON_COMPILING_IN_LIMITED_API typedef struct { PyCodeObject* code_object; int code_line; } __Pyx_CodeObjectCacheEntry; struct __Pyx_CodeObjectCache { int count; int max_count; __Pyx_CodeObjectCacheEntry* entries; }; static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); static PyCodeObject *__pyx_find_code_object(int code_line); static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); #endif /* AddTraceback.proto */ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename); /* GCCDiagnostics.proto */ #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) #define __Pyx_HAS_GCC_DIAGNOSTIC #endif /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); /* CIntToPy.proto */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); /* FormatTypeName.proto */ #if CYTHON_COMPILING_IN_LIMITED_API typedef PyObject *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%U" static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp); #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj) #else typedef const char *__Pyx_TypeName; #define __Pyx_FMT_TYPENAME "%.200s" #define __Pyx_PyType_GetName(tp) ((tp)->tp_name) #define __Pyx_DECREF_TypeName(obj) #endif /* CIntFromPy.proto */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* FastTypeChecks.proto */ #if CYTHON_COMPILING_IN_CPYTHON #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2) static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); #else #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2)) #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) #endif #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2) #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) /* PyObjectCall2Args.proto */ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); /* PyObjectCallMethod1.proto */ static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg); /* CoroutineBase.proto */ struct __pyx_CoroutineObject; typedef PyObject *(*__pyx_coroutine_body_t)(struct __pyx_CoroutineObject *, PyThreadState *, PyObject *); #if CYTHON_USE_EXC_INFO_STACK #define __Pyx_ExcInfoStruct _PyErr_StackItem #else typedef struct { PyObject *exc_type; PyObject *exc_value; PyObject *exc_traceback; } __Pyx_ExcInfoStruct; #endif typedef struct __pyx_CoroutineObject { PyObject_HEAD __pyx_coroutine_body_t body; PyObject *closure; __Pyx_ExcInfoStruct gi_exc_state; PyObject *gi_weakreflist; PyObject *classobj; PyObject *yieldfrom; PyObject *gi_name; PyObject *gi_qualname; PyObject *gi_modulename; PyObject *gi_code; PyObject *gi_frame; int resume_label; char is_running; } __pyx_CoroutineObject; static __pyx_CoroutineObject *__Pyx__Coroutine_New( PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name); static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name); static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self); static int __Pyx_Coroutine_clear(PyObject *self); static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value); static PyObject *__Pyx_Coroutine_Close(PyObject *self); static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); #if CYTHON_USE_EXC_INFO_STACK #define __Pyx_Coroutine_SwapException(self) #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state) #else #define __Pyx_Coroutine_SwapException(self) {\ __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\ __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\ } #define __Pyx_Coroutine_ResetAndClearException(self) {\ __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\ (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\ } #endif #if CYTHON_FAST_THREAD_STATE #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue) #else #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\ __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue) #endif static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue); static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state); /* PatchModuleWithCoroutine.proto */ static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code); /* PatchGeneratorABC.proto */ static int __Pyx_patch_abc(void); /* Generator.proto */ #define __Pyx_Generator_USED #define __Pyx_Generator_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_GeneratorType) #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\ __Pyx__Coroutine_New(__pyx_GeneratorType, body, code, closure, name, qualname, module_name) static PyObject *__Pyx_Generator_Next(PyObject *self); static int __pyx_Generator_init(PyObject *module); /* CheckBinaryVersion.proto */ static unsigned long __Pyx_get_runtime_version(void); static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer); /* VoidPtrImport.proto */ static int __Pyx_ImportVoidPtr_3_0_9(PyObject *module, const char *name, void **p, const char *sig); /* FunctionImport.proto */ static int __Pyx_ImportFunction_3_0_9(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /* InitStrings.proto */ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* #### Code section: module_declarations ### */ /* Module declarations from "libc.stddef" */ /* Module declarations from "pyreadstat.readstat_api" */ /* Module declarations from "pyreadstat._readstat_parser" */ static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_readstat_to_numpy_types = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_readstat_to_numpy_types (*__pyx_vp_10pyreadstat_16_readstat_parser_readstat_to_numpy_types) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_date_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_date_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_date_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_datetime_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_datetime_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_datetime_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_time_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_time_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_time_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_all_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_all_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_all_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_sas_origin = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_sas_origin (*__pyx_vp_10pyreadstat_16_readstat_parser_sas_origin) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_datetime_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_datetime_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_datetime_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_date_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_date_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_date_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_time_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_time_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_time_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_all_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_all_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_all_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_spss_origin = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_spss_origin (*__pyx_vp_10pyreadstat_16_readstat_parser_spss_origin) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_datetime_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_datetime_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_datetime_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_date_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_date_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_date_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_time_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_time_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_time_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_all_formats = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_all_formats (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_all_formats) static PyObject **__pyx_vp_10pyreadstat_16_readstat_parser_stata_origin = 0; #define __pyx_v_10pyreadstat_16_readstat_parser_stata_origin (*__pyx_vp_10pyreadstat_16_readstat_parser_stata_origin) static PyObject *(*__pyx_f_10pyreadstat_16_readstat_parser_run_conversion)(PyObject *, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format, __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension, PyObject *, int, int, PyObject *, int, int, long, long, PyObject *, PyObject *, PyObject *); /*proto*/ /* Module declarations from "pyreadstat._readstat_writer" */ static int (*__pyx_f_10pyreadstat_16_readstat_writer_run_write)(PyObject *, PyObject *, __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format, PyObject *, PyObject *, int, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int); /*proto*/ /* Module declarations from "pyreadstat.pyreadstat" */ /* #### Code section: typeinfo ### */ /* #### Code section: before_global_var ### */ #define __Pyx_MODULE_NAME "pyreadstat.pyreadstat" extern int __pyx_module_is_main_pyreadstat__pyreadstat; int __pyx_module_is_main_pyreadstat__pyreadstat = 0; /* Implementation of "pyreadstat.pyreadstat" */ /* #### Code section: global_var ### */ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_max; /* #### Code section: string_decls ### */ static const char __pyx_k_x[] = "x"; static const char __pyx_k__6[] = ""; static const char __pyx_k__8[] = "*"; static const char __pyx_k__9[] = "."; static const char __pyx_k_df[] = "df"; static const char __pyx_k_gc[] = "gc"; static const char __pyx_k_mp[] = "mp"; static const char __pyx_k_np[] = "np"; static const char __pyx_k_pd[] = "pd"; static const char __pyx_k__10[] = "_"; static const char __pyx_k__37[] = "?"; static const char __pyx_k_div[] = "div"; static const char __pyx_k_dta[] = "dta"; static const char __pyx_k_get[] = "get"; static const char __pyx_k_inf[] = "inf"; static const char __pyx_k_key[] = "key"; static const char __pyx_k_map[] = "map"; static const char __pyx_k_max[] = "max"; static const char __pyx_k_pop[] = "pop"; static const char __pyx_k_por[] = "por"; static const char __pyx_k_Pool[] = "Pool"; static const char __pyx_k_args[] = "args"; static const char __pyx_k_axis[] = "axis"; static const char __pyx_k_dict[] = "dict"; static const char __pyx_k_divs[] = "divs"; static const char __pyx_k_indx[] = "indx"; static const char __pyx_k_jobs[] = "jobs"; static const char __pyx_k_keys[] = "keys"; static const char __pyx_k_main[] = "__main__"; static const char __pyx_k_meta[] = "meta"; static const char __pyx_k_name[] = "__name__"; static const char __pyx_k_note[] = "note"; static const char __pyx_k_pool[] = "pool"; static const char __pyx_k_send[] = "send"; static const char __pyx_k_spec[] = "__spec__"; static const char __pyx_k_test[] = "__test__"; static const char __pyx_k_chunk[] = "chunk"; static const char __pyx_k_close[] = "close"; static const char __pyx_k_final[] = "final"; static const char __pyx_k_items[] = "items"; static const char __pyx_k_limit[] = "limit"; static const char __pyx_k_numpy[] = "numpy"; static const char __pyx_k_range[] = "range"; static const char __pyx_k_throw[] = "throw"; static const char __pyx_k_xport[] = "xport"; static const char __pyx_k_chunks[] = "chunks"; static const char __pyx_k_concat[] = "concat"; static const char __pyx_k_enable[] = "enable"; static const char __pyx_k_format[] = "format"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_kwargs[] = "kwargs"; static const char __pyx_k_offset[] = "offset"; static const char __pyx_k_pandas[] = "pandas"; static const char __pyx_k_worker[] = "worker"; static const char __pyx_k_catalog[] = "catalog"; static const char __pyx_k_columns[] = "columns"; static const char __pyx_k_disable[] = "disable"; static const char __pyx_k_integer[] = "integer"; static const char __pyx_k_numrows[] = "numrows"; static const char __pyx_k_offsets[] = "offsets"; static const char __pyx_k_usecols[] = "usecols"; static const char __pyx_k_usernan[] = "usernan"; static const char __pyx_k_version[] = "version"; static const char __pyx_k_col_name[] = "col_name"; static const char __pyx_k_compress[] = "compress"; static const char __pyx_k_dst_path[] = "dst_path"; static const char __pyx_k_encoding[] = "encoding"; static const char __pyx_k_metadata[] = "metadata"; static const char __pyx_k_metaonly[] = "metaonly"; static const char __pyx_k_num_rows[] = "num_rows"; static const char __pyx_k_prev_div[] = "prev_div"; static const char __pyx_k_read_dta[] = "read_dta"; static const char __pyx_k_read_por[] = "read_por"; static const char __pyx_k_read_sav[] = "read_sav"; static const char __pyx_k_sas7bcat[] = "sas7bcat"; static const char __pyx_k_sas7bdat[] = "sas7bdat"; static const char __pyx_k_sav_zsav[] = "sav/zsav"; static const char __pyx_k_chunksize[] = "chunksize"; static const char __pyx_k_cpu_count[] = "cpu_count"; static const char __pyx_k_enumerate[] = "enumerate"; static const char __pyx_k_file_path[] = "file_path"; static const char __pyx_k_isenabled[] = "isenabled"; static const char __pyx_k_processes[] = "processes"; static const char __pyx_k_row_limit[] = "row_limit"; static const char __pyx_k_var_width[] = "var_width"; static const char __pyx_k_write_dta[] = "write_dta"; static const char __pyx_k_write_por[] = "write_por"; static const char __pyx_k_write_sav[] = "write_sav"; static const char __pyx_k_col_format[] = "col_format"; static const char __pyx_k_data_frame[] = "data_frame"; static const char __pyx_k_file_label[] = "file_label"; static const char __pyx_k_read_xport[] = "read_xport"; static const char __pyx_k_row_offset[] = "row_offset"; static const char __pyx_k_table_name[] = "table_name"; static const char __pyx_k_N_var_width[] = "N{var_width}"; static const char __pyx_k_concatenate[] = "concatenate"; static const char __pyx_k_file_format[] = "file_format"; static const char __pyx_k_number_rows[] = "number_rows"; static const char __pyx_k_prev_offset[] = "prev_offset"; static const char __pyx_k_pyfunctions[] = "pyfunctions"; static const char __pyx_k_write_xport[] = "write_xport"; static const char __pyx_k_catalog_file[] = "catalog_file"; static const char __pyx_k_ignore_index[] = "ignore_index"; static const char __pyx_k_initializing[] = "_initializing"; static const char __pyx_k_is_coroutine[] = "_is_coroutine"; static const char __pyx_k_metadataonly[] = "metadataonly"; static const char __pyx_k_multiprocess[] = "multiprocess"; static const char __pyx_k_row_compress[] = "row_compress"; static const char __pyx_k_user_missing[] = "user_missing"; static const char __pyx_k_F_var_width_0[] = "F{var_width}.0"; static const char __pyx_k_class_getitem[] = "__class_getitem__"; static const char __pyx_k_column_labels[] = "column_labels"; static const char __pyx_k_filename_path[] = "filename_path"; static const char __pyx_k_num_processes[] = "num_processes"; static const char __pyx_k_output_format[] = "output_format"; static const char __pyx_k_read_function[] = "read_function"; static const char __pyx_k_read_sas7bcat[] = "read_sas7bcat"; static const char __pyx_k_read_sas7bdat[] = "read_sas7bdat"; static const char __pyx_k_file_extension[] = "file_extension"; static const char __pyx_k_missing_ranges[] = "missing_ranges"; static const char __pyx_k_PyreadstatError[] = "PyreadstatError"; static const char __pyx_k_dates_as_pandas[] = "dates_as_pandas"; static const char __pyx_k_formats_presets[] = "formats_presets"; static const char __pyx_k_multiprocessing[] = "multiprocessing"; static const char __pyx_k_readstat_parser[] = "_readstat_parser"; static const char __pyx_k_row_compression[] = "row_compression"; static const char __pyx_k_variable_format[] = "variable_format"; static const char __pyx_k_set_value_labels[] = "set_value_labels"; static const char __pyx_k_variable_measure[] = "variable_measure"; static const char __pyx_k_asyncio_coroutines[] = "asyncio.coroutines"; static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; static const char __pyx_k_extra_date_formats[] = "extra_date_formats"; static const char __pyx_k_restricted_integer[] = "restricted_integer"; static const char __pyx_k_set_catalog_to_sas[] = "set_catalog_to_sas"; static const char __pyx_k_variable_alignment[] = "variable_alignment"; static const char __pyx_k_apply_value_formats[] = "apply_value_formats"; static const char __pyx_k_file_format_version[] = "file_format_version"; static const char __pyx_k_formats_as_category[] = "formats_as_category"; static const char __pyx_k_missing_user_values[] = "missing_user_values"; static const char __pyx_k_read_file_in_chunks[] = "read_file_in_chunks"; static const char __pyx_k_Version_not_supported[] = "Version not supported"; static const char __pyx_k_pyreadstat_pyreadstat[] = "pyreadstat.pyreadstat"; static const char __pyx_k_variable_value_labels[] = "variable_value_labels"; static const char __pyx_k_extra_datetime_formats[] = "extra_datetime_formats"; static const char __pyx_k_no_datetime_conversion[] = "no_datetime_conversion"; static const char __pyx_k_variable_display_width[] = "variable_display_width"; static const char __pyx_k_dates_as_pandas_datetime[] = "dates_as_pandas_datetime"; static const char __pyx_k_pyreadstat_pyreadstat_pyx[] = "pyreadstat/pyreadstat.pyx"; static const char __pyx_k_read_file_multiprocessing[] = "read_file_multiprocessing"; static const char __pyx_k_disable_datetime_conversion[] = "disable_datetime_conversion"; static const char __pyx_k_formats_as_ordered_category[] = "formats_as_ordered_category"; static const char __pyx_k_read_sas7bcat_not_supported[] = "read_sas7bcat not supported"; static const char __pyx_k_read_sas7bcat_is_not_supported[] = "read_sas7bcat is not supported"; static const char __pyx_k_The_number_of_rows_of_the_file_c[] = "The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data"; static const char __pyx_k_compress_and_row_compress_cannot[] = "compress and row_compress cannot be both True"; static const char __pyx_k_num_rows_must_be_specified_for_r[] = "num_rows must be specified for read_xport and read_por to be a number equal or larger than the number of rows in the dataset."; /* #### Code section: decls ### */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_read_sas7bdat(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_catalog_file, PyObject *__pyx_v_formats_as_category, PyObject *__pyx_v_formats_as_ordered_category, PyObject *__pyx_v_encoding, PyObject *__pyx_v_usecols, PyObject *__pyx_v_user_missing, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_2read_xport(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_encoding, PyObject *__pyx_v_usecols, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_4read_dta(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_apply_value_formats, PyObject *__pyx_v_formats_as_category, PyObject *__pyx_v_formats_as_ordered_category, PyObject *__pyx_v_encoding, PyObject *__pyx_v_usecols, PyObject *__pyx_v_user_missing, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_6read_sav(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_apply_value_formats, PyObject *__pyx_v_formats_as_category, PyObject *__pyx_v_formats_as_ordered_category, PyObject *__pyx_v_encoding, PyObject *__pyx_v_usecols, PyObject *__pyx_v_user_missing, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_8read_por(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_apply_value_formats, PyObject *__pyx_v_formats_as_category, CYTHON_UNUSED PyObject *__pyx_v_formats_as_ordered_category, PyObject *__pyx_v_usecols, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_10read_sas7bcat(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_encoding, PyObject *__pyx_v_output_format); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_12read_file_in_chunks(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_read_function, PyObject *__pyx_v_file_path, PyObject *__pyx_v_chunksize, PyObject *__pyx_v_offset, PyObject *__pyx_v_limit, PyObject *__pyx_v_multiprocess, PyObject *__pyx_v_num_processes, PyObject *__pyx_v_num_rows, PyObject *__pyx_v_kwargs); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_15read_file_multiprocessing(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_read_function, PyObject *__pyx_v_file_path, PyObject *__pyx_v_num_processes, PyObject *__pyx_v_num_rows, PyObject *__pyx_v_kwargs); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_17write_sav(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_dst_path, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, PyObject *__pyx_v_compress, PyObject *__pyx_v_row_compress, PyObject *__pyx_v_note, PyObject *__pyx_v_variable_value_labels, PyObject *__pyx_v_missing_ranges, PyObject *__pyx_v_variable_display_width, PyObject *__pyx_v_variable_measure, PyObject *__pyx_v_variable_format); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_19write_dta(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_dst_path, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, int __pyx_v_version, PyObject *__pyx_v_variable_value_labels, PyObject *__pyx_v_missing_user_values, PyObject *__pyx_v_variable_format); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_21write_xport(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_dst_path, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, PyObject *__pyx_v_table_name, int __pyx_v_file_format_version, PyObject *__pyx_v_variable_format); /* proto */ static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_23write_por(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_dst_path, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, PyObject *__pyx_v_variable_format); /* proto */ static PyObject *__pyx_tp_new_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get = {0, 0, 0, 0, 0}; static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items = {0, 0, 0, 0, 0}; static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_keys = {0, 0, 0, 0, 0}; static __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop = {0, 0, 0, 0, 0}; /* #### Code section: late_includes ### */ /* #### Code section: module_state ### */ typedef struct { PyObject *__pyx_d; PyObject *__pyx_b; PyObject *__pyx_cython_runtime; PyObject *__pyx_empty_tuple; PyObject *__pyx_empty_bytes; PyObject *__pyx_empty_unicode; #ifdef __Pyx_CyFunction_USED PyTypeObject *__pyx_CyFunctionType; #endif #ifdef __Pyx_FusedFunction_USED PyTypeObject *__pyx_FusedFunctionType; #endif #ifdef __Pyx_Generator_USED PyTypeObject *__pyx_GeneratorType; #endif #ifdef __Pyx_IterableCoroutine_USED PyTypeObject *__pyx_IterableCoroutineType; #endif #ifdef __Pyx_Coroutine_USED PyTypeObject *__pyx_CoroutineAwaitType; #endif #ifdef __Pyx_Coroutine_USED PyTypeObject *__pyx_CoroutineType; #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif PyTypeObject *__pyx_ptype_10pyreadstat_16_readstat_parser_data_container; #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE PyObject *__pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks; #endif PyTypeObject *__pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks; PyObject *__pyx_kp_s_F_var_width_0; PyObject *__pyx_kp_s_N_var_width; PyObject *__pyx_n_s_Pool; PyObject *__pyx_n_s_PyreadstatError; PyObject *__pyx_kp_s_The_number_of_rows_of_the_file_c; PyObject *__pyx_kp_s_Version_not_supported; PyObject *__pyx_n_s__10; PyObject *__pyx_n_s__37; PyObject *__pyx_kp_s__6; PyObject *__pyx_n_s__8; PyObject *__pyx_kp_u__9; PyObject *__pyx_n_s_apply_value_formats; PyObject *__pyx_n_s_args; PyObject *__pyx_n_s_asyncio_coroutines; PyObject *__pyx_n_s_axis; PyObject *__pyx_n_s_catalog; PyObject *__pyx_n_s_catalog_file; PyObject *__pyx_n_s_chunk; PyObject *__pyx_n_s_chunks; PyObject *__pyx_n_s_chunksize; PyObject *__pyx_n_s_class_getitem; PyObject *__pyx_n_s_cline_in_traceback; PyObject *__pyx_n_s_close; PyObject *__pyx_n_s_col_format; PyObject *__pyx_n_s_col_name; PyObject *__pyx_n_s_column_labels; PyObject *__pyx_n_s_columns; PyObject *__pyx_n_s_compress; PyObject *__pyx_kp_s_compress_and_row_compress_cannot; PyObject *__pyx_n_s_concat; PyObject *__pyx_n_s_concatenate; PyObject *__pyx_n_s_cpu_count; PyObject *__pyx_n_s_data_frame; PyObject *__pyx_n_s_dates_as_pandas; PyObject *__pyx_n_s_dates_as_pandas_datetime; PyObject *__pyx_n_s_df; PyObject *__pyx_n_s_dict; PyObject *__pyx_kp_u_disable; PyObject *__pyx_n_s_disable_datetime_conversion; PyObject *__pyx_n_s_div; PyObject *__pyx_n_s_divs; PyObject *__pyx_n_s_dst_path; PyObject *__pyx_n_s_dta; PyObject *__pyx_kp_u_enable; PyObject *__pyx_n_s_encoding; PyObject *__pyx_n_s_enumerate; PyObject *__pyx_n_s_extra_date_formats; PyObject *__pyx_n_s_extra_datetime_formats; PyObject *__pyx_n_s_file_extension; PyObject *__pyx_n_s_file_format; PyObject *__pyx_n_s_file_format_version; PyObject *__pyx_n_s_file_label; PyObject *__pyx_n_s_file_path; PyObject *__pyx_n_s_filename_path; PyObject *__pyx_n_s_final; PyObject *__pyx_n_s_format; PyObject *__pyx_n_s_formats_as_category; PyObject *__pyx_n_s_formats_as_ordered_category; PyObject *__pyx_n_s_formats_presets; PyObject *__pyx_kp_u_gc; PyObject *__pyx_n_s_get; PyObject *__pyx_n_s_ignore_index; PyObject *__pyx_n_s_import; PyObject *__pyx_n_s_indx; PyObject *__pyx_n_s_inf; PyObject *__pyx_n_s_initializing; PyObject *__pyx_n_s_integer; PyObject *__pyx_n_s_is_coroutine; PyObject *__pyx_kp_u_isenabled; PyObject *__pyx_n_s_items; PyObject *__pyx_n_s_jobs; PyObject *__pyx_n_s_key; PyObject *__pyx_n_s_keys; PyObject *__pyx_n_s_kwargs; PyObject *__pyx_n_s_limit; PyObject *__pyx_n_s_main; PyObject *__pyx_n_s_map; PyObject *__pyx_n_s_max; PyObject *__pyx_n_s_meta; PyObject *__pyx_n_s_metadata; PyObject *__pyx_n_s_metadataonly; PyObject *__pyx_n_s_metaonly; PyObject *__pyx_n_s_missing_ranges; PyObject *__pyx_n_s_missing_user_values; PyObject *__pyx_n_s_mp; PyObject *__pyx_n_s_multiprocess; PyObject *__pyx_n_s_multiprocessing; PyObject *__pyx_n_s_name; PyObject *__pyx_n_s_no_datetime_conversion; PyObject *__pyx_n_s_note; PyObject *__pyx_n_s_np; PyObject *__pyx_n_s_num_processes; PyObject *__pyx_n_s_num_rows; PyObject *__pyx_kp_s_num_rows_must_be_specified_for_r; PyObject *__pyx_n_s_number_rows; PyObject *__pyx_n_s_numpy; PyObject *__pyx_n_s_numrows; PyObject *__pyx_n_s_offset; PyObject *__pyx_n_s_offsets; PyObject *__pyx_n_s_output_format; PyObject *__pyx_n_s_pandas; PyObject *__pyx_n_s_pd; PyObject *__pyx_n_s_pool; PyObject *__pyx_n_s_pop; PyObject *__pyx_n_s_por; PyObject *__pyx_n_s_prev_div; PyObject *__pyx_n_s_prev_offset; PyObject *__pyx_n_s_processes; PyObject *__pyx_n_s_pyfunctions; PyObject *__pyx_n_s_pyreadstat_pyreadstat; PyObject *__pyx_kp_s_pyreadstat_pyreadstat_pyx; PyObject *__pyx_n_s_range; PyObject *__pyx_n_s_read_dta; PyObject *__pyx_n_s_read_file_in_chunks; PyObject *__pyx_n_s_read_file_multiprocessing; PyObject *__pyx_n_s_read_function; PyObject *__pyx_n_s_read_por; PyObject *__pyx_n_s_read_sas7bcat; PyObject *__pyx_kp_s_read_sas7bcat_is_not_supported; PyObject *__pyx_kp_s_read_sas7bcat_not_supported; PyObject *__pyx_n_s_read_sas7bdat; PyObject *__pyx_n_s_read_sav; PyObject *__pyx_n_s_read_xport; PyObject *__pyx_n_s_readstat_parser; PyObject *__pyx_n_s_restricted_integer; PyObject *__pyx_n_s_row_compress; PyObject *__pyx_n_s_row_compression; PyObject *__pyx_n_s_row_limit; PyObject *__pyx_n_s_row_offset; PyObject *__pyx_n_s_sas7bcat; PyObject *__pyx_n_s_sas7bdat; PyObject *__pyx_kp_s_sav_zsav; PyObject *__pyx_n_s_send; PyObject *__pyx_n_s_set_catalog_to_sas; PyObject *__pyx_n_s_set_value_labels; PyObject *__pyx_n_s_spec; PyObject *__pyx_n_s_table_name; PyObject *__pyx_n_s_test; PyObject *__pyx_n_s_throw; PyObject *__pyx_n_s_usecols; PyObject *__pyx_n_s_user_missing; PyObject *__pyx_n_s_usernan; PyObject *__pyx_n_s_var_width; PyObject *__pyx_n_s_variable_alignment; PyObject *__pyx_n_s_variable_display_width; PyObject *__pyx_n_s_variable_format; PyObject *__pyx_n_s_variable_measure; PyObject *__pyx_n_s_variable_value_labels; PyObject *__pyx_n_s_version; PyObject *__pyx_n_s_worker; PyObject *__pyx_n_s_write_dta; PyObject *__pyx_n_s_write_por; PyObject *__pyx_n_s_write_sav; PyObject *__pyx_n_s_write_xport; PyObject *__pyx_n_s_x; PyObject *__pyx_n_s_xport; PyObject *__pyx_int_0; PyObject *__pyx_int_1; PyObject *__pyx_int_4; PyObject *__pyx_int_100000; PyObject *__pyx_codeobj_; PyObject *__pyx_tuple__2; PyObject *__pyx_tuple__3; PyObject *__pyx_tuple__4; PyObject *__pyx_tuple__5; PyObject *__pyx_tuple__7; PyObject *__pyx_tuple__11; PyObject *__pyx_tuple__13; PyObject *__pyx_tuple__15; PyObject *__pyx_tuple__18; PyObject *__pyx_tuple__20; PyObject *__pyx_tuple__22; PyObject *__pyx_tuple__23; PyObject *__pyx_tuple__24; PyObject *__pyx_tuple__25; PyObject *__pyx_tuple__27; PyObject *__pyx_tuple__29; PyObject *__pyx_tuple__30; PyObject *__pyx_tuple__32; PyObject *__pyx_tuple__34; PyObject *__pyx_tuple__36; PyObject *__pyx_codeobj__12; PyObject *__pyx_codeobj__14; PyObject *__pyx_codeobj__16; PyObject *__pyx_codeobj__17; PyObject *__pyx_codeobj__19; PyObject *__pyx_codeobj__21; PyObject *__pyx_codeobj__26; PyObject *__pyx_codeobj__28; PyObject *__pyx_codeobj__31; PyObject *__pyx_codeobj__33; PyObject *__pyx_codeobj__35; } __pyx_mstate; #if CYTHON_USE_MODULE_STATE #ifdef __cplusplus namespace { extern struct PyModuleDef __pyx_moduledef; } /* anonymous namespace */ #else static struct PyModuleDef __pyx_moduledef; #endif #define __pyx_mstate(o) ((__pyx_mstate *)__Pyx_PyModule_GetState(o)) #define __pyx_mstate_global (__pyx_mstate(PyState_FindModule(&__pyx_moduledef))) #define __pyx_m (PyState_FindModule(&__pyx_moduledef)) #else static __pyx_mstate __pyx_mstate_global_static = #ifdef __cplusplus {}; #else {0}; #endif static __pyx_mstate *__pyx_mstate_global = &__pyx_mstate_global_static; #endif /* #### Code section: module_state_clear ### */ #if CYTHON_USE_MODULE_STATE static int __pyx_m_clear(PyObject *m) { __pyx_mstate *clear_module_state = __pyx_mstate(m); if (!clear_module_state) return 0; Py_CLEAR(clear_module_state->__pyx_d); Py_CLEAR(clear_module_state->__pyx_b); Py_CLEAR(clear_module_state->__pyx_cython_runtime); Py_CLEAR(clear_module_state->__pyx_empty_tuple); Py_CLEAR(clear_module_state->__pyx_empty_bytes); Py_CLEAR(clear_module_state->__pyx_empty_unicode); #ifdef __Pyx_CyFunction_USED Py_CLEAR(clear_module_state->__pyx_CyFunctionType); #endif #ifdef __Pyx_FusedFunction_USED Py_CLEAR(clear_module_state->__pyx_FusedFunctionType); #endif Py_CLEAR(clear_module_state->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container); Py_CLEAR(clear_module_state->__pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks); Py_CLEAR(clear_module_state->__pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks); Py_CLEAR(clear_module_state->__pyx_kp_s_F_var_width_0); Py_CLEAR(clear_module_state->__pyx_kp_s_N_var_width); Py_CLEAR(clear_module_state->__pyx_n_s_Pool); Py_CLEAR(clear_module_state->__pyx_n_s_PyreadstatError); Py_CLEAR(clear_module_state->__pyx_kp_s_The_number_of_rows_of_the_file_c); Py_CLEAR(clear_module_state->__pyx_kp_s_Version_not_supported); Py_CLEAR(clear_module_state->__pyx_n_s__10); Py_CLEAR(clear_module_state->__pyx_n_s__37); Py_CLEAR(clear_module_state->__pyx_kp_s__6); Py_CLEAR(clear_module_state->__pyx_n_s__8); Py_CLEAR(clear_module_state->__pyx_kp_u__9); Py_CLEAR(clear_module_state->__pyx_n_s_apply_value_formats); Py_CLEAR(clear_module_state->__pyx_n_s_args); Py_CLEAR(clear_module_state->__pyx_n_s_asyncio_coroutines); Py_CLEAR(clear_module_state->__pyx_n_s_axis); Py_CLEAR(clear_module_state->__pyx_n_s_catalog); Py_CLEAR(clear_module_state->__pyx_n_s_catalog_file); Py_CLEAR(clear_module_state->__pyx_n_s_chunk); Py_CLEAR(clear_module_state->__pyx_n_s_chunks); Py_CLEAR(clear_module_state->__pyx_n_s_chunksize); Py_CLEAR(clear_module_state->__pyx_n_s_class_getitem); Py_CLEAR(clear_module_state->__pyx_n_s_cline_in_traceback); Py_CLEAR(clear_module_state->__pyx_n_s_close); Py_CLEAR(clear_module_state->__pyx_n_s_col_format); Py_CLEAR(clear_module_state->__pyx_n_s_col_name); Py_CLEAR(clear_module_state->__pyx_n_s_column_labels); Py_CLEAR(clear_module_state->__pyx_n_s_columns); Py_CLEAR(clear_module_state->__pyx_n_s_compress); Py_CLEAR(clear_module_state->__pyx_kp_s_compress_and_row_compress_cannot); Py_CLEAR(clear_module_state->__pyx_n_s_concat); Py_CLEAR(clear_module_state->__pyx_n_s_concatenate); Py_CLEAR(clear_module_state->__pyx_n_s_cpu_count); Py_CLEAR(clear_module_state->__pyx_n_s_data_frame); Py_CLEAR(clear_module_state->__pyx_n_s_dates_as_pandas); Py_CLEAR(clear_module_state->__pyx_n_s_dates_as_pandas_datetime); Py_CLEAR(clear_module_state->__pyx_n_s_df); Py_CLEAR(clear_module_state->__pyx_n_s_dict); Py_CLEAR(clear_module_state->__pyx_kp_u_disable); Py_CLEAR(clear_module_state->__pyx_n_s_disable_datetime_conversion); Py_CLEAR(clear_module_state->__pyx_n_s_div); Py_CLEAR(clear_module_state->__pyx_n_s_divs); Py_CLEAR(clear_module_state->__pyx_n_s_dst_path); Py_CLEAR(clear_module_state->__pyx_n_s_dta); Py_CLEAR(clear_module_state->__pyx_kp_u_enable); Py_CLEAR(clear_module_state->__pyx_n_s_encoding); Py_CLEAR(clear_module_state->__pyx_n_s_enumerate); Py_CLEAR(clear_module_state->__pyx_n_s_extra_date_formats); Py_CLEAR(clear_module_state->__pyx_n_s_extra_datetime_formats); Py_CLEAR(clear_module_state->__pyx_n_s_file_extension); Py_CLEAR(clear_module_state->__pyx_n_s_file_format); Py_CLEAR(clear_module_state->__pyx_n_s_file_format_version); Py_CLEAR(clear_module_state->__pyx_n_s_file_label); Py_CLEAR(clear_module_state->__pyx_n_s_file_path); Py_CLEAR(clear_module_state->__pyx_n_s_filename_path); Py_CLEAR(clear_module_state->__pyx_n_s_final); Py_CLEAR(clear_module_state->__pyx_n_s_format); Py_CLEAR(clear_module_state->__pyx_n_s_formats_as_category); Py_CLEAR(clear_module_state->__pyx_n_s_formats_as_ordered_category); Py_CLEAR(clear_module_state->__pyx_n_s_formats_presets); Py_CLEAR(clear_module_state->__pyx_kp_u_gc); Py_CLEAR(clear_module_state->__pyx_n_s_get); Py_CLEAR(clear_module_state->__pyx_n_s_ignore_index); Py_CLEAR(clear_module_state->__pyx_n_s_import); Py_CLEAR(clear_module_state->__pyx_n_s_indx); Py_CLEAR(clear_module_state->__pyx_n_s_inf); Py_CLEAR(clear_module_state->__pyx_n_s_initializing); Py_CLEAR(clear_module_state->__pyx_n_s_integer); Py_CLEAR(clear_module_state->__pyx_n_s_is_coroutine); Py_CLEAR(clear_module_state->__pyx_kp_u_isenabled); Py_CLEAR(clear_module_state->__pyx_n_s_items); Py_CLEAR(clear_module_state->__pyx_n_s_jobs); Py_CLEAR(clear_module_state->__pyx_n_s_key); Py_CLEAR(clear_module_state->__pyx_n_s_keys); Py_CLEAR(clear_module_state->__pyx_n_s_kwargs); Py_CLEAR(clear_module_state->__pyx_n_s_limit); Py_CLEAR(clear_module_state->__pyx_n_s_main); Py_CLEAR(clear_module_state->__pyx_n_s_map); Py_CLEAR(clear_module_state->__pyx_n_s_max); Py_CLEAR(clear_module_state->__pyx_n_s_meta); Py_CLEAR(clear_module_state->__pyx_n_s_metadata); Py_CLEAR(clear_module_state->__pyx_n_s_metadataonly); Py_CLEAR(clear_module_state->__pyx_n_s_metaonly); Py_CLEAR(clear_module_state->__pyx_n_s_missing_ranges); Py_CLEAR(clear_module_state->__pyx_n_s_missing_user_values); Py_CLEAR(clear_module_state->__pyx_n_s_mp); Py_CLEAR(clear_module_state->__pyx_n_s_multiprocess); Py_CLEAR(clear_module_state->__pyx_n_s_multiprocessing); Py_CLEAR(clear_module_state->__pyx_n_s_name); Py_CLEAR(clear_module_state->__pyx_n_s_no_datetime_conversion); Py_CLEAR(clear_module_state->__pyx_n_s_note); Py_CLEAR(clear_module_state->__pyx_n_s_np); Py_CLEAR(clear_module_state->__pyx_n_s_num_processes); Py_CLEAR(clear_module_state->__pyx_n_s_num_rows); Py_CLEAR(clear_module_state->__pyx_kp_s_num_rows_must_be_specified_for_r); Py_CLEAR(clear_module_state->__pyx_n_s_number_rows); Py_CLEAR(clear_module_state->__pyx_n_s_numpy); Py_CLEAR(clear_module_state->__pyx_n_s_numrows); Py_CLEAR(clear_module_state->__pyx_n_s_offset); Py_CLEAR(clear_module_state->__pyx_n_s_offsets); Py_CLEAR(clear_module_state->__pyx_n_s_output_format); Py_CLEAR(clear_module_state->__pyx_n_s_pandas); Py_CLEAR(clear_module_state->__pyx_n_s_pd); Py_CLEAR(clear_module_state->__pyx_n_s_pool); Py_CLEAR(clear_module_state->__pyx_n_s_pop); Py_CLEAR(clear_module_state->__pyx_n_s_por); Py_CLEAR(clear_module_state->__pyx_n_s_prev_div); Py_CLEAR(clear_module_state->__pyx_n_s_prev_offset); Py_CLEAR(clear_module_state->__pyx_n_s_processes); Py_CLEAR(clear_module_state->__pyx_n_s_pyfunctions); Py_CLEAR(clear_module_state->__pyx_n_s_pyreadstat_pyreadstat); Py_CLEAR(clear_module_state->__pyx_kp_s_pyreadstat_pyreadstat_pyx); Py_CLEAR(clear_module_state->__pyx_n_s_range); Py_CLEAR(clear_module_state->__pyx_n_s_read_dta); Py_CLEAR(clear_module_state->__pyx_n_s_read_file_in_chunks); Py_CLEAR(clear_module_state->__pyx_n_s_read_file_multiprocessing); Py_CLEAR(clear_module_state->__pyx_n_s_read_function); Py_CLEAR(clear_module_state->__pyx_n_s_read_por); Py_CLEAR(clear_module_state->__pyx_n_s_read_sas7bcat); Py_CLEAR(clear_module_state->__pyx_kp_s_read_sas7bcat_is_not_supported); Py_CLEAR(clear_module_state->__pyx_kp_s_read_sas7bcat_not_supported); Py_CLEAR(clear_module_state->__pyx_n_s_read_sas7bdat); Py_CLEAR(clear_module_state->__pyx_n_s_read_sav); Py_CLEAR(clear_module_state->__pyx_n_s_read_xport); Py_CLEAR(clear_module_state->__pyx_n_s_readstat_parser); Py_CLEAR(clear_module_state->__pyx_n_s_restricted_integer); Py_CLEAR(clear_module_state->__pyx_n_s_row_compress); Py_CLEAR(clear_module_state->__pyx_n_s_row_compression); Py_CLEAR(clear_module_state->__pyx_n_s_row_limit); Py_CLEAR(clear_module_state->__pyx_n_s_row_offset); Py_CLEAR(clear_module_state->__pyx_n_s_sas7bcat); Py_CLEAR(clear_module_state->__pyx_n_s_sas7bdat); Py_CLEAR(clear_module_state->__pyx_kp_s_sav_zsav); Py_CLEAR(clear_module_state->__pyx_n_s_send); Py_CLEAR(clear_module_state->__pyx_n_s_set_catalog_to_sas); Py_CLEAR(clear_module_state->__pyx_n_s_set_value_labels); Py_CLEAR(clear_module_state->__pyx_n_s_spec); Py_CLEAR(clear_module_state->__pyx_n_s_table_name); Py_CLEAR(clear_module_state->__pyx_n_s_test); Py_CLEAR(clear_module_state->__pyx_n_s_throw); Py_CLEAR(clear_module_state->__pyx_n_s_usecols); Py_CLEAR(clear_module_state->__pyx_n_s_user_missing); Py_CLEAR(clear_module_state->__pyx_n_s_usernan); Py_CLEAR(clear_module_state->__pyx_n_s_var_width); Py_CLEAR(clear_module_state->__pyx_n_s_variable_alignment); Py_CLEAR(clear_module_state->__pyx_n_s_variable_display_width); Py_CLEAR(clear_module_state->__pyx_n_s_variable_format); Py_CLEAR(clear_module_state->__pyx_n_s_variable_measure); Py_CLEAR(clear_module_state->__pyx_n_s_variable_value_labels); Py_CLEAR(clear_module_state->__pyx_n_s_version); Py_CLEAR(clear_module_state->__pyx_n_s_worker); Py_CLEAR(clear_module_state->__pyx_n_s_write_dta); Py_CLEAR(clear_module_state->__pyx_n_s_write_por); Py_CLEAR(clear_module_state->__pyx_n_s_write_sav); Py_CLEAR(clear_module_state->__pyx_n_s_write_xport); Py_CLEAR(clear_module_state->__pyx_n_s_x); Py_CLEAR(clear_module_state->__pyx_n_s_xport); Py_CLEAR(clear_module_state->__pyx_int_0); Py_CLEAR(clear_module_state->__pyx_int_1); Py_CLEAR(clear_module_state->__pyx_int_4); Py_CLEAR(clear_module_state->__pyx_int_100000); Py_CLEAR(clear_module_state->__pyx_codeobj_); Py_CLEAR(clear_module_state->__pyx_tuple__2); Py_CLEAR(clear_module_state->__pyx_tuple__3); Py_CLEAR(clear_module_state->__pyx_tuple__4); Py_CLEAR(clear_module_state->__pyx_tuple__5); Py_CLEAR(clear_module_state->__pyx_tuple__7); Py_CLEAR(clear_module_state->__pyx_tuple__11); Py_CLEAR(clear_module_state->__pyx_tuple__13); Py_CLEAR(clear_module_state->__pyx_tuple__15); Py_CLEAR(clear_module_state->__pyx_tuple__18); Py_CLEAR(clear_module_state->__pyx_tuple__20); Py_CLEAR(clear_module_state->__pyx_tuple__22); Py_CLEAR(clear_module_state->__pyx_tuple__23); Py_CLEAR(clear_module_state->__pyx_tuple__24); Py_CLEAR(clear_module_state->__pyx_tuple__25); Py_CLEAR(clear_module_state->__pyx_tuple__27); Py_CLEAR(clear_module_state->__pyx_tuple__29); Py_CLEAR(clear_module_state->__pyx_tuple__30); Py_CLEAR(clear_module_state->__pyx_tuple__32); Py_CLEAR(clear_module_state->__pyx_tuple__34); Py_CLEAR(clear_module_state->__pyx_tuple__36); Py_CLEAR(clear_module_state->__pyx_codeobj__12); Py_CLEAR(clear_module_state->__pyx_codeobj__14); Py_CLEAR(clear_module_state->__pyx_codeobj__16); Py_CLEAR(clear_module_state->__pyx_codeobj__17); Py_CLEAR(clear_module_state->__pyx_codeobj__19); Py_CLEAR(clear_module_state->__pyx_codeobj__21); Py_CLEAR(clear_module_state->__pyx_codeobj__26); Py_CLEAR(clear_module_state->__pyx_codeobj__28); Py_CLEAR(clear_module_state->__pyx_codeobj__31); Py_CLEAR(clear_module_state->__pyx_codeobj__33); Py_CLEAR(clear_module_state->__pyx_codeobj__35); return 0; } #endif /* #### Code section: module_state_traverse ### */ #if CYTHON_USE_MODULE_STATE static int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) { __pyx_mstate *traverse_module_state = __pyx_mstate(m); if (!traverse_module_state) return 0; Py_VISIT(traverse_module_state->__pyx_d); Py_VISIT(traverse_module_state->__pyx_b); Py_VISIT(traverse_module_state->__pyx_cython_runtime); Py_VISIT(traverse_module_state->__pyx_empty_tuple); Py_VISIT(traverse_module_state->__pyx_empty_bytes); Py_VISIT(traverse_module_state->__pyx_empty_unicode); #ifdef __Pyx_CyFunction_USED Py_VISIT(traverse_module_state->__pyx_CyFunctionType); #endif #ifdef __Pyx_FusedFunction_USED Py_VISIT(traverse_module_state->__pyx_FusedFunctionType); #endif Py_VISIT(traverse_module_state->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container); Py_VISIT(traverse_module_state->__pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks); Py_VISIT(traverse_module_state->__pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks); Py_VISIT(traverse_module_state->__pyx_kp_s_F_var_width_0); Py_VISIT(traverse_module_state->__pyx_kp_s_N_var_width); Py_VISIT(traverse_module_state->__pyx_n_s_Pool); Py_VISIT(traverse_module_state->__pyx_n_s_PyreadstatError); Py_VISIT(traverse_module_state->__pyx_kp_s_The_number_of_rows_of_the_file_c); Py_VISIT(traverse_module_state->__pyx_kp_s_Version_not_supported); Py_VISIT(traverse_module_state->__pyx_n_s__10); Py_VISIT(traverse_module_state->__pyx_n_s__37); Py_VISIT(traverse_module_state->__pyx_kp_s__6); Py_VISIT(traverse_module_state->__pyx_n_s__8); Py_VISIT(traverse_module_state->__pyx_kp_u__9); Py_VISIT(traverse_module_state->__pyx_n_s_apply_value_formats); Py_VISIT(traverse_module_state->__pyx_n_s_args); Py_VISIT(traverse_module_state->__pyx_n_s_asyncio_coroutines); Py_VISIT(traverse_module_state->__pyx_n_s_axis); Py_VISIT(traverse_module_state->__pyx_n_s_catalog); Py_VISIT(traverse_module_state->__pyx_n_s_catalog_file); Py_VISIT(traverse_module_state->__pyx_n_s_chunk); Py_VISIT(traverse_module_state->__pyx_n_s_chunks); Py_VISIT(traverse_module_state->__pyx_n_s_chunksize); Py_VISIT(traverse_module_state->__pyx_n_s_class_getitem); Py_VISIT(traverse_module_state->__pyx_n_s_cline_in_traceback); Py_VISIT(traverse_module_state->__pyx_n_s_close); Py_VISIT(traverse_module_state->__pyx_n_s_col_format); Py_VISIT(traverse_module_state->__pyx_n_s_col_name); Py_VISIT(traverse_module_state->__pyx_n_s_column_labels); Py_VISIT(traverse_module_state->__pyx_n_s_columns); Py_VISIT(traverse_module_state->__pyx_n_s_compress); Py_VISIT(traverse_module_state->__pyx_kp_s_compress_and_row_compress_cannot); Py_VISIT(traverse_module_state->__pyx_n_s_concat); Py_VISIT(traverse_module_state->__pyx_n_s_concatenate); Py_VISIT(traverse_module_state->__pyx_n_s_cpu_count); Py_VISIT(traverse_module_state->__pyx_n_s_data_frame); Py_VISIT(traverse_module_state->__pyx_n_s_dates_as_pandas); Py_VISIT(traverse_module_state->__pyx_n_s_dates_as_pandas_datetime); Py_VISIT(traverse_module_state->__pyx_n_s_df); Py_VISIT(traverse_module_state->__pyx_n_s_dict); Py_VISIT(traverse_module_state->__pyx_kp_u_disable); Py_VISIT(traverse_module_state->__pyx_n_s_disable_datetime_conversion); Py_VISIT(traverse_module_state->__pyx_n_s_div); Py_VISIT(traverse_module_state->__pyx_n_s_divs); Py_VISIT(traverse_module_state->__pyx_n_s_dst_path); Py_VISIT(traverse_module_state->__pyx_n_s_dta); Py_VISIT(traverse_module_state->__pyx_kp_u_enable); Py_VISIT(traverse_module_state->__pyx_n_s_encoding); Py_VISIT(traverse_module_state->__pyx_n_s_enumerate); Py_VISIT(traverse_module_state->__pyx_n_s_extra_date_formats); Py_VISIT(traverse_module_state->__pyx_n_s_extra_datetime_formats); Py_VISIT(traverse_module_state->__pyx_n_s_file_extension); Py_VISIT(traverse_module_state->__pyx_n_s_file_format); Py_VISIT(traverse_module_state->__pyx_n_s_file_format_version); Py_VISIT(traverse_module_state->__pyx_n_s_file_label); Py_VISIT(traverse_module_state->__pyx_n_s_file_path); Py_VISIT(traverse_module_state->__pyx_n_s_filename_path); Py_VISIT(traverse_module_state->__pyx_n_s_final); Py_VISIT(traverse_module_state->__pyx_n_s_format); Py_VISIT(traverse_module_state->__pyx_n_s_formats_as_category); Py_VISIT(traverse_module_state->__pyx_n_s_formats_as_ordered_category); Py_VISIT(traverse_module_state->__pyx_n_s_formats_presets); Py_VISIT(traverse_module_state->__pyx_kp_u_gc); Py_VISIT(traverse_module_state->__pyx_n_s_get); Py_VISIT(traverse_module_state->__pyx_n_s_ignore_index); Py_VISIT(traverse_module_state->__pyx_n_s_import); Py_VISIT(traverse_module_state->__pyx_n_s_indx); Py_VISIT(traverse_module_state->__pyx_n_s_inf); Py_VISIT(traverse_module_state->__pyx_n_s_initializing); Py_VISIT(traverse_module_state->__pyx_n_s_integer); Py_VISIT(traverse_module_state->__pyx_n_s_is_coroutine); Py_VISIT(traverse_module_state->__pyx_kp_u_isenabled); Py_VISIT(traverse_module_state->__pyx_n_s_items); Py_VISIT(traverse_module_state->__pyx_n_s_jobs); Py_VISIT(traverse_module_state->__pyx_n_s_key); Py_VISIT(traverse_module_state->__pyx_n_s_keys); Py_VISIT(traverse_module_state->__pyx_n_s_kwargs); Py_VISIT(traverse_module_state->__pyx_n_s_limit); Py_VISIT(traverse_module_state->__pyx_n_s_main); Py_VISIT(traverse_module_state->__pyx_n_s_map); Py_VISIT(traverse_module_state->__pyx_n_s_max); Py_VISIT(traverse_module_state->__pyx_n_s_meta); Py_VISIT(traverse_module_state->__pyx_n_s_metadata); Py_VISIT(traverse_module_state->__pyx_n_s_metadataonly); Py_VISIT(traverse_module_state->__pyx_n_s_metaonly); Py_VISIT(traverse_module_state->__pyx_n_s_missing_ranges); Py_VISIT(traverse_module_state->__pyx_n_s_missing_user_values); Py_VISIT(traverse_module_state->__pyx_n_s_mp); Py_VISIT(traverse_module_state->__pyx_n_s_multiprocess); Py_VISIT(traverse_module_state->__pyx_n_s_multiprocessing); Py_VISIT(traverse_module_state->__pyx_n_s_name); Py_VISIT(traverse_module_state->__pyx_n_s_no_datetime_conversion); Py_VISIT(traverse_module_state->__pyx_n_s_note); Py_VISIT(traverse_module_state->__pyx_n_s_np); Py_VISIT(traverse_module_state->__pyx_n_s_num_processes); Py_VISIT(traverse_module_state->__pyx_n_s_num_rows); Py_VISIT(traverse_module_state->__pyx_kp_s_num_rows_must_be_specified_for_r); Py_VISIT(traverse_module_state->__pyx_n_s_number_rows); Py_VISIT(traverse_module_state->__pyx_n_s_numpy); Py_VISIT(traverse_module_state->__pyx_n_s_numrows); Py_VISIT(traverse_module_state->__pyx_n_s_offset); Py_VISIT(traverse_module_state->__pyx_n_s_offsets); Py_VISIT(traverse_module_state->__pyx_n_s_output_format); Py_VISIT(traverse_module_state->__pyx_n_s_pandas); Py_VISIT(traverse_module_state->__pyx_n_s_pd); Py_VISIT(traverse_module_state->__pyx_n_s_pool); Py_VISIT(traverse_module_state->__pyx_n_s_pop); Py_VISIT(traverse_module_state->__pyx_n_s_por); Py_VISIT(traverse_module_state->__pyx_n_s_prev_div); Py_VISIT(traverse_module_state->__pyx_n_s_prev_offset); Py_VISIT(traverse_module_state->__pyx_n_s_processes); Py_VISIT(traverse_module_state->__pyx_n_s_pyfunctions); Py_VISIT(traverse_module_state->__pyx_n_s_pyreadstat_pyreadstat); Py_VISIT(traverse_module_state->__pyx_kp_s_pyreadstat_pyreadstat_pyx); Py_VISIT(traverse_module_state->__pyx_n_s_range); Py_VISIT(traverse_module_state->__pyx_n_s_read_dta); Py_VISIT(traverse_module_state->__pyx_n_s_read_file_in_chunks); Py_VISIT(traverse_module_state->__pyx_n_s_read_file_multiprocessing); Py_VISIT(traverse_module_state->__pyx_n_s_read_function); Py_VISIT(traverse_module_state->__pyx_n_s_read_por); Py_VISIT(traverse_module_state->__pyx_n_s_read_sas7bcat); Py_VISIT(traverse_module_state->__pyx_kp_s_read_sas7bcat_is_not_supported); Py_VISIT(traverse_module_state->__pyx_kp_s_read_sas7bcat_not_supported); Py_VISIT(traverse_module_state->__pyx_n_s_read_sas7bdat); Py_VISIT(traverse_module_state->__pyx_n_s_read_sav); Py_VISIT(traverse_module_state->__pyx_n_s_read_xport); Py_VISIT(traverse_module_state->__pyx_n_s_readstat_parser); Py_VISIT(traverse_module_state->__pyx_n_s_restricted_integer); Py_VISIT(traverse_module_state->__pyx_n_s_row_compress); Py_VISIT(traverse_module_state->__pyx_n_s_row_compression); Py_VISIT(traverse_module_state->__pyx_n_s_row_limit); Py_VISIT(traverse_module_state->__pyx_n_s_row_offset); Py_VISIT(traverse_module_state->__pyx_n_s_sas7bcat); Py_VISIT(traverse_module_state->__pyx_n_s_sas7bdat); Py_VISIT(traverse_module_state->__pyx_kp_s_sav_zsav); Py_VISIT(traverse_module_state->__pyx_n_s_send); Py_VISIT(traverse_module_state->__pyx_n_s_set_catalog_to_sas); Py_VISIT(traverse_module_state->__pyx_n_s_set_value_labels); Py_VISIT(traverse_module_state->__pyx_n_s_spec); Py_VISIT(traverse_module_state->__pyx_n_s_table_name); Py_VISIT(traverse_module_state->__pyx_n_s_test); Py_VISIT(traverse_module_state->__pyx_n_s_throw); Py_VISIT(traverse_module_state->__pyx_n_s_usecols); Py_VISIT(traverse_module_state->__pyx_n_s_user_missing); Py_VISIT(traverse_module_state->__pyx_n_s_usernan); Py_VISIT(traverse_module_state->__pyx_n_s_var_width); Py_VISIT(traverse_module_state->__pyx_n_s_variable_alignment); Py_VISIT(traverse_module_state->__pyx_n_s_variable_display_width); Py_VISIT(traverse_module_state->__pyx_n_s_variable_format); Py_VISIT(traverse_module_state->__pyx_n_s_variable_measure); Py_VISIT(traverse_module_state->__pyx_n_s_variable_value_labels); Py_VISIT(traverse_module_state->__pyx_n_s_version); Py_VISIT(traverse_module_state->__pyx_n_s_worker); Py_VISIT(traverse_module_state->__pyx_n_s_write_dta); Py_VISIT(traverse_module_state->__pyx_n_s_write_por); Py_VISIT(traverse_module_state->__pyx_n_s_write_sav); Py_VISIT(traverse_module_state->__pyx_n_s_write_xport); Py_VISIT(traverse_module_state->__pyx_n_s_x); Py_VISIT(traverse_module_state->__pyx_n_s_xport); Py_VISIT(traverse_module_state->__pyx_int_0); Py_VISIT(traverse_module_state->__pyx_int_1); Py_VISIT(traverse_module_state->__pyx_int_4); Py_VISIT(traverse_module_state->__pyx_int_100000); Py_VISIT(traverse_module_state->__pyx_codeobj_); Py_VISIT(traverse_module_state->__pyx_tuple__2); Py_VISIT(traverse_module_state->__pyx_tuple__3); Py_VISIT(traverse_module_state->__pyx_tuple__4); Py_VISIT(traverse_module_state->__pyx_tuple__5); Py_VISIT(traverse_module_state->__pyx_tuple__7); Py_VISIT(traverse_module_state->__pyx_tuple__11); Py_VISIT(traverse_module_state->__pyx_tuple__13); Py_VISIT(traverse_module_state->__pyx_tuple__15); Py_VISIT(traverse_module_state->__pyx_tuple__18); Py_VISIT(traverse_module_state->__pyx_tuple__20); Py_VISIT(traverse_module_state->__pyx_tuple__22); Py_VISIT(traverse_module_state->__pyx_tuple__23); Py_VISIT(traverse_module_state->__pyx_tuple__24); Py_VISIT(traverse_module_state->__pyx_tuple__25); Py_VISIT(traverse_module_state->__pyx_tuple__27); Py_VISIT(traverse_module_state->__pyx_tuple__29); Py_VISIT(traverse_module_state->__pyx_tuple__30); Py_VISIT(traverse_module_state->__pyx_tuple__32); Py_VISIT(traverse_module_state->__pyx_tuple__34); Py_VISIT(traverse_module_state->__pyx_tuple__36); Py_VISIT(traverse_module_state->__pyx_codeobj__12); Py_VISIT(traverse_module_state->__pyx_codeobj__14); Py_VISIT(traverse_module_state->__pyx_codeobj__16); Py_VISIT(traverse_module_state->__pyx_codeobj__17); Py_VISIT(traverse_module_state->__pyx_codeobj__19); Py_VISIT(traverse_module_state->__pyx_codeobj__21); Py_VISIT(traverse_module_state->__pyx_codeobj__26); Py_VISIT(traverse_module_state->__pyx_codeobj__28); Py_VISIT(traverse_module_state->__pyx_codeobj__31); Py_VISIT(traverse_module_state->__pyx_codeobj__33); Py_VISIT(traverse_module_state->__pyx_codeobj__35); return 0; } #endif /* #### Code section: module_state_defines ### */ #define __pyx_d __pyx_mstate_global->__pyx_d #define __pyx_b __pyx_mstate_global->__pyx_b #define __pyx_cython_runtime __pyx_mstate_global->__pyx_cython_runtime #define __pyx_empty_tuple __pyx_mstate_global->__pyx_empty_tuple #define __pyx_empty_bytes __pyx_mstate_global->__pyx_empty_bytes #define __pyx_empty_unicode __pyx_mstate_global->__pyx_empty_unicode #ifdef __Pyx_CyFunction_USED #define __pyx_CyFunctionType __pyx_mstate_global->__pyx_CyFunctionType #endif #ifdef __Pyx_FusedFunction_USED #define __pyx_FusedFunctionType __pyx_mstate_global->__pyx_FusedFunctionType #endif #ifdef __Pyx_Generator_USED #define __pyx_GeneratorType __pyx_mstate_global->__pyx_GeneratorType #endif #ifdef __Pyx_IterableCoroutine_USED #define __pyx_IterableCoroutineType __pyx_mstate_global->__pyx_IterableCoroutineType #endif #ifdef __Pyx_Coroutine_USED #define __pyx_CoroutineAwaitType __pyx_mstate_global->__pyx_CoroutineAwaitType #endif #ifdef __Pyx_Coroutine_USED #define __pyx_CoroutineType __pyx_mstate_global->__pyx_CoroutineType #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #endif #define __pyx_ptype_10pyreadstat_16_readstat_parser_data_container __pyx_mstate_global->__pyx_ptype_10pyreadstat_16_readstat_parser_data_container #if CYTHON_USE_MODULE_STATE #endif #if CYTHON_USE_MODULE_STATE #define __pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks __pyx_mstate_global->__pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks #endif #define __pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks __pyx_mstate_global->__pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks #define __pyx_kp_s_F_var_width_0 __pyx_mstate_global->__pyx_kp_s_F_var_width_0 #define __pyx_kp_s_N_var_width __pyx_mstate_global->__pyx_kp_s_N_var_width #define __pyx_n_s_Pool __pyx_mstate_global->__pyx_n_s_Pool #define __pyx_n_s_PyreadstatError __pyx_mstate_global->__pyx_n_s_PyreadstatError #define __pyx_kp_s_The_number_of_rows_of_the_file_c __pyx_mstate_global->__pyx_kp_s_The_number_of_rows_of_the_file_c #define __pyx_kp_s_Version_not_supported __pyx_mstate_global->__pyx_kp_s_Version_not_supported #define __pyx_n_s__10 __pyx_mstate_global->__pyx_n_s__10 #define __pyx_n_s__37 __pyx_mstate_global->__pyx_n_s__37 #define __pyx_kp_s__6 __pyx_mstate_global->__pyx_kp_s__6 #define __pyx_n_s__8 __pyx_mstate_global->__pyx_n_s__8 #define __pyx_kp_u__9 __pyx_mstate_global->__pyx_kp_u__9 #define __pyx_n_s_apply_value_formats __pyx_mstate_global->__pyx_n_s_apply_value_formats #define __pyx_n_s_args __pyx_mstate_global->__pyx_n_s_args #define __pyx_n_s_asyncio_coroutines __pyx_mstate_global->__pyx_n_s_asyncio_coroutines #define __pyx_n_s_axis __pyx_mstate_global->__pyx_n_s_axis #define __pyx_n_s_catalog __pyx_mstate_global->__pyx_n_s_catalog #define __pyx_n_s_catalog_file __pyx_mstate_global->__pyx_n_s_catalog_file #define __pyx_n_s_chunk __pyx_mstate_global->__pyx_n_s_chunk #define __pyx_n_s_chunks __pyx_mstate_global->__pyx_n_s_chunks #define __pyx_n_s_chunksize __pyx_mstate_global->__pyx_n_s_chunksize #define __pyx_n_s_class_getitem __pyx_mstate_global->__pyx_n_s_class_getitem #define __pyx_n_s_cline_in_traceback __pyx_mstate_global->__pyx_n_s_cline_in_traceback #define __pyx_n_s_close __pyx_mstate_global->__pyx_n_s_close #define __pyx_n_s_col_format __pyx_mstate_global->__pyx_n_s_col_format #define __pyx_n_s_col_name __pyx_mstate_global->__pyx_n_s_col_name #define __pyx_n_s_column_labels __pyx_mstate_global->__pyx_n_s_column_labels #define __pyx_n_s_columns __pyx_mstate_global->__pyx_n_s_columns #define __pyx_n_s_compress __pyx_mstate_global->__pyx_n_s_compress #define __pyx_kp_s_compress_and_row_compress_cannot __pyx_mstate_global->__pyx_kp_s_compress_and_row_compress_cannot #define __pyx_n_s_concat __pyx_mstate_global->__pyx_n_s_concat #define __pyx_n_s_concatenate __pyx_mstate_global->__pyx_n_s_concatenate #define __pyx_n_s_cpu_count __pyx_mstate_global->__pyx_n_s_cpu_count #define __pyx_n_s_data_frame __pyx_mstate_global->__pyx_n_s_data_frame #define __pyx_n_s_dates_as_pandas __pyx_mstate_global->__pyx_n_s_dates_as_pandas #define __pyx_n_s_dates_as_pandas_datetime __pyx_mstate_global->__pyx_n_s_dates_as_pandas_datetime #define __pyx_n_s_df __pyx_mstate_global->__pyx_n_s_df #define __pyx_n_s_dict __pyx_mstate_global->__pyx_n_s_dict #define __pyx_kp_u_disable __pyx_mstate_global->__pyx_kp_u_disable #define __pyx_n_s_disable_datetime_conversion __pyx_mstate_global->__pyx_n_s_disable_datetime_conversion #define __pyx_n_s_div __pyx_mstate_global->__pyx_n_s_div #define __pyx_n_s_divs __pyx_mstate_global->__pyx_n_s_divs #define __pyx_n_s_dst_path __pyx_mstate_global->__pyx_n_s_dst_path #define __pyx_n_s_dta __pyx_mstate_global->__pyx_n_s_dta #define __pyx_kp_u_enable __pyx_mstate_global->__pyx_kp_u_enable #define __pyx_n_s_encoding __pyx_mstate_global->__pyx_n_s_encoding #define __pyx_n_s_enumerate __pyx_mstate_global->__pyx_n_s_enumerate #define __pyx_n_s_extra_date_formats __pyx_mstate_global->__pyx_n_s_extra_date_formats #define __pyx_n_s_extra_datetime_formats __pyx_mstate_global->__pyx_n_s_extra_datetime_formats #define __pyx_n_s_file_extension __pyx_mstate_global->__pyx_n_s_file_extension #define __pyx_n_s_file_format __pyx_mstate_global->__pyx_n_s_file_format #define __pyx_n_s_file_format_version __pyx_mstate_global->__pyx_n_s_file_format_version #define __pyx_n_s_file_label __pyx_mstate_global->__pyx_n_s_file_label #define __pyx_n_s_file_path __pyx_mstate_global->__pyx_n_s_file_path #define __pyx_n_s_filename_path __pyx_mstate_global->__pyx_n_s_filename_path #define __pyx_n_s_final __pyx_mstate_global->__pyx_n_s_final #define __pyx_n_s_format __pyx_mstate_global->__pyx_n_s_format #define __pyx_n_s_formats_as_category __pyx_mstate_global->__pyx_n_s_formats_as_category #define __pyx_n_s_formats_as_ordered_category __pyx_mstate_global->__pyx_n_s_formats_as_ordered_category #define __pyx_n_s_formats_presets __pyx_mstate_global->__pyx_n_s_formats_presets #define __pyx_kp_u_gc __pyx_mstate_global->__pyx_kp_u_gc #define __pyx_n_s_get __pyx_mstate_global->__pyx_n_s_get #define __pyx_n_s_ignore_index __pyx_mstate_global->__pyx_n_s_ignore_index #define __pyx_n_s_import __pyx_mstate_global->__pyx_n_s_import #define __pyx_n_s_indx __pyx_mstate_global->__pyx_n_s_indx #define __pyx_n_s_inf __pyx_mstate_global->__pyx_n_s_inf #define __pyx_n_s_initializing __pyx_mstate_global->__pyx_n_s_initializing #define __pyx_n_s_integer __pyx_mstate_global->__pyx_n_s_integer #define __pyx_n_s_is_coroutine __pyx_mstate_global->__pyx_n_s_is_coroutine #define __pyx_kp_u_isenabled __pyx_mstate_global->__pyx_kp_u_isenabled #define __pyx_n_s_items __pyx_mstate_global->__pyx_n_s_items #define __pyx_n_s_jobs __pyx_mstate_global->__pyx_n_s_jobs #define __pyx_n_s_key __pyx_mstate_global->__pyx_n_s_key #define __pyx_n_s_keys __pyx_mstate_global->__pyx_n_s_keys #define __pyx_n_s_kwargs __pyx_mstate_global->__pyx_n_s_kwargs #define __pyx_n_s_limit __pyx_mstate_global->__pyx_n_s_limit #define __pyx_n_s_main __pyx_mstate_global->__pyx_n_s_main #define __pyx_n_s_map __pyx_mstate_global->__pyx_n_s_map #define __pyx_n_s_max __pyx_mstate_global->__pyx_n_s_max #define __pyx_n_s_meta __pyx_mstate_global->__pyx_n_s_meta #define __pyx_n_s_metadata __pyx_mstate_global->__pyx_n_s_metadata #define __pyx_n_s_metadataonly __pyx_mstate_global->__pyx_n_s_metadataonly #define __pyx_n_s_metaonly __pyx_mstate_global->__pyx_n_s_metaonly #define __pyx_n_s_missing_ranges __pyx_mstate_global->__pyx_n_s_missing_ranges #define __pyx_n_s_missing_user_values __pyx_mstate_global->__pyx_n_s_missing_user_values #define __pyx_n_s_mp __pyx_mstate_global->__pyx_n_s_mp #define __pyx_n_s_multiprocess __pyx_mstate_global->__pyx_n_s_multiprocess #define __pyx_n_s_multiprocessing __pyx_mstate_global->__pyx_n_s_multiprocessing #define __pyx_n_s_name __pyx_mstate_global->__pyx_n_s_name #define __pyx_n_s_no_datetime_conversion __pyx_mstate_global->__pyx_n_s_no_datetime_conversion #define __pyx_n_s_note __pyx_mstate_global->__pyx_n_s_note #define __pyx_n_s_np __pyx_mstate_global->__pyx_n_s_np #define __pyx_n_s_num_processes __pyx_mstate_global->__pyx_n_s_num_processes #define __pyx_n_s_num_rows __pyx_mstate_global->__pyx_n_s_num_rows #define __pyx_kp_s_num_rows_must_be_specified_for_r __pyx_mstate_global->__pyx_kp_s_num_rows_must_be_specified_for_r #define __pyx_n_s_number_rows __pyx_mstate_global->__pyx_n_s_number_rows #define __pyx_n_s_numpy __pyx_mstate_global->__pyx_n_s_numpy #define __pyx_n_s_numrows __pyx_mstate_global->__pyx_n_s_numrows #define __pyx_n_s_offset __pyx_mstate_global->__pyx_n_s_offset #define __pyx_n_s_offsets __pyx_mstate_global->__pyx_n_s_offsets #define __pyx_n_s_output_format __pyx_mstate_global->__pyx_n_s_output_format #define __pyx_n_s_pandas __pyx_mstate_global->__pyx_n_s_pandas #define __pyx_n_s_pd __pyx_mstate_global->__pyx_n_s_pd #define __pyx_n_s_pool __pyx_mstate_global->__pyx_n_s_pool #define __pyx_n_s_pop __pyx_mstate_global->__pyx_n_s_pop #define __pyx_n_s_por __pyx_mstate_global->__pyx_n_s_por #define __pyx_n_s_prev_div __pyx_mstate_global->__pyx_n_s_prev_div #define __pyx_n_s_prev_offset __pyx_mstate_global->__pyx_n_s_prev_offset #define __pyx_n_s_processes __pyx_mstate_global->__pyx_n_s_processes #define __pyx_n_s_pyfunctions __pyx_mstate_global->__pyx_n_s_pyfunctions #define __pyx_n_s_pyreadstat_pyreadstat __pyx_mstate_global->__pyx_n_s_pyreadstat_pyreadstat #define __pyx_kp_s_pyreadstat_pyreadstat_pyx __pyx_mstate_global->__pyx_kp_s_pyreadstat_pyreadstat_pyx #define __pyx_n_s_range __pyx_mstate_global->__pyx_n_s_range #define __pyx_n_s_read_dta __pyx_mstate_global->__pyx_n_s_read_dta #define __pyx_n_s_read_file_in_chunks __pyx_mstate_global->__pyx_n_s_read_file_in_chunks #define __pyx_n_s_read_file_multiprocessing __pyx_mstate_global->__pyx_n_s_read_file_multiprocessing #define __pyx_n_s_read_function __pyx_mstate_global->__pyx_n_s_read_function #define __pyx_n_s_read_por __pyx_mstate_global->__pyx_n_s_read_por #define __pyx_n_s_read_sas7bcat __pyx_mstate_global->__pyx_n_s_read_sas7bcat #define __pyx_kp_s_read_sas7bcat_is_not_supported __pyx_mstate_global->__pyx_kp_s_read_sas7bcat_is_not_supported #define __pyx_kp_s_read_sas7bcat_not_supported __pyx_mstate_global->__pyx_kp_s_read_sas7bcat_not_supported #define __pyx_n_s_read_sas7bdat __pyx_mstate_global->__pyx_n_s_read_sas7bdat #define __pyx_n_s_read_sav __pyx_mstate_global->__pyx_n_s_read_sav #define __pyx_n_s_read_xport __pyx_mstate_global->__pyx_n_s_read_xport #define __pyx_n_s_readstat_parser __pyx_mstate_global->__pyx_n_s_readstat_parser #define __pyx_n_s_restricted_integer __pyx_mstate_global->__pyx_n_s_restricted_integer #define __pyx_n_s_row_compress __pyx_mstate_global->__pyx_n_s_row_compress #define __pyx_n_s_row_compression __pyx_mstate_global->__pyx_n_s_row_compression #define __pyx_n_s_row_limit __pyx_mstate_global->__pyx_n_s_row_limit #define __pyx_n_s_row_offset __pyx_mstate_global->__pyx_n_s_row_offset #define __pyx_n_s_sas7bcat __pyx_mstate_global->__pyx_n_s_sas7bcat #define __pyx_n_s_sas7bdat __pyx_mstate_global->__pyx_n_s_sas7bdat #define __pyx_kp_s_sav_zsav __pyx_mstate_global->__pyx_kp_s_sav_zsav #define __pyx_n_s_send __pyx_mstate_global->__pyx_n_s_send #define __pyx_n_s_set_catalog_to_sas __pyx_mstate_global->__pyx_n_s_set_catalog_to_sas #define __pyx_n_s_set_value_labels __pyx_mstate_global->__pyx_n_s_set_value_labels #define __pyx_n_s_spec __pyx_mstate_global->__pyx_n_s_spec #define __pyx_n_s_table_name __pyx_mstate_global->__pyx_n_s_table_name #define __pyx_n_s_test __pyx_mstate_global->__pyx_n_s_test #define __pyx_n_s_throw __pyx_mstate_global->__pyx_n_s_throw #define __pyx_n_s_usecols __pyx_mstate_global->__pyx_n_s_usecols #define __pyx_n_s_user_missing __pyx_mstate_global->__pyx_n_s_user_missing #define __pyx_n_s_usernan __pyx_mstate_global->__pyx_n_s_usernan #define __pyx_n_s_var_width __pyx_mstate_global->__pyx_n_s_var_width #define __pyx_n_s_variable_alignment __pyx_mstate_global->__pyx_n_s_variable_alignment #define __pyx_n_s_variable_display_width __pyx_mstate_global->__pyx_n_s_variable_display_width #define __pyx_n_s_variable_format __pyx_mstate_global->__pyx_n_s_variable_format #define __pyx_n_s_variable_measure __pyx_mstate_global->__pyx_n_s_variable_measure #define __pyx_n_s_variable_value_labels __pyx_mstate_global->__pyx_n_s_variable_value_labels #define __pyx_n_s_version __pyx_mstate_global->__pyx_n_s_version #define __pyx_n_s_worker __pyx_mstate_global->__pyx_n_s_worker #define __pyx_n_s_write_dta __pyx_mstate_global->__pyx_n_s_write_dta #define __pyx_n_s_write_por __pyx_mstate_global->__pyx_n_s_write_por #define __pyx_n_s_write_sav __pyx_mstate_global->__pyx_n_s_write_sav #define __pyx_n_s_write_xport __pyx_mstate_global->__pyx_n_s_write_xport #define __pyx_n_s_x __pyx_mstate_global->__pyx_n_s_x #define __pyx_n_s_xport __pyx_mstate_global->__pyx_n_s_xport #define __pyx_int_0 __pyx_mstate_global->__pyx_int_0 #define __pyx_int_1 __pyx_mstate_global->__pyx_int_1 #define __pyx_int_4 __pyx_mstate_global->__pyx_int_4 #define __pyx_int_100000 __pyx_mstate_global->__pyx_int_100000 #define __pyx_codeobj_ __pyx_mstate_global->__pyx_codeobj_ #define __pyx_tuple__2 __pyx_mstate_global->__pyx_tuple__2 #define __pyx_tuple__3 __pyx_mstate_global->__pyx_tuple__3 #define __pyx_tuple__4 __pyx_mstate_global->__pyx_tuple__4 #define __pyx_tuple__5 __pyx_mstate_global->__pyx_tuple__5 #define __pyx_tuple__7 __pyx_mstate_global->__pyx_tuple__7 #define __pyx_tuple__11 __pyx_mstate_global->__pyx_tuple__11 #define __pyx_tuple__13 __pyx_mstate_global->__pyx_tuple__13 #define __pyx_tuple__15 __pyx_mstate_global->__pyx_tuple__15 #define __pyx_tuple__18 __pyx_mstate_global->__pyx_tuple__18 #define __pyx_tuple__20 __pyx_mstate_global->__pyx_tuple__20 #define __pyx_tuple__22 __pyx_mstate_global->__pyx_tuple__22 #define __pyx_tuple__23 __pyx_mstate_global->__pyx_tuple__23 #define __pyx_tuple__24 __pyx_mstate_global->__pyx_tuple__24 #define __pyx_tuple__25 __pyx_mstate_global->__pyx_tuple__25 #define __pyx_tuple__27 __pyx_mstate_global->__pyx_tuple__27 #define __pyx_tuple__29 __pyx_mstate_global->__pyx_tuple__29 #define __pyx_tuple__30 __pyx_mstate_global->__pyx_tuple__30 #define __pyx_tuple__32 __pyx_mstate_global->__pyx_tuple__32 #define __pyx_tuple__34 __pyx_mstate_global->__pyx_tuple__34 #define __pyx_tuple__36 __pyx_mstate_global->__pyx_tuple__36 #define __pyx_codeobj__12 __pyx_mstate_global->__pyx_codeobj__12 #define __pyx_codeobj__14 __pyx_mstate_global->__pyx_codeobj__14 #define __pyx_codeobj__16 __pyx_mstate_global->__pyx_codeobj__16 #define __pyx_codeobj__17 __pyx_mstate_global->__pyx_codeobj__17 #define __pyx_codeobj__19 __pyx_mstate_global->__pyx_codeobj__19 #define __pyx_codeobj__21 __pyx_mstate_global->__pyx_codeobj__21 #define __pyx_codeobj__26 __pyx_mstate_global->__pyx_codeobj__26 #define __pyx_codeobj__28 __pyx_mstate_global->__pyx_codeobj__28 #define __pyx_codeobj__31 __pyx_mstate_global->__pyx_codeobj__31 #define __pyx_codeobj__33 __pyx_mstate_global->__pyx_codeobj__33 #define __pyx_codeobj__35 __pyx_mstate_global->__pyx_codeobj__35 /* #### Code section: module_code ### */ /* "pyreadstat/pyreadstat.pyx":42 * # Parsing functions * * def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_1read_sas7bdat(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_read_sas7bdat, "\n Read a SAS sas7bdat file.\n It accepts the path to a sas7bcat.\n \n Parameters\n ----------\n filename_path : str, bytes or Path-like object\n path to the file. In python 2.7 the string is assumed to be utf-8 encoded.\n metadataonly : bool, optional\n by default False. IF true, no data will be read but only metadata, so that you can get all elements in the\n metadata object. The data frame will be set with the correct column names but no data.\n dates_as_pandas_datetime : bool, optional\n by default False. If true dates will be transformed to pandas datetime64 instead of date.\n catalog_file : str, optional\n path to a sas7bcat file. By default is None. If not None, will parse the catalog file and replace the values\n by the formats in the catalog, if any appropiate is found. If this is not the behavior you are looking for,\n Use read_sas7bcat to parse the catalog independently\n of the sas7bdat and set_catalog_to_sas to apply the resulting format into sas7bdat files.\n formats_as_category : bool, optional\n Will take effect only if the catalog_file was specified. If True the variables whose values were replaced\n by the formats will be transformed into pandas categories.\n formats_as_ordered_category : bool, optional\n defaults to False. If True the variables having formats will be transformed into pandas ordered categories.\n it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of\n the value of formats_as_category.\n encoding : str, optional\n Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an\n iconv-compatible name\n usecols : list, optional\n a list with column names to read from the file. Only those columns wil""l be imported. Case sensitive!\n user_missing : bool, optional\n by default False, in this case user defined missing values are delivered as nan. If true, the missing values\n will be deliver as is, and an extra piece of information will be set in the metadata (missing_user_values)\n to be able to interpret those values as missing.\n disable_datetime_conversion : bool, optional\n if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns\n will remain as numbers. In order to convert them later to an appropiate python object, the user can use the\n information about the original variable format stored in the metadata object in original_variable_types.\n Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where\n there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates\n beyond that will rise an Overflow error in pyreadstat).\n row_limit : int, optional\n maximum number of rows to read. The default is 0 meaning unlimited.\n row_offset : int, optional\n start reading rows after this offset. By default 0, meaning start with the first row not skipping anything.\n output_format : str, optional\n one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the\n user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas\n dataframe is avoided.\n extra_datetime_formats: list of str, optional\n formats to be parsed as python datetime objects\n extra_date_formats: list of str, optional\n formats to be parsed as python date objects\n \n\n Returns\n -------\n data_frame : pandas d""ataframe\n a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly.\n metadata\n object with metadata. The members variables_value_labels will be empty unless a valid catalog file is\n supplied.\n Look at the documentation for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_1read_sas7bdat = {"read_sas7bdat", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_1read_sas7bdat, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_read_sas7bdat}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_1read_sas7bdat(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_filename_path = 0; PyObject *__pyx_v_metadataonly = 0; PyObject *__pyx_v_dates_as_pandas_datetime = 0; PyObject *__pyx_v_catalog_file = 0; PyObject *__pyx_v_formats_as_category = 0; PyObject *__pyx_v_formats_as_ordered_category = 0; PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_usecols = 0; PyObject *__pyx_v_user_missing = 0; PyObject *__pyx_v_disable_datetime_conversion = 0; int __pyx_v_row_limit; int __pyx_v_row_offset; PyObject *__pyx_v_output_format = 0; PyObject *__pyx_v_extra_datetime_formats = 0; PyObject *__pyx_v_extra_date_formats = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_sas7bdat (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename_path,&__pyx_n_s_metadataonly,&__pyx_n_s_dates_as_pandas_datetime,&__pyx_n_s_catalog_file,&__pyx_n_s_formats_as_category,&__pyx_n_s_formats_as_ordered_category,&__pyx_n_s_encoding,&__pyx_n_s_usecols,&__pyx_n_s_user_missing,&__pyx_n_s_disable_datetime_conversion,&__pyx_n_s_row_limit,&__pyx_n_s_row_offset,&__pyx_n_s_output_format,&__pyx_n_s_extra_datetime_formats,&__pyx_n_s_extra_date_formats,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); /* "pyreadstat/pyreadstat.pyx":43 * * def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, # <<<<<<<<<<<<<< * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, * list extra_datetime_formats=None, list extra_date_formats=None): */ values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); /* "pyreadstat/pyreadstat.pyx":44 * def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, # <<<<<<<<<<<<<< * list extra_datetime_formats=None, list extra_date_formats=None): * r""" */ values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[12] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":45 * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, * list extra_datetime_formats=None, list extra_date_formats=None): # <<<<<<<<<<<<<< * r""" * Read a SAS sas7bdat file. */ values[13] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[14] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 15: values[14] = __Pyx_Arg_FASTCALL(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = __Pyx_Arg_FASTCALL(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_metadataonly); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dates_as_pandas_datetime); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_catalog_file); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_formats_as_category); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_formats_as_ordered_category); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_encoding); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_usecols); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_user_missing); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_disable_datetime_conversion); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_limit); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 11: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_offset); if (value) { values[11] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 12: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_output_format); if (value) { values[12] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 13: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_datetime_formats); if (value) { values[13] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 14: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_date_formats); if (value) { values[14] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "read_sas7bdat") < 0)) __PYX_ERR(0, 42, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 15: values[14] = __Pyx_Arg_FASTCALL(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = __Pyx_Arg_FASTCALL(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_filename_path = values[0]; __pyx_v_metadataonly = values[1]; __pyx_v_dates_as_pandas_datetime = values[2]; __pyx_v_catalog_file = values[3]; __pyx_v_formats_as_category = values[4]; __pyx_v_formats_as_ordered_category = values[5]; __pyx_v_encoding = ((PyObject*)values[6]); __pyx_v_usecols = ((PyObject*)values[7]); __pyx_v_user_missing = values[8]; __pyx_v_disable_datetime_conversion = values[9]; if (values[10]) { __pyx_v_row_limit = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_row_limit == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L3_error) } else { __pyx_v_row_limit = ((int)((int)0)); } if (values[11]) { __pyx_v_row_offset = __Pyx_PyInt_As_int(values[11]); if (unlikely((__pyx_v_row_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 44, __pyx_L3_error) } else { __pyx_v_row_offset = ((int)((int)0)); } __pyx_v_output_format = ((PyObject*)values[12]); __pyx_v_extra_datetime_formats = ((PyObject*)values[13]); __pyx_v_extra_date_formats = ((PyObject*)values[14]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_sas7bdat", 0, 1, 15, __pyx_nargs); __PYX_ERR(0, 42, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.read_sas7bdat", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_encoding), (&PyString_Type), 1, "encoding", 1))) __PYX_ERR(0, 43, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_usecols), (&PyList_Type), 1, "usecols", 1))) __PYX_ERR(0, 43, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output_format), (&PyString_Type), 1, "output_format", 1))) __PYX_ERR(0, 44, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_datetime_formats), (&PyList_Type), 1, "extra_datetime_formats", 1))) __PYX_ERR(0, 45, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_date_formats), (&PyList_Type), 1, "extra_date_formats", 1))) __PYX_ERR(0, 45, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_read_sas7bdat(__pyx_self, __pyx_v_filename_path, __pyx_v_metadataonly, __pyx_v_dates_as_pandas_datetime, __pyx_v_catalog_file, __pyx_v_formats_as_category, __pyx_v_formats_as_ordered_category, __pyx_v_encoding, __pyx_v_usecols, __pyx_v_user_missing, __pyx_v_disable_datetime_conversion, __pyx_v_row_limit, __pyx_v_row_offset, __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); /* "pyreadstat/pyreadstat.pyx":42 * # Parsing functions * * def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_read_sas7bdat(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_catalog_file, PyObject *__pyx_v_formats_as_category, PyObject *__pyx_v_formats_as_ordered_category, PyObject *__pyx_v_encoding, PyObject *__pyx_v_usecols, PyObject *__pyx_v_user_missing, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats) { int __pyx_v_metaonly; int __pyx_v_dates_as_pandas; int __pyx_v_usernan; int __pyx_v_no_datetime_conversion; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format; __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_v_file_extension; PyObject *__pyx_v_data_frame = NULL; PyObject *__pyx_v_metadata = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_v_catalog = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *(*__pyx_t_6)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_sas7bdat", 1); /* "pyreadstat/pyreadstat.pyx":111 * """ * * cdef bint metaonly = 0 # <<<<<<<<<<<<<< * if metadataonly: * metaonly = 1 */ __pyx_v_metaonly = 0; /* "pyreadstat/pyreadstat.pyx":112 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_metadataonly); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 112, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":113 * cdef bint metaonly = 0 * if metadataonly: * metaonly = 1 # <<<<<<<<<<<<<< * * cdef bint dates_as_pandas = 0 */ __pyx_v_metaonly = 1; /* "pyreadstat/pyreadstat.pyx":112 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ } /* "pyreadstat/pyreadstat.pyx":115 * metaonly = 1 * * cdef bint dates_as_pandas = 0 # <<<<<<<<<<<<<< * if dates_as_pandas_datetime: * dates_as_pandas = 1 */ __pyx_v_dates_as_pandas = 0; /* "pyreadstat/pyreadstat.pyx":116 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_dates_as_pandas_datetime); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 116, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":117 * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: * dates_as_pandas = 1 # <<<<<<<<<<<<<< * * cdef bint usernan = 0 */ __pyx_v_dates_as_pandas = 1; /* "pyreadstat/pyreadstat.pyx":116 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ } /* "pyreadstat/pyreadstat.pyx":119 * dates_as_pandas = 1 * * cdef bint usernan = 0 # <<<<<<<<<<<<<< * if user_missing: * usernan = 1 */ __pyx_v_usernan = 0; /* "pyreadstat/pyreadstat.pyx":120 * * cdef bint usernan = 0 * if user_missing: # <<<<<<<<<<<<<< * usernan = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_user_missing); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 120, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":121 * cdef bint usernan = 0 * if user_missing: * usernan = 1 # <<<<<<<<<<<<<< * * cdef bint no_datetime_conversion = 0 */ __pyx_v_usernan = 1; /* "pyreadstat/pyreadstat.pyx":120 * * cdef bint usernan = 0 * if user_missing: # <<<<<<<<<<<<<< * usernan = 1 * */ } /* "pyreadstat/pyreadstat.pyx":123 * usernan = 1 * * cdef bint no_datetime_conversion = 0 # <<<<<<<<<<<<<< * if disable_datetime_conversion: * no_datetime_conversion = 1 */ __pyx_v_no_datetime_conversion = 0; /* "pyreadstat/pyreadstat.pyx":124 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_disable_datetime_conversion); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 124, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":125 * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: * no_datetime_conversion = 1 # <<<<<<<<<<<<<< * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS */ __pyx_v_no_datetime_conversion = 1; /* "pyreadstat/pyreadstat.pyx":124 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ } /* "pyreadstat/pyreadstat.pyx":127 * no_datetime_conversion = 1 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS # <<<<<<<<<<<<<< * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAS7BDAT * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, */ __pyx_v_file_format = __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS; /* "pyreadstat/pyreadstat.pyx":128 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAS7BDAT # <<<<<<<<<<<<<< * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, */ __pyx_v_file_extension = __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BDAT; /* "pyreadstat/pyreadstat.pyx":129 * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAS7BDAT * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, # <<<<<<<<<<<<<< * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) */ __pyx_t_2 = __pyx_f_10pyreadstat_16_readstat_parser_run_conversion(__pyx_v_filename_path, __pyx_v_file_format, __pyx_v_file_extension, __pyx_v_encoding, __pyx_v_metaonly, __pyx_v_dates_as_pandas, __pyx_v_usecols, __pyx_v_usernan, __pyx_v_no_datetime_conversion, ((long)__pyx_v_row_limit), ((long)__pyx_v_row_offset), __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 129, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 129, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L8_unpacking_done; __pyx_L7_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 129, __pyx_L1_error) __pyx_L8_unpacking_done:; } __pyx_v_data_frame = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_metadata = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":132 * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) * metadata.file_format = "sas7bdat" # <<<<<<<<<<<<<< * * if catalog_file: */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_file_format, __pyx_n_s_sas7bdat) < 0) __PYX_ERR(0, 132, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":134 * metadata.file_format = "sas7bdat" * * if catalog_file: # <<<<<<<<<<<<<< * _ , catalog = read_sas7bcat(catalog_file, encoding=encoding) * data_frame, metadata = set_catalog_to_sas(data_frame, metadata, catalog, formats_as_category=formats_as_category, */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_catalog_file); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 134, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":135 * * if catalog_file: * _ , catalog = read_sas7bcat(catalog_file, encoding=encoding) # <<<<<<<<<<<<<< * data_frame, metadata = set_catalog_to_sas(data_frame, metadata, catalog, formats_as_category=formats_as_category, * formats_as_ordered_category=formats_as_ordered_category) */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_read_sas7bcat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_catalog_file); __Pyx_GIVEREF(__pyx_v_catalog_file); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_catalog_file)) __PYX_ERR(0, 135, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_encoding, __pyx_v_encoding) < 0) __PYX_ERR(0, 135, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 135, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L10_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L10_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_2), 2) < 0) __PYX_ERR(0, 135, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L11_unpacking_done; __pyx_L10_unpacking_failed:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 135, __pyx_L1_error) __pyx_L11_unpacking_done:; } __pyx_v__ = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_catalog = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":136 * if catalog_file: * _ , catalog = read_sas7bcat(catalog_file, encoding=encoding) * data_frame, metadata = set_catalog_to_sas(data_frame, metadata, catalog, formats_as_category=formats_as_category, # <<<<<<<<<<<<<< * formats_as_ordered_category=formats_as_ordered_category) * */ __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_set_catalog_to_sas); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_data_frame)) __PYX_ERR(0, 136, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_metadata)) __PYX_ERR(0, 136, __pyx_L1_error); __Pyx_INCREF(__pyx_v_catalog); __Pyx_GIVEREF(__pyx_v_catalog); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_catalog)) __PYX_ERR(0, 136, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_formats_as_category, __pyx_v_formats_as_category) < 0) __PYX_ERR(0, 136, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":137 * _ , catalog = read_sas7bcat(catalog_file, encoding=encoding) * data_frame, metadata = set_catalog_to_sas(data_frame, metadata, catalog, formats_as_category=formats_as_category, * formats_as_ordered_category=formats_as_ordered_category) # <<<<<<<<<<<<<< * * return data_frame, metadata */ if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_formats_as_ordered_category, __pyx_v_formats_as_ordered_category) < 0) __PYX_ERR(0, 136, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":136 * if catalog_file: * _ , catalog = read_sas7bcat(catalog_file, encoding=encoding) * data_frame, metadata = set_catalog_to_sas(data_frame, metadata, catalog, formats_as_category=formats_as_category, # <<<<<<<<<<<<<< * formats_as_ordered_category=formats_as_ordered_category) * */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 136, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 136, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L13_unpacking_done; __pyx_L12_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 136, __pyx_L1_error) __pyx_L13_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_data_frame, __pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_metadata, __pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":134 * metadata.file_format = "sas7bdat" * * if catalog_file: # <<<<<<<<<<<<<< * _ , catalog = read_sas7bcat(catalog_file, encoding=encoding) * data_frame, metadata = set_catalog_to_sas(data_frame, metadata, catalog, formats_as_category=formats_as_category, */ } /* "pyreadstat/pyreadstat.pyx":139 * formats_as_ordered_category=formats_as_ordered_category) * * return data_frame, metadata # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data_frame)) __PYX_ERR(0, 139, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_metadata)) __PYX_ERR(0, 139, __pyx_L1_error); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "pyreadstat/pyreadstat.pyx":42 * # Parsing functions * * def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("pyreadstat.pyreadstat.read_sas7bdat", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_data_frame); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_catalog); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":142 * * * def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, # <<<<<<<<<<<<<< * list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, * str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_3read_xport(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_2read_xport, "\n Read a SAS xport file.\n\n Parameters\n ----------\n filename_path : str, bytes or Path-like object\n path to the file. In python 2.7 the string is assumed to be utf-8 encoded\n metadataonly : bool, optional\n by default False. IF true, no data will be read but only metadata, so that you can get all elements in the\n metadata object. The data frame will be set with the correct column names but no data.\n Notice that number_rows will be None as xport files do not have the number of rows recorded in the file metadata.\n dates_as_pandas_datetime : bool, optional\n by default False. If true dates will be transformed to pandas datetime64 instead of date.\n encoding : str, optional\n Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an\n iconv-compatible name\n usecols : list, optional\n a list with column names to read from the file. Only those columns will be imported. Case sensitive!\n disable_datetime_conversion : bool, optional\n if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns\n will remain as numbers. In order to convert them later to an appropiate python object, the user can use the\n information about the original variable format stored in the metadata object in original_variable_types.\n Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where\n there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates\n beyond that will rise an Overflow error in pyreadstat).\n row_limit : int, optional\n maximum number of rows to read. The default is 0 meaning unlimited.\n row_offset : int, optional\n start reading rows after this ""offset. By default 0, meaning start with the first row not skipping anything.\n output_format : str, optional\n one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the\n user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas\n dataframe is avoided.\n extra_datetime_formats: list of str, optional\n formats to be parsed as python datetime objects\n extra_date_formats: list of str, optional\n formats to be parsed as python date objects\n\n Returns\n -------\n data_frame : pandas dataframe\n a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly.\n metadata :\n object with metadata. Look at the documentation for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_3read_xport = {"read_xport", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_3read_xport, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_2read_xport}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_3read_xport(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_filename_path = 0; PyObject *__pyx_v_metadataonly = 0; PyObject *__pyx_v_dates_as_pandas_datetime = 0; PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_usecols = 0; PyObject *__pyx_v_disable_datetime_conversion = 0; int __pyx_v_row_limit; int __pyx_v_row_offset; PyObject *__pyx_v_output_format = 0; PyObject *__pyx_v_extra_datetime_formats = 0; PyObject *__pyx_v_extra_date_formats = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_xport (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename_path,&__pyx_n_s_metadataonly,&__pyx_n_s_dates_as_pandas_datetime,&__pyx_n_s_encoding,&__pyx_n_s_usecols,&__pyx_n_s_disable_datetime_conversion,&__pyx_n_s_row_limit,&__pyx_n_s_row_offset,&__pyx_n_s_output_format,&__pyx_n_s_extra_datetime_formats,&__pyx_n_s_extra_date_formats,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":143 * * def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, * list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, # <<<<<<<<<<<<<< * str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): * r""" */ values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); /* "pyreadstat/pyreadstat.pyx":144 * def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, * list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, * str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): # <<<<<<<<<<<<<< * r""" * Read a SAS xport file. */ values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[10] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_metadataonly); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dates_as_pandas_datetime); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_encoding); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_usecols); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_disable_datetime_conversion); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_limit); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_offset); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_output_format); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_datetime_formats); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_date_formats); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "read_xport") < 0)) __PYX_ERR(0, 142, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_filename_path = values[0]; __pyx_v_metadataonly = values[1]; __pyx_v_dates_as_pandas_datetime = values[2]; __pyx_v_encoding = ((PyObject*)values[3]); __pyx_v_usecols = ((PyObject*)values[4]); __pyx_v_disable_datetime_conversion = values[5]; if (values[6]) { __pyx_v_row_limit = __Pyx_PyInt_As_int(values[6]); if (unlikely((__pyx_v_row_limit == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L3_error) } else { __pyx_v_row_limit = ((int)((int)0)); } if (values[7]) { __pyx_v_row_offset = __Pyx_PyInt_As_int(values[7]); if (unlikely((__pyx_v_row_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L3_error) } else { __pyx_v_row_offset = ((int)((int)0)); } __pyx_v_output_format = ((PyObject*)values[8]); __pyx_v_extra_datetime_formats = ((PyObject*)values[9]); __pyx_v_extra_date_formats = ((PyObject*)values[10]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_xport", 0, 1, 11, __pyx_nargs); __PYX_ERR(0, 142, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.read_xport", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_encoding), (&PyString_Type), 1, "encoding", 1))) __PYX_ERR(0, 142, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_usecols), (&PyList_Type), 1, "usecols", 1))) __PYX_ERR(0, 143, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output_format), (&PyString_Type), 1, "output_format", 1))) __PYX_ERR(0, 144, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_datetime_formats), (&PyList_Type), 1, "extra_datetime_formats", 1))) __PYX_ERR(0, 144, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_date_formats), (&PyList_Type), 1, "extra_date_formats", 1))) __PYX_ERR(0, 144, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_2read_xport(__pyx_self, __pyx_v_filename_path, __pyx_v_metadataonly, __pyx_v_dates_as_pandas_datetime, __pyx_v_encoding, __pyx_v_usecols, __pyx_v_disable_datetime_conversion, __pyx_v_row_limit, __pyx_v_row_offset, __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); /* "pyreadstat/pyreadstat.pyx":142 * * * def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, # <<<<<<<<<<<<<< * list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, * str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_2read_xport(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_encoding, PyObject *__pyx_v_usecols, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats) { int __pyx_v_metaonly; int __pyx_v_dates_as_pandas; int __pyx_v_usernan; int __pyx_v_no_datetime_conversion; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format; __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_v_file_extension; PyObject *__pyx_v_data_frame = NULL; PyObject *__pyx_v_metadata = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *(*__pyx_t_6)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_xport", 1); /* "pyreadstat/pyreadstat.pyx":191 * """ * * cdef bint metaonly = 0 # <<<<<<<<<<<<<< * if metadataonly: * metaonly = 1 */ __pyx_v_metaonly = 0; /* "pyreadstat/pyreadstat.pyx":192 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_metadataonly); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 192, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":193 * cdef bint metaonly = 0 * if metadataonly: * metaonly = 1 # <<<<<<<<<<<<<< * * cdef bint dates_as_pandas = 0 */ __pyx_v_metaonly = 1; /* "pyreadstat/pyreadstat.pyx":192 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ } /* "pyreadstat/pyreadstat.pyx":195 * metaonly = 1 * * cdef bint dates_as_pandas = 0 # <<<<<<<<<<<<<< * if dates_as_pandas_datetime: * dates_as_pandas = 1 */ __pyx_v_dates_as_pandas = 0; /* "pyreadstat/pyreadstat.pyx":196 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_dates_as_pandas_datetime); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 196, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":197 * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: * dates_as_pandas = 1 # <<<<<<<<<<<<<< * * cdef bint usernan = 0 */ __pyx_v_dates_as_pandas = 1; /* "pyreadstat/pyreadstat.pyx":196 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ } /* "pyreadstat/pyreadstat.pyx":199 * dates_as_pandas = 1 * * cdef bint usernan = 0 # <<<<<<<<<<<<<< * * cdef bint no_datetime_conversion = 0 */ __pyx_v_usernan = 0; /* "pyreadstat/pyreadstat.pyx":201 * cdef bint usernan = 0 * * cdef bint no_datetime_conversion = 0 # <<<<<<<<<<<<<< * if disable_datetime_conversion: * no_datetime_conversion = 1 */ __pyx_v_no_datetime_conversion = 0; /* "pyreadstat/pyreadstat.pyx":202 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_disable_datetime_conversion); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 202, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":203 * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: * no_datetime_conversion = 1 # <<<<<<<<<<<<<< * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS */ __pyx_v_no_datetime_conversion = 1; /* "pyreadstat/pyreadstat.pyx":202 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ } /* "pyreadstat/pyreadstat.pyx":205 * no_datetime_conversion = 1 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS # <<<<<<<<<<<<<< * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_XPORT * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, */ __pyx_v_file_format = __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS; /* "pyreadstat/pyreadstat.pyx":206 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_XPORT # <<<<<<<<<<<<<< * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, */ __pyx_v_file_extension = __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_XPORT; /* "pyreadstat/pyreadstat.pyx":207 * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_XPORT * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, # <<<<<<<<<<<<<< * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) */ __pyx_t_2 = __pyx_f_10pyreadstat_16_readstat_parser_run_conversion(__pyx_v_filename_path, __pyx_v_file_format, __pyx_v_file_extension, __pyx_v_encoding, __pyx_v_metaonly, __pyx_v_dates_as_pandas, __pyx_v_usecols, __pyx_v_usernan, __pyx_v_no_datetime_conversion, ((long)__pyx_v_row_limit), ((long)__pyx_v_row_offset), __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 207, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 207, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 207, __pyx_L1_error) __pyx_L7_unpacking_done:; } __pyx_v_data_frame = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_metadata = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":210 * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) * metadata.file_format = "xport" # <<<<<<<<<<<<<< * * return data_frame, metadata */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_file_format, __pyx_n_s_xport) < 0) __PYX_ERR(0, 210, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":212 * metadata.file_format = "xport" * * return data_frame, metadata # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data_frame)) __PYX_ERR(0, 212, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_metadata)) __PYX_ERR(0, 212, __pyx_L1_error); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; /* "pyreadstat/pyreadstat.pyx":142 * * * def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, # <<<<<<<<<<<<<< * list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, * str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("pyreadstat.pyreadstat.read_xport", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_data_frame); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":215 * * * def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_5read_dta(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_4read_dta, "\n Read a STATA dta file\n\n Parameters\n ----------\n filename_path : str, bytes or Path-like object\n path to the file. In Python 2.7 the string is assumed to be utf-8 encoded\n metadataonly : bool, optional\n by default False. IF true, no data will be read but only metadata, so that you can get all elements in the\n metadata object. The data frame will be set with the correct column names but no data.\n dates_as_pandas_datetime : bool, optional\n by default False. If true dates will be transformed to pandas datetime64 instead of date.\n apply_value_formats : bool, optional\n by default False. If true it will change values in the dataframe for they value labels in the metadata,\n if any appropiate are found.\n formats_as_category : bool, optional\n by default True. Takes effect only if apply_value_formats is True. If True, variables with values changed\n for their formatted version will be transformed into pandas categories.\n formats_as_ordered_category : bool, optional\n defaults to False. If True the variables having formats will be transformed into pandas ordered categories.\n it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of\n the value of formats_as_category.\n encoding : str, optional\n Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an\n iconv-compatible name\n usecols : list, optional\n a list with column names to read from the file. Only those columns will be imported. Case sensitive!\n user_missing : bool, optional\n by default False, in this case user defined missing values are delivered as nan. If true, the missing values\n will be deliver as is, and an extra piece of information will be set in the ""metadata (missing_user_values)\n to be able to interpret those values as missing.\n disable_datetime_conversion : bool, optional\n if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns\n will remain as numbers. In order to convert them later to an appropiate python object, the user can use the\n information about the original variable format stored in the metadata object in original_variable_types.\n Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where\n there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates\n beyond that will rise an Overflow error in pyreadstat).\n row_limit : int, optional\n maximum number of rows to read. The default is 0 meaning unlimited.\n row_offset : int, optional\n start reading rows after this offset. By default 0, meaning start with the first row not skipping anything.\n output_format : str, optional\n one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the\n user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas\n dataframe is avoided.\n extra_datetime_formats: list of str, optional\n formats to be parsed as python datetime objects\n extra_date_formats: list of str, optional\n formats to be parsed as python date objects\n\n Returns\n -------\n data_frame : pandas dataframe\n a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly.\n metadata :\n object with metadata. Look at the documentation for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_5read_dta = {"read_dta", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_5read_dta, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_4read_dta}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_5read_dta(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_filename_path = 0; PyObject *__pyx_v_metadataonly = 0; PyObject *__pyx_v_dates_as_pandas_datetime = 0; PyObject *__pyx_v_apply_value_formats = 0; PyObject *__pyx_v_formats_as_category = 0; PyObject *__pyx_v_formats_as_ordered_category = 0; PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_usecols = 0; PyObject *__pyx_v_user_missing = 0; PyObject *__pyx_v_disable_datetime_conversion = 0; int __pyx_v_row_limit; int __pyx_v_row_offset; PyObject *__pyx_v_output_format = 0; PyObject *__pyx_v_extra_datetime_formats = 0; PyObject *__pyx_v_extra_date_formats = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_dta (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename_path,&__pyx_n_s_metadataonly,&__pyx_n_s_dates_as_pandas_datetime,&__pyx_n_s_apply_value_formats,&__pyx_n_s_formats_as_category,&__pyx_n_s_formats_as_ordered_category,&__pyx_n_s_encoding,&__pyx_n_s_usecols,&__pyx_n_s_user_missing,&__pyx_n_s_disable_datetime_conversion,&__pyx_n_s_row_limit,&__pyx_n_s_row_offset,&__pyx_n_s_output_format,&__pyx_n_s_extra_datetime_formats,&__pyx_n_s_extra_date_formats,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); /* "pyreadstat/pyreadstat.pyx":216 * * def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, # <<<<<<<<<<<<<< * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, * list extra_datetime_formats=None, list extra_date_formats=None): */ values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); /* "pyreadstat/pyreadstat.pyx":217 * def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, # <<<<<<<<<<<<<< * list extra_datetime_formats=None, list extra_date_formats=None): * r""" */ values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[12] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":218 * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, * list extra_datetime_formats=None, list extra_date_formats=None): # <<<<<<<<<<<<<< * r""" * Read a STATA dta file */ values[13] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[14] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 15: values[14] = __Pyx_Arg_FASTCALL(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = __Pyx_Arg_FASTCALL(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_metadataonly); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dates_as_pandas_datetime); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_apply_value_formats); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_formats_as_category); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_formats_as_ordered_category); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_encoding); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_usecols); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_user_missing); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_disable_datetime_conversion); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_limit); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 11: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_offset); if (value) { values[11] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 12: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_output_format); if (value) { values[12] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 13: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_datetime_formats); if (value) { values[13] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 14: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_date_formats); if (value) { values[14] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 215, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "read_dta") < 0)) __PYX_ERR(0, 215, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 15: values[14] = __Pyx_Arg_FASTCALL(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = __Pyx_Arg_FASTCALL(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_filename_path = values[0]; __pyx_v_metadataonly = values[1]; __pyx_v_dates_as_pandas_datetime = values[2]; __pyx_v_apply_value_formats = values[3]; __pyx_v_formats_as_category = values[4]; __pyx_v_formats_as_ordered_category = values[5]; __pyx_v_encoding = ((PyObject*)values[6]); __pyx_v_usecols = ((PyObject*)values[7]); __pyx_v_user_missing = values[8]; __pyx_v_disable_datetime_conversion = values[9]; if (values[10]) { __pyx_v_row_limit = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_row_limit == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L3_error) } else { __pyx_v_row_limit = ((int)((int)0)); } if (values[11]) { __pyx_v_row_offset = __Pyx_PyInt_As_int(values[11]); if (unlikely((__pyx_v_row_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 217, __pyx_L3_error) } else { __pyx_v_row_offset = ((int)((int)0)); } __pyx_v_output_format = ((PyObject*)values[12]); __pyx_v_extra_datetime_formats = ((PyObject*)values[13]); __pyx_v_extra_date_formats = ((PyObject*)values[14]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_dta", 0, 1, 15, __pyx_nargs); __PYX_ERR(0, 215, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.read_dta", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_encoding), (&PyString_Type), 1, "encoding", 1))) __PYX_ERR(0, 216, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_usecols), (&PyList_Type), 1, "usecols", 1))) __PYX_ERR(0, 216, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output_format), (&PyString_Type), 1, "output_format", 1))) __PYX_ERR(0, 217, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_datetime_formats), (&PyList_Type), 1, "extra_datetime_formats", 1))) __PYX_ERR(0, 218, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_date_formats), (&PyList_Type), 1, "extra_date_formats", 1))) __PYX_ERR(0, 218, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_4read_dta(__pyx_self, __pyx_v_filename_path, __pyx_v_metadataonly, __pyx_v_dates_as_pandas_datetime, __pyx_v_apply_value_formats, __pyx_v_formats_as_category, __pyx_v_formats_as_ordered_category, __pyx_v_encoding, __pyx_v_usecols, __pyx_v_user_missing, __pyx_v_disable_datetime_conversion, __pyx_v_row_limit, __pyx_v_row_offset, __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); /* "pyreadstat/pyreadstat.pyx":215 * * * def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_4read_dta(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_apply_value_formats, PyObject *__pyx_v_formats_as_category, PyObject *__pyx_v_formats_as_ordered_category, PyObject *__pyx_v_encoding, PyObject *__pyx_v_usecols, PyObject *__pyx_v_user_missing, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats) { int __pyx_v_metaonly; int __pyx_v_dates_as_pandas; int __pyx_v_usernan; int __pyx_v_no_datetime_conversion; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format; __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_v_file_extension; PyObject *__pyx_v_data_frame = NULL; PyObject *__pyx_v_metadata = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *(*__pyx_t_6)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_dta", 1); /* "pyreadstat/pyreadstat.pyx":278 * """ * * cdef bint metaonly = 0 # <<<<<<<<<<<<<< * if metadataonly: * metaonly = 1 */ __pyx_v_metaonly = 0; /* "pyreadstat/pyreadstat.pyx":279 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_metadataonly); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 279, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":280 * cdef bint metaonly = 0 * if metadataonly: * metaonly = 1 # <<<<<<<<<<<<<< * * cdef bint dates_as_pandas = 0 */ __pyx_v_metaonly = 1; /* "pyreadstat/pyreadstat.pyx":279 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ } /* "pyreadstat/pyreadstat.pyx":282 * metaonly = 1 * * cdef bint dates_as_pandas = 0 # <<<<<<<<<<<<<< * if dates_as_pandas_datetime: * dates_as_pandas = 1 */ __pyx_v_dates_as_pandas = 0; /* "pyreadstat/pyreadstat.pyx":283 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_dates_as_pandas_datetime); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 283, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":284 * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: * dates_as_pandas = 1 # <<<<<<<<<<<<<< * * cdef bint usernan = 0 */ __pyx_v_dates_as_pandas = 1; /* "pyreadstat/pyreadstat.pyx":283 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ } /* "pyreadstat/pyreadstat.pyx":286 * dates_as_pandas = 1 * * cdef bint usernan = 0 # <<<<<<<<<<<<<< * if user_missing: * usernan = 1 */ __pyx_v_usernan = 0; /* "pyreadstat/pyreadstat.pyx":287 * * cdef bint usernan = 0 * if user_missing: # <<<<<<<<<<<<<< * usernan = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_user_missing); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 287, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":288 * cdef bint usernan = 0 * if user_missing: * usernan = 1 # <<<<<<<<<<<<<< * * cdef bint no_datetime_conversion = 0 */ __pyx_v_usernan = 1; /* "pyreadstat/pyreadstat.pyx":287 * * cdef bint usernan = 0 * if user_missing: # <<<<<<<<<<<<<< * usernan = 1 * */ } /* "pyreadstat/pyreadstat.pyx":290 * usernan = 1 * * cdef bint no_datetime_conversion = 0 # <<<<<<<<<<<<<< * if disable_datetime_conversion: * no_datetime_conversion = 1 */ __pyx_v_no_datetime_conversion = 0; /* "pyreadstat/pyreadstat.pyx":291 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_disable_datetime_conversion); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 291, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":292 * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: * no_datetime_conversion = 1 # <<<<<<<<<<<<<< * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_STATA */ __pyx_v_no_datetime_conversion = 1; /* "pyreadstat/pyreadstat.pyx":291 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ } /* "pyreadstat/pyreadstat.pyx":294 * no_datetime_conversion = 1 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_STATA # <<<<<<<<<<<<<< * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_DTA * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, */ __pyx_v_file_format = __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_STATA; /* "pyreadstat/pyreadstat.pyx":295 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_STATA * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_DTA # <<<<<<<<<<<<<< * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, */ __pyx_v_file_extension = __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_DTA; /* "pyreadstat/pyreadstat.pyx":296 * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_STATA * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_DTA * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, # <<<<<<<<<<<<<< * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) */ __pyx_t_2 = __pyx_f_10pyreadstat_16_readstat_parser_run_conversion(__pyx_v_filename_path, __pyx_v_file_format, __pyx_v_file_extension, __pyx_v_encoding, __pyx_v_metaonly, __pyx_v_dates_as_pandas, __pyx_v_usecols, __pyx_v_usernan, __pyx_v_no_datetime_conversion, ((long)__pyx_v_row_limit), ((long)__pyx_v_row_offset), __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 296, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 296, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L8_unpacking_done; __pyx_L7_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 296, __pyx_L1_error) __pyx_L8_unpacking_done:; } __pyx_v_data_frame = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_metadata = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":299 * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) * metadata.file_format = "dta" # <<<<<<<<<<<<<< * * if apply_value_formats: */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_file_format, __pyx_n_s_dta) < 0) __PYX_ERR(0, 299, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":301 * metadata.file_format = "dta" * * if apply_value_formats: # <<<<<<<<<<<<<< * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, * formats_as_ordered_category=formats_as_ordered_category) */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_apply_value_formats); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 301, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":302 * * if apply_value_formats: * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, # <<<<<<<<<<<<<< * formats_as_ordered_category=formats_as_ordered_category) * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_set_value_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_data_frame)) __PYX_ERR(0, 302, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_metadata)) __PYX_ERR(0, 302, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_formats_as_category, __pyx_v_formats_as_category) < 0) __PYX_ERR(0, 302, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":303 * if apply_value_formats: * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, * formats_as_ordered_category=formats_as_ordered_category) # <<<<<<<<<<<<<< * * return data_frame, metadata */ if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_formats_as_ordered_category, __pyx_v_formats_as_ordered_category) < 0) __PYX_ERR(0, 302, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":302 * * if apply_value_formats: * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, # <<<<<<<<<<<<<< * formats_as_ordered_category=formats_as_ordered_category) * */ __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_data_frame, __pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/pyreadstat.pyx":301 * metadata.file_format = "dta" * * if apply_value_formats: # <<<<<<<<<<<<<< * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, * formats_as_ordered_category=formats_as_ordered_category) */ } /* "pyreadstat/pyreadstat.pyx":305 * formats_as_ordered_category=formats_as_ordered_category) * * return data_frame, metadata # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_data_frame)) __PYX_ERR(0, 305, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_metadata)) __PYX_ERR(0, 305, __pyx_L1_error); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; /* "pyreadstat/pyreadstat.pyx":215 * * * def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("pyreadstat.pyreadstat.read_dta", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_data_frame); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":308 * * * def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_7read_sav(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_6read_sav, "\n Read a SPSS sav or zsav (compressed) files\n\n Parameters\n ----------\n filename_path : str, bytes or Path-like object\n path to the file. In Python 2.7 the string is assumed to be utf-8 encoded\n metadataonly : bool, optional\n by default False. IF true, no data will be read but only metadata, so that you can get all elements in the\n metadata object. The data frame will be set with the correct column names but no data.\n dates_as_pandas_datetime : bool, optional\n by default False. If true dates will be transformed to pandas datetime64 instead of date.\n apply_value_formats : bool, optional\n by default False. If true it will change values in the dataframe for they value labels in the metadata,\n if any appropiate are found.\n formats_as_category : bool, optional\n by default True. Takes effect only if apply_value_formats is True. If True, variables with values changed\n for their formatted version will be transformed into pandas categories.\n formats_as_ordered_category : bool, optional\n defaults to False. If True the variables having formats will be transformed into pandas ordered categories.\n it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of\n the value of formats_as_category.\n encoding : str, optional\n Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an\n iconv-compatible name\n usecols : list, optional\n a list with column names to read from the file. Only those columns will be imported. Case sensitive!\n user_missing : bool, optional\n by default False, in this case user defined missing values are delivered as nan. If true, the missing values\n will be deliver as is, and an extra piece of informatio""n will be set in the metadata (missing_ranges)\n to be able to interpret those values as missing.\n disable_datetime_conversion : bool, optional\n if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns\n will remain as numbers. In order to convert them later to an appropiate python object, the user can use the\n information about the original variable format stored in the metadata object in original_variable_types.\n Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where\n there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates\n beyond that will rise an Overflow error in pyreadstat).\n row_limit : int, optional\n maximum number of rows to read. The default is 0 meaning unlimited.\n row_offset : int, optional\n start reading rows after this offset. By default 0, meaning start with the first row not skipping anything.\n output_format : str, optional\n one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the\n user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas\n dataframe is avoided.\n extra_datetime_formats: list of str, optional\n formats to be parsed as python datetime objects\n extra_date_formats: list of str, optional\n formats to be parsed as python date objects\n\n Returns\n -------\n data_frame : pandas dataframe\n a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly.\n metadata :\n object with metadata. Look at the documentation for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_7read_sav = {"read_sav", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_7read_sav, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_6read_sav}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_7read_sav(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_filename_path = 0; PyObject *__pyx_v_metadataonly = 0; PyObject *__pyx_v_dates_as_pandas_datetime = 0; PyObject *__pyx_v_apply_value_formats = 0; PyObject *__pyx_v_formats_as_category = 0; PyObject *__pyx_v_formats_as_ordered_category = 0; PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_usecols = 0; PyObject *__pyx_v_user_missing = 0; PyObject *__pyx_v_disable_datetime_conversion = 0; int __pyx_v_row_limit; int __pyx_v_row_offset; PyObject *__pyx_v_output_format = 0; PyObject *__pyx_v_extra_datetime_formats = 0; PyObject *__pyx_v_extra_date_formats = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_sav (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename_path,&__pyx_n_s_metadataonly,&__pyx_n_s_dates_as_pandas_datetime,&__pyx_n_s_apply_value_formats,&__pyx_n_s_formats_as_category,&__pyx_n_s_formats_as_ordered_category,&__pyx_n_s_encoding,&__pyx_n_s_usecols,&__pyx_n_s_user_missing,&__pyx_n_s_disable_datetime_conversion,&__pyx_n_s_row_limit,&__pyx_n_s_row_offset,&__pyx_n_s_output_format,&__pyx_n_s_extra_datetime_formats,&__pyx_n_s_extra_date_formats,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); /* "pyreadstat/pyreadstat.pyx":309 * * def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, # <<<<<<<<<<<<<< * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, * list extra_date_formats=None): */ values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); /* "pyreadstat/pyreadstat.pyx":310 * def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, # <<<<<<<<<<<<<< * list extra_date_formats=None): * r""" */ values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[12] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[13] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":311 * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, * list extra_date_formats=None): # <<<<<<<<<<<<<< * r""" * Read a SPSS sav or zsav (compressed) files */ values[14] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 15: values[14] = __Pyx_Arg_FASTCALL(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = __Pyx_Arg_FASTCALL(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_metadataonly); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dates_as_pandas_datetime); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_apply_value_formats); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_formats_as_category); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_formats_as_ordered_category); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_encoding); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_usecols); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_user_missing); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_disable_datetime_conversion); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_limit); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 11: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_offset); if (value) { values[11] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 12: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_output_format); if (value) { values[12] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 13: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_datetime_formats); if (value) { values[13] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 14: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_date_formats); if (value) { values[14] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "read_sav") < 0)) __PYX_ERR(0, 308, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 15: values[14] = __Pyx_Arg_FASTCALL(__pyx_args, 14); CYTHON_FALLTHROUGH; case 14: values[13] = __Pyx_Arg_FASTCALL(__pyx_args, 13); CYTHON_FALLTHROUGH; case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_filename_path = values[0]; __pyx_v_metadataonly = values[1]; __pyx_v_dates_as_pandas_datetime = values[2]; __pyx_v_apply_value_formats = values[3]; __pyx_v_formats_as_category = values[4]; __pyx_v_formats_as_ordered_category = values[5]; __pyx_v_encoding = ((PyObject*)values[6]); __pyx_v_usecols = ((PyObject*)values[7]); __pyx_v_user_missing = values[8]; __pyx_v_disable_datetime_conversion = values[9]; if (values[10]) { __pyx_v_row_limit = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_row_limit == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 310, __pyx_L3_error) } else { __pyx_v_row_limit = ((int)((int)0)); } if (values[11]) { __pyx_v_row_offset = __Pyx_PyInt_As_int(values[11]); if (unlikely((__pyx_v_row_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 310, __pyx_L3_error) } else { __pyx_v_row_offset = ((int)((int)0)); } __pyx_v_output_format = ((PyObject*)values[12]); __pyx_v_extra_datetime_formats = ((PyObject*)values[13]); __pyx_v_extra_date_formats = ((PyObject*)values[14]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_sav", 0, 1, 15, __pyx_nargs); __PYX_ERR(0, 308, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.read_sav", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_encoding), (&PyString_Type), 1, "encoding", 1))) __PYX_ERR(0, 309, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_usecols), (&PyList_Type), 1, "usecols", 1))) __PYX_ERR(0, 309, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output_format), (&PyString_Type), 1, "output_format", 1))) __PYX_ERR(0, 310, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_datetime_formats), (&PyList_Type), 1, "extra_datetime_formats", 1))) __PYX_ERR(0, 310, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_date_formats), (&PyList_Type), 1, "extra_date_formats", 1))) __PYX_ERR(0, 311, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_6read_sav(__pyx_self, __pyx_v_filename_path, __pyx_v_metadataonly, __pyx_v_dates_as_pandas_datetime, __pyx_v_apply_value_formats, __pyx_v_formats_as_category, __pyx_v_formats_as_ordered_category, __pyx_v_encoding, __pyx_v_usecols, __pyx_v_user_missing, __pyx_v_disable_datetime_conversion, __pyx_v_row_limit, __pyx_v_row_offset, __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); /* "pyreadstat/pyreadstat.pyx":308 * * * def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_6read_sav(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_apply_value_formats, PyObject *__pyx_v_formats_as_category, PyObject *__pyx_v_formats_as_ordered_category, PyObject *__pyx_v_encoding, PyObject *__pyx_v_usecols, PyObject *__pyx_v_user_missing, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats) { int __pyx_v_metaonly; int __pyx_v_dates_as_pandas; int __pyx_v_usernan; int __pyx_v_no_datetime_conversion; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format; __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_v_file_extension; PyObject *__pyx_v_data_frame = NULL; PyObject *__pyx_v_metadata = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *(*__pyx_t_6)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_sav", 1); /* "pyreadstat/pyreadstat.pyx":371 * """ * * cdef bint metaonly = 0 # <<<<<<<<<<<<<< * if metadataonly: * metaonly = 1 */ __pyx_v_metaonly = 0; /* "pyreadstat/pyreadstat.pyx":372 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_metadataonly); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 372, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":373 * cdef bint metaonly = 0 * if metadataonly: * metaonly = 1 # <<<<<<<<<<<<<< * * cdef bint dates_as_pandas = 0 */ __pyx_v_metaonly = 1; /* "pyreadstat/pyreadstat.pyx":372 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ } /* "pyreadstat/pyreadstat.pyx":375 * metaonly = 1 * * cdef bint dates_as_pandas = 0 # <<<<<<<<<<<<<< * if dates_as_pandas_datetime: * dates_as_pandas = 1 */ __pyx_v_dates_as_pandas = 0; /* "pyreadstat/pyreadstat.pyx":376 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_dates_as_pandas_datetime); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 376, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":377 * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: * dates_as_pandas = 1 # <<<<<<<<<<<<<< * * cdef bint usernan = 0 */ __pyx_v_dates_as_pandas = 1; /* "pyreadstat/pyreadstat.pyx":376 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ } /* "pyreadstat/pyreadstat.pyx":379 * dates_as_pandas = 1 * * cdef bint usernan = 0 # <<<<<<<<<<<<<< * if user_missing: * usernan = 1 */ __pyx_v_usernan = 0; /* "pyreadstat/pyreadstat.pyx":380 * * cdef bint usernan = 0 * if user_missing: # <<<<<<<<<<<<<< * usernan = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_user_missing); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 380, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":381 * cdef bint usernan = 0 * if user_missing: * usernan = 1 # <<<<<<<<<<<<<< * * cdef bint no_datetime_conversion = 0 */ __pyx_v_usernan = 1; /* "pyreadstat/pyreadstat.pyx":380 * * cdef bint usernan = 0 * if user_missing: # <<<<<<<<<<<<<< * usernan = 1 * */ } /* "pyreadstat/pyreadstat.pyx":383 * usernan = 1 * * cdef bint no_datetime_conversion = 0 # <<<<<<<<<<<<<< * if disable_datetime_conversion: * no_datetime_conversion = 1 */ __pyx_v_no_datetime_conversion = 0; /* "pyreadstat/pyreadstat.pyx":384 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_disable_datetime_conversion); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 384, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":385 * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: * no_datetime_conversion = 1 # <<<<<<<<<<<<<< * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS */ __pyx_v_no_datetime_conversion = 1; /* "pyreadstat/pyreadstat.pyx":384 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ } /* "pyreadstat/pyreadstat.pyx":387 * no_datetime_conversion = 1 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS # <<<<<<<<<<<<<< * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAV * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, */ __pyx_v_file_format = __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS; /* "pyreadstat/pyreadstat.pyx":388 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAV # <<<<<<<<<<<<<< * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, */ __pyx_v_file_extension = __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAV; /* "pyreadstat/pyreadstat.pyx":389 * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAV * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, # <<<<<<<<<<<<<< * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) */ __pyx_t_2 = __pyx_f_10pyreadstat_16_readstat_parser_run_conversion(__pyx_v_filename_path, __pyx_v_file_format, __pyx_v_file_extension, __pyx_v_encoding, __pyx_v_metaonly, __pyx_v_dates_as_pandas, __pyx_v_usecols, __pyx_v_usernan, __pyx_v_no_datetime_conversion, ((long)__pyx_v_row_limit), ((long)__pyx_v_row_offset), __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 389, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 389, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L8_unpacking_done; __pyx_L7_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 389, __pyx_L1_error) __pyx_L8_unpacking_done:; } __pyx_v_data_frame = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_metadata = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":392 * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) * metadata.file_format = "sav/zsav" # <<<<<<<<<<<<<< * * if apply_value_formats: */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_file_format, __pyx_kp_s_sav_zsav) < 0) __PYX_ERR(0, 392, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":394 * metadata.file_format = "sav/zsav" * * if apply_value_formats: # <<<<<<<<<<<<<< * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, * formats_as_ordered_category=formats_as_ordered_category) */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_apply_value_formats); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 394, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":395 * * if apply_value_formats: * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, # <<<<<<<<<<<<<< * formats_as_ordered_category=formats_as_ordered_category) * */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_set_value_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_data_frame)) __PYX_ERR(0, 395, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_metadata)) __PYX_ERR(0, 395, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_formats_as_category, __pyx_v_formats_as_category) < 0) __PYX_ERR(0, 395, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":396 * if apply_value_formats: * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, * formats_as_ordered_category=formats_as_ordered_category) # <<<<<<<<<<<<<< * * return data_frame, metadata */ if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_formats_as_ordered_category, __pyx_v_formats_as_ordered_category) < 0) __PYX_ERR(0, 395, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":395 * * if apply_value_formats: * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, # <<<<<<<<<<<<<< * formats_as_ordered_category=formats_as_ordered_category) * */ __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_data_frame, __pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/pyreadstat.pyx":394 * metadata.file_format = "sav/zsav" * * if apply_value_formats: # <<<<<<<<<<<<<< * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, * formats_as_ordered_category=formats_as_ordered_category) */ } /* "pyreadstat/pyreadstat.pyx":398 * formats_as_ordered_category=formats_as_ordered_category) * * return data_frame, metadata # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_data_frame)) __PYX_ERR(0, 398, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_metadata)) __PYX_ERR(0, 398, __pyx_L1_error); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; /* "pyreadstat/pyreadstat.pyx":308 * * * def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("pyreadstat.pyreadstat.read_sav", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_data_frame); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":401 * * * def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_9read_por(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_8read_por, "\n Read a SPSS por file. Files are assumed to be UTF-8 encoded, the encoding cannot be set to other.\n\n Parameters\n ----------\n filename_path : str, bytes or Path-like object\n path to the file. In Python 2.7 the string is assumed to be utf-8 encoded\n metadataonly : bool, optional\n by default False. IF true, no data will be read but only metadata, so that you can get all elements in the\n metadata object. The data frame will be set with the correct column names but no data.\n Notice that number_rows will be None as por files do not have the number of rows recorded in the file metadata.\n dates_as_pandas_datetime : bool, optional\n by default False. If true dates will be transformed to pandas datetime64 instead of date.\n apply_value_formats : bool, optional\n by default False. If true it will change values in the dataframe for they value labels in the metadata,\n if any appropiate are found.\n formats_as_category : bool, optional\n by default True. Takes effect only if apply_value_formats is True. If True, variables with values changed\n for their formatted version will be transformed into pandas categories.\n formats_as_ordered_category : bool, optional\n defaults to False. If True the variables having formats will be transformed into pandas ordered categories.\n it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of\n the value of formats_as_category.\n usecols : list, optional\n a list with column names to read from the file. Only those columns will be imported. Case sensitive!\n disable_datetime_conversion : bool, optional\n if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns\n will remain as numbers. In order to convert them"" later to an appropiate python object, the user can use the\n information about the original variable format stored in the metadata object in original_variable_types.\n Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where\n there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates\n beyond that will rise an Overflow error in pyreadstat).\n row_limit : int, optional\n maximum number of rows to read. The default is 0 meaning unlimited.\n row_offset : int, optional\n start reading rows after this offset. By default 0, meaning start with the first row not skipping anything.\n output_format : str, optional\n one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the\n user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas\n dataframe is avoided.\n extra_datetime_formats: list of str, optional\n formats to be parsed as python datetime objects\n extra_date_formats: list of str, optional\n formats to be parsed as python date objects\n\n Returns\n -------\n data_frame : pandas dataframe\n a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly.\n metadata :\n object with metadata. Look at the documentation for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_9read_por = {"read_por", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_9read_por, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_8read_por}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_9read_por(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_filename_path = 0; PyObject *__pyx_v_metadataonly = 0; PyObject *__pyx_v_dates_as_pandas_datetime = 0; PyObject *__pyx_v_apply_value_formats = 0; PyObject *__pyx_v_formats_as_category = 0; CYTHON_UNUSED PyObject *__pyx_v_formats_as_ordered_category = 0; PyObject *__pyx_v_usecols = 0; PyObject *__pyx_v_disable_datetime_conversion = 0; int __pyx_v_row_limit; int __pyx_v_row_offset; PyObject *__pyx_v_output_format = 0; PyObject *__pyx_v_extra_datetime_formats = 0; PyObject *__pyx_v_extra_date_formats = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_por (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename_path,&__pyx_n_s_metadataonly,&__pyx_n_s_dates_as_pandas_datetime,&__pyx_n_s_apply_value_formats,&__pyx_n_s_formats_as_category,&__pyx_n_s_formats_as_ordered_category,&__pyx_n_s_usecols,&__pyx_n_s_disable_datetime_conversion,&__pyx_n_s_row_limit,&__pyx_n_s_row_offset,&__pyx_n_s_output_format,&__pyx_n_s_extra_datetime_formats,&__pyx_n_s_extra_date_formats,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); /* "pyreadstat/pyreadstat.pyx":402 * * def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, # <<<<<<<<<<<<<< * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, * list extra_datetime_formats=None, list extra_date_formats=None): */ values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":403 * def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, # <<<<<<<<<<<<<< * list extra_datetime_formats=None, list extra_date_formats=None): * r""" */ values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[10] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":404 * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, * list extra_datetime_formats=None, list extra_date_formats=None): # <<<<<<<<<<<<<< * r""" * Read a SPSS por file. Files are assumed to be UTF-8 encoded, the encoding cannot be set to other. */ values[11] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[12] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_metadataonly); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dates_as_pandas_datetime); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_apply_value_formats); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_formats_as_category); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_formats_as_ordered_category); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_usecols); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_disable_datetime_conversion); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_limit); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_offset); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_output_format); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 11: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_datetime_formats); if (value) { values[11] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 12: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extra_date_formats); if (value) { values[12] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 401, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "read_por") < 0)) __PYX_ERR(0, 401, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_filename_path = values[0]; __pyx_v_metadataonly = values[1]; __pyx_v_dates_as_pandas_datetime = values[2]; __pyx_v_apply_value_formats = values[3]; __pyx_v_formats_as_category = values[4]; __pyx_v_formats_as_ordered_category = values[5]; __pyx_v_usecols = ((PyObject*)values[6]); __pyx_v_disable_datetime_conversion = values[7]; if (values[8]) { __pyx_v_row_limit = __Pyx_PyInt_As_int(values[8]); if (unlikely((__pyx_v_row_limit == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 403, __pyx_L3_error) } else { __pyx_v_row_limit = ((int)((int)0)); } if (values[9]) { __pyx_v_row_offset = __Pyx_PyInt_As_int(values[9]); if (unlikely((__pyx_v_row_offset == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 403, __pyx_L3_error) } else { __pyx_v_row_offset = ((int)((int)0)); } __pyx_v_output_format = ((PyObject*)values[10]); __pyx_v_extra_datetime_formats = ((PyObject*)values[11]); __pyx_v_extra_date_formats = ((PyObject*)values[12]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_por", 0, 1, 13, __pyx_nargs); __PYX_ERR(0, 401, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.read_por", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_usecols), (&PyList_Type), 1, "usecols", 1))) __PYX_ERR(0, 402, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output_format), (&PyString_Type), 1, "output_format", 1))) __PYX_ERR(0, 403, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_datetime_formats), (&PyList_Type), 1, "extra_datetime_formats", 1))) __PYX_ERR(0, 404, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_extra_date_formats), (&PyList_Type), 1, "extra_date_formats", 1))) __PYX_ERR(0, 404, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_8read_por(__pyx_self, __pyx_v_filename_path, __pyx_v_metadataonly, __pyx_v_dates_as_pandas_datetime, __pyx_v_apply_value_formats, __pyx_v_formats_as_category, __pyx_v_formats_as_ordered_category, __pyx_v_usecols, __pyx_v_disable_datetime_conversion, __pyx_v_row_limit, __pyx_v_row_offset, __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); /* "pyreadstat/pyreadstat.pyx":401 * * * def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_8read_por(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_metadataonly, PyObject *__pyx_v_dates_as_pandas_datetime, PyObject *__pyx_v_apply_value_formats, PyObject *__pyx_v_formats_as_category, CYTHON_UNUSED PyObject *__pyx_v_formats_as_ordered_category, PyObject *__pyx_v_usecols, PyObject *__pyx_v_disable_datetime_conversion, int __pyx_v_row_limit, int __pyx_v_row_offset, PyObject *__pyx_v_output_format, PyObject *__pyx_v_extra_datetime_formats, PyObject *__pyx_v_extra_date_formats) { int __pyx_v_metaonly; int __pyx_v_dates_as_pandas; int __pyx_v_usernan; int __pyx_v_no_datetime_conversion; PyObject *__pyx_v_encoding = 0; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format; __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_v_file_extension; PyObject *__pyx_v_data_frame = NULL; PyObject *__pyx_v_metadata = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *(*__pyx_t_6)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_por", 1); /* "pyreadstat/pyreadstat.pyx":458 * """ * * cdef bint metaonly = 0 # <<<<<<<<<<<<<< * if metadataonly: * metaonly = 1 */ __pyx_v_metaonly = 0; /* "pyreadstat/pyreadstat.pyx":459 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_metadataonly); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 459, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":460 * cdef bint metaonly = 0 * if metadataonly: * metaonly = 1 # <<<<<<<<<<<<<< * * cdef bint dates_as_pandas = 0 */ __pyx_v_metaonly = 1; /* "pyreadstat/pyreadstat.pyx":459 * * cdef bint metaonly = 0 * if metadataonly: # <<<<<<<<<<<<<< * metaonly = 1 * */ } /* "pyreadstat/pyreadstat.pyx":462 * metaonly = 1 * * cdef bint dates_as_pandas = 0 # <<<<<<<<<<<<<< * if dates_as_pandas_datetime: * dates_as_pandas = 1 */ __pyx_v_dates_as_pandas = 0; /* "pyreadstat/pyreadstat.pyx":463 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_dates_as_pandas_datetime); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 463, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":464 * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: * dates_as_pandas = 1 # <<<<<<<<<<<<<< * * cdef bint usernan = 0 */ __pyx_v_dates_as_pandas = 1; /* "pyreadstat/pyreadstat.pyx":463 * * cdef bint dates_as_pandas = 0 * if dates_as_pandas_datetime: # <<<<<<<<<<<<<< * dates_as_pandas = 1 * */ } /* "pyreadstat/pyreadstat.pyx":466 * dates_as_pandas = 1 * * cdef bint usernan = 0 # <<<<<<<<<<<<<< * * cdef bint no_datetime_conversion = 0 */ __pyx_v_usernan = 0; /* "pyreadstat/pyreadstat.pyx":468 * cdef bint usernan = 0 * * cdef bint no_datetime_conversion = 0 # <<<<<<<<<<<<<< * if disable_datetime_conversion: * no_datetime_conversion = 1 */ __pyx_v_no_datetime_conversion = 0; /* "pyreadstat/pyreadstat.pyx":469 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_disable_datetime_conversion); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 469, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":470 * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: * no_datetime_conversion = 1 # <<<<<<<<<<<<<< * * cdef str encoding = None */ __pyx_v_no_datetime_conversion = 1; /* "pyreadstat/pyreadstat.pyx":469 * * cdef bint no_datetime_conversion = 0 * if disable_datetime_conversion: # <<<<<<<<<<<<<< * no_datetime_conversion = 1 * */ } /* "pyreadstat/pyreadstat.pyx":472 * no_datetime_conversion = 1 * * cdef str encoding = None # <<<<<<<<<<<<<< * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS */ __Pyx_INCREF(Py_None); __pyx_v_encoding = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":474 * cdef str encoding = None * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS # <<<<<<<<<<<<<< * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_POR * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, */ __pyx_v_file_format = __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SPSS; /* "pyreadstat/pyreadstat.pyx":475 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_POR # <<<<<<<<<<<<<< * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, */ __pyx_v_file_extension = __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_POR; /* "pyreadstat/pyreadstat.pyx":476 * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_POR * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, # <<<<<<<<<<<<<< * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) */ __pyx_t_2 = __pyx_f_10pyreadstat_16_readstat_parser_run_conversion(__pyx_v_filename_path, __pyx_v_file_format, __pyx_v_file_extension, __pyx_v_encoding, __pyx_v_metaonly, __pyx_v_dates_as_pandas, __pyx_v_usecols, __pyx_v_usernan, __pyx_v_no_datetime_conversion, ((long)__pyx_v_row_limit), ((long)__pyx_v_row_offset), __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 476, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 476, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 476, __pyx_L1_error) __pyx_L7_unpacking_done:; } __pyx_v_data_frame = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_metadata = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":479 * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) * metadata.file_format = "por" # <<<<<<<<<<<<<< * if apply_value_formats: * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category) */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_file_format, __pyx_n_s_por) < 0) __PYX_ERR(0, 479, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":480 * output_format, extra_datetime_formats, extra_date_formats) * metadata.file_format = "por" * if apply_value_formats: # <<<<<<<<<<<<<< * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category) * */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_apply_value_formats); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 480, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":481 * metadata.file_format = "por" * if apply_value_formats: * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category) # <<<<<<<<<<<<<< * * return data_frame, metadata */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_set_value_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_data_frame)) __PYX_ERR(0, 481, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_metadata)) __PYX_ERR(0, 481, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_formats_as_category, __pyx_v_formats_as_category) < 0) __PYX_ERR(0, 481, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_data_frame, __pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/pyreadstat.pyx":480 * output_format, extra_datetime_formats, extra_date_formats) * metadata.file_format = "por" * if apply_value_formats: # <<<<<<<<<<<<<< * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category) * */ } /* "pyreadstat/pyreadstat.pyx":483 * data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category) * * return data_frame, metadata # <<<<<<<<<<<<<< * * */ __Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 483, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_data_frame)) __PYX_ERR(0, 483, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_metadata)) __PYX_ERR(0, 483, __pyx_L1_error); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; /* "pyreadstat/pyreadstat.pyx":401 * * * def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("pyreadstat.pyreadstat.read_por", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_encoding); __Pyx_XDECREF(__pyx_v_data_frame); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":486 * * * def read_sas7bcat(filename_path, str encoding=None, str output_format=None): # <<<<<<<<<<<<<< * r""" * Read a SAS sas7bcat file. The returning dataframe will be empty. The metadata object will contain a dictionary */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_11read_sas7bcat(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_10read_sas7bcat, "\n Read a SAS sas7bcat file. The returning dataframe will be empty. The metadata object will contain a dictionary\n value_labels that contains the formats. When parsing the sas7bdat file, in the metadata, the dictionary\n variable_to_label contains a map from variable name to the formats.\n In order to apply the catalog to the sas7bdat file use set_catalog_to_sas or pass the catalog file as an argument\n to read_sas7bdat directly.\n SAS catalog files are difficult ones, some of them can be read only in specific SAS version, may contain strange\n encodings etc. Therefore it may be that many catalog files are not readable from this application.\n\n Parameters\n ----------\n filename_path : str, bytes or Path-like object\n path to the file. The string is assumed to be utf-8 encoded\n encoding : str, optional\n Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an\n iconv-compatible name\n output_format : str, optional\n one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned. \n Notice that for this function the resulting object is always empty, this is done for consistency with other functions\n but has no impact on performance.\n\n Returns\n -------\n data_frame : pandas dataframe\n a pandas data frame with the data (no data in this case, so will be empty). If the output_parameter is other\n than 'pandas' then the object type will change accordingly altough the object will always be empty\n metadata :\n object with metadata. The member value_labels is the one that contains the formats.\n Look at the documentation for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_11read_sas7bcat = {"read_sas7bcat", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_11read_sas7bcat, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_10read_sas7bcat}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_11read_sas7bcat(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_filename_path = 0; PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_output_format = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[3] = {0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_sas7bcat (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename_path,&__pyx_n_s_encoding,&__pyx_n_s_output_format,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_encoding); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_output_format); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 486, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "read_sas7bcat") < 0)) __PYX_ERR(0, 486, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_filename_path = values[0]; __pyx_v_encoding = ((PyObject*)values[1]); __pyx_v_output_format = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_sas7bcat", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 486, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.read_sas7bcat", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_encoding), (&PyString_Type), 1, "encoding", 1))) __PYX_ERR(0, 486, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_output_format), (&PyString_Type), 1, "output_format", 1))) __PYX_ERR(0, 486, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_10read_sas7bcat(__pyx_self, __pyx_v_filename_path, __pyx_v_encoding, __pyx_v_output_format); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_10read_sas7bcat(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename_path, PyObject *__pyx_v_encoding, PyObject *__pyx_v_output_format) { int __pyx_v_metaonly; int __pyx_v_dates_as_pandas; PyObject *__pyx_v_usecols = 0; int __pyx_v_usernan; int __pyx_v_no_datetime_conversion; long __pyx_v_row_limit; long __pyx_v_row_offset; PyObject *__pyx_v_extra_datetime_formats = 0; PyObject *__pyx_v_extra_date_formats = 0; __pyx_t_10pyreadstat_16_readstat_parser_py_file_format __pyx_v_file_format; __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension __pyx_v_file_extension; PyObject *__pyx_v_data_frame = NULL; PyObject *__pyx_v_metadata = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *(*__pyx_t_5)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_sas7bcat", 1); /* "pyreadstat/pyreadstat.pyx":517 * Look at the documentation for more information. * """ * cdef bint metaonly = 1 # <<<<<<<<<<<<<< * cdef bint dates_as_pandas = 0 * cdef list usecols = None */ __pyx_v_metaonly = 1; /* "pyreadstat/pyreadstat.pyx":518 * """ * cdef bint metaonly = 1 * cdef bint dates_as_pandas = 0 # <<<<<<<<<<<<<< * cdef list usecols = None * cdef bint usernan = 0 */ __pyx_v_dates_as_pandas = 0; /* "pyreadstat/pyreadstat.pyx":519 * cdef bint metaonly = 1 * cdef bint dates_as_pandas = 0 * cdef list usecols = None # <<<<<<<<<<<<<< * cdef bint usernan = 0 * cdef bint no_datetime_conversion = 0 */ __Pyx_INCREF(Py_None); __pyx_v_usecols = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":520 * cdef bint dates_as_pandas = 0 * cdef list usecols = None * cdef bint usernan = 0 # <<<<<<<<<<<<<< * cdef bint no_datetime_conversion = 0 * cdef long row_limit=0 */ __pyx_v_usernan = 0; /* "pyreadstat/pyreadstat.pyx":521 * cdef list usecols = None * cdef bint usernan = 0 * cdef bint no_datetime_conversion = 0 # <<<<<<<<<<<<<< * cdef long row_limit=0 * cdef long row_offset=0 */ __pyx_v_no_datetime_conversion = 0; /* "pyreadstat/pyreadstat.pyx":522 * cdef bint usernan = 0 * cdef bint no_datetime_conversion = 0 * cdef long row_limit=0 # <<<<<<<<<<<<<< * cdef long row_offset=0 * cdef list extra_datetime_formats=None */ __pyx_v_row_limit = 0; /* "pyreadstat/pyreadstat.pyx":523 * cdef bint no_datetime_conversion = 0 * cdef long row_limit=0 * cdef long row_offset=0 # <<<<<<<<<<<<<< * cdef list extra_datetime_formats=None * cdef list extra_date_formats=None */ __pyx_v_row_offset = 0; /* "pyreadstat/pyreadstat.pyx":524 * cdef long row_limit=0 * cdef long row_offset=0 * cdef list extra_datetime_formats=None # <<<<<<<<<<<<<< * cdef list extra_date_formats=None * */ __Pyx_INCREF(Py_None); __pyx_v_extra_datetime_formats = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":525 * cdef long row_offset=0 * cdef list extra_datetime_formats=None * cdef list extra_date_formats=None # <<<<<<<<<<<<<< * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS */ __Pyx_INCREF(Py_None); __pyx_v_extra_date_formats = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":527 * cdef list extra_date_formats=None * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS # <<<<<<<<<<<<<< * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAS7BCAT * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, */ __pyx_v_file_format = __pyx_e_10pyreadstat_16_readstat_parser_FILE_FORMAT_SAS; /* "pyreadstat/pyreadstat.pyx":528 * * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAS7BCAT # <<<<<<<<<<<<<< * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, */ __pyx_v_file_extension = __pyx_e_10pyreadstat_16_readstat_parser_FILE_EXT_SAS7BCAT; /* "pyreadstat/pyreadstat.pyx":529 * cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS * cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAS7BCAT * data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, # <<<<<<<<<<<<<< * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) */ __pyx_t_1 = __pyx_f_10pyreadstat_16_readstat_parser_run_conversion(__pyx_v_filename_path, __pyx_v_file_format, __pyx_v_file_extension, __pyx_v_encoding, __pyx_v_metaonly, __pyx_v_dates_as_pandas, __pyx_v_usecols, __pyx_v_usernan, __pyx_v_no_datetime_conversion, __pyx_v_row_limit, __pyx_v_row_offset, __pyx_v_output_format, __pyx_v_extra_datetime_formats, __pyx_v_extra_date_formats); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 529, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 529, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 529, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_v_data_frame = __pyx_t_2; __pyx_t_2 = 0; __pyx_v_metadata = __pyx_t_3; __pyx_t_3 = 0; /* "pyreadstat/pyreadstat.pyx":532 * dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, * output_format, extra_datetime_formats, extra_date_formats) * metadata.file_format = "sas7bcat" # <<<<<<<<<<<<<< * * return data_frame, metadata */ if (__Pyx_PyObject_SetAttrStr(__pyx_v_metadata, __pyx_n_s_file_format, __pyx_n_s_sas7bcat) < 0) __PYX_ERR(0, 532, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":534 * metadata.file_format = "sas7bcat" * * return data_frame, metadata # <<<<<<<<<<<<<< * * # convenience functions to read in chunks */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 534, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_data_frame); __Pyx_GIVEREF(__pyx_v_data_frame); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data_frame)) __PYX_ERR(0, 534, __pyx_L1_error); __Pyx_INCREF(__pyx_v_metadata); __Pyx_GIVEREF(__pyx_v_metadata); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_metadata)) __PYX_ERR(0, 534, __pyx_L1_error); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "pyreadstat/pyreadstat.pyx":486 * * * def read_sas7bcat(filename_path, str encoding=None, str output_format=None): # <<<<<<<<<<<<<< * r""" * Read a SAS sas7bcat file. The returning dataframe will be empty. The metadata object will contain a dictionary */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("pyreadstat.pyreadstat.read_sas7bcat", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_usecols); __Pyx_XDECREF(__pyx_v_extra_datetime_formats); __Pyx_XDECREF(__pyx_v_extra_date_formats); __Pyx_XDECREF(__pyx_v_data_frame); __Pyx_XDECREF(__pyx_v_metadata); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_10pyreadstat_10pyreadstat_14generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* "pyreadstat/pyreadstat.pyx":538 * # convenience functions to read in chunks * * def read_file_in_chunks(read_function, file_path, chunksize=100000, offset=0, limit=0, # <<<<<<<<<<<<<< * multiprocess=False, num_processes=4, num_rows=None, **kwargs): * """ */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_13read_file_in_chunks(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_12read_file_in_chunks, "\n Returns a generator that will allow to read a file in chunks.\n\n If using multiprocessing, for Xport, Por and some defective sav files where the number of rows in the dataset canot be obtained from the metadata, \n the parameter num_rows must be set to a number equal or larger than the number of rows in the dataset. That information must\n be obtained by the user before running this function.\n\n Parameters\n ----------\n read_function : pyreadstat function\n a pyreadstat reading function\n file_path : string\n path to the file to be read\n chunksize : integer, optional\n size of the chunks to read\n offset : integer, optional\n start reading the file after certain number of rows\n limit : integer, optional\n stop reading the file after certain number of rows, will be added to offset\n multiprocess: bool, optional\n use multiprocessing to read each chunk?\n num_processes: integer, optional\n in case multiprocess is true, how many workers/processes to spawn?\n num_rows: integer, optional\n number of rows in the dataset. If using multiprocessing it is obligatory for files where\n the number of rows cannot be obtained from the medatata, such as xport, por and \n some defective sav files. The user must obtain this value by reading the file without multiprocessing first or any other means. A number\n larger than the actual number of rows will work as well. Discarded if the number of rows can be obtained from the metadata or not using\n multiprocessing.\n kwargs : dict, optional\n any other keyword argument to pass to the read_function. row_limit and row_offset will be discarded if present.\n\n Yields\n -------\n data_frame : pandas dataframe\n a pandas data frame with the data\n metadata :\n object with me""tadata. \n Look at the documentation for more information.\n\n it : generator\n A generator that reads the file in chunks.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_13read_file_in_chunks = {"read_file_in_chunks", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_13read_file_in_chunks, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_12read_file_in_chunks}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_13read_file_in_chunks(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_read_function = 0; PyObject *__pyx_v_file_path = 0; PyObject *__pyx_v_chunksize = 0; PyObject *__pyx_v_offset = 0; PyObject *__pyx_v_limit = 0; PyObject *__pyx_v_multiprocess = 0; PyObject *__pyx_v_num_processes = 0; PyObject *__pyx_v_num_rows = 0; PyObject *__pyx_v_kwargs = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[8] = {0,0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_file_in_chunks (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL; __Pyx_GOTREF(__pyx_v_kwargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_read_function,&__pyx_n_s_file_path,&__pyx_n_s_chunksize,&__pyx_n_s_offset,&__pyx_n_s_limit,&__pyx_n_s_multiprocess,&__pyx_n_s_num_processes,&__pyx_n_s_num_rows,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_100000))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); /* "pyreadstat/pyreadstat.pyx":539 * * def read_file_in_chunks(read_function, file_path, chunksize=100000, offset=0, limit=0, * multiprocess=False, num_processes=4, num_rows=None, **kwargs): # <<<<<<<<<<<<<< * """ * Returns a generator that will allow to read a file in chunks. */ values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_4))); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_read_function)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_file_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("read_file_in_chunks", 0, 2, 8, 1); __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_chunksize); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_offset); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_limit); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_multiprocess); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_num_processes); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_num_rows); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 538, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kwargs, values + 0, kwd_pos_args, "read_file_in_chunks") < 0)) __PYX_ERR(0, 538, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_read_function = values[0]; __pyx_v_file_path = values[1]; __pyx_v_chunksize = values[2]; __pyx_v_offset = values[3]; __pyx_v_limit = values[4]; __pyx_v_multiprocess = values[5]; __pyx_v_num_processes = values[6]; __pyx_v_num_rows = values[7]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_file_in_chunks", 0, 2, 8, __pyx_nargs); __PYX_ERR(0, 538, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_CLEAR(__pyx_v_kwargs); __Pyx_AddTraceback("pyreadstat.pyreadstat.read_file_in_chunks", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_12read_file_in_chunks(__pyx_self, __pyx_v_read_function, __pyx_v_file_path, __pyx_v_chunksize, __pyx_v_offset, __pyx_v_limit, __pyx_v_multiprocess, __pyx_v_num_processes, __pyx_v_num_rows, __pyx_v_kwargs); /* "pyreadstat/pyreadstat.pyx":538 * # convenience functions to read in chunks * * def read_file_in_chunks(read_function, file_path, chunksize=100000, offset=0, limit=0, # <<<<<<<<<<<<<< * multiprocess=False, num_processes=4, num_rows=None, **kwargs): * """ */ /* function exit code */ __Pyx_DECREF(__pyx_v_kwargs); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_12read_file_in_chunks(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_read_function, PyObject *__pyx_v_file_path, PyObject *__pyx_v_chunksize, PyObject *__pyx_v_offset, PyObject *__pyx_v_limit, PyObject *__pyx_v_multiprocess, PyObject *__pyx_v_num_processes, PyObject *__pyx_v_num_rows, PyObject *__pyx_v_kwargs) { struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_file_in_chunks", 0); __pyx_cur_scope = (struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *)__pyx_tp_new_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks(__pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 538, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_v_read_function = __pyx_v_read_function; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_read_function); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_read_function); __pyx_cur_scope->__pyx_v_file_path = __pyx_v_file_path; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_file_path); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_file_path); __pyx_cur_scope->__pyx_v_chunksize = __pyx_v_chunksize; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_chunksize); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_chunksize); __pyx_cur_scope->__pyx_v_offset = __pyx_v_offset; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_offset); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_offset); __pyx_cur_scope->__pyx_v_limit = __pyx_v_limit; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_limit); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_limit); __pyx_cur_scope->__pyx_v_multiprocess = __pyx_v_multiprocess; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_multiprocess); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_multiprocess); __pyx_cur_scope->__pyx_v_num_processes = __pyx_v_num_processes; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_num_processes); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_num_processes); __pyx_cur_scope->__pyx_v_num_rows = __pyx_v_num_rows; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_num_rows); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_num_rows); __pyx_cur_scope->__pyx_v_kwargs = __pyx_v_kwargs; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_kwargs); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_kwargs); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10pyreadstat_10pyreadstat_14generator, __pyx_codeobj_, (PyObject *) __pyx_cur_scope, __pyx_n_s_read_file_in_chunks, __pyx_n_s_read_file_in_chunks, __pyx_n_s_pyreadstat_pyreadstat); if (unlikely(!gen)) __PYX_ERR(0, 538, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("pyreadstat.pyreadstat.read_file_in_chunks", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_10pyreadstat_10pyreadstat_14generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *__pyx_cur_scope = ((struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *)__pyx_generator->closure); PyObject *__pyx_r = NULL; PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; int __pyx_t_3; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; PyObject *(*__pyx_t_6)(PyObject *); int __pyx_t_7; Py_ssize_t __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_file_in_chunks", 0); switch (__pyx_generator->resume_label) { case 0: goto __pyx_L3_first_run; case 1: goto __pyx_L24_resume_from_yield; default: /* CPython raises the right error here */ __Pyx_RefNannyFinishContext(); return NULL; } __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 538, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":584 * """ * * if read_function == read_sas7bcat: # <<<<<<<<<<<<<< * raise Exception("read_sas7bcat not supported") * */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_read_sas7bcat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 584, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_read_function, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 584, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 584, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__pyx_t_3)) { /* "pyreadstat/pyreadstat.pyx":585 * * if read_function == read_sas7bcat: * raise Exception("read_sas7bcat not supported") # <<<<<<<<<<<<<< * * if "row_offset" in kwargs: */ __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 585, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 585, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":584 * """ * * if read_function == read_sas7bcat: # <<<<<<<<<<<<<< * raise Exception("read_sas7bcat not supported") * */ } /* "pyreadstat/pyreadstat.pyx":587 * raise Exception("read_sas7bcat not supported") * * if "row_offset" in kwargs: # <<<<<<<<<<<<<< * _ = kwargs.pop("row_offset") * */ __pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_row_offset, __pyx_cur_scope->__pyx_v_kwargs, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 587, __pyx_L1_error) if (__pyx_t_3) { /* "pyreadstat/pyreadstat.pyx":588 * * if "row_offset" in kwargs: * _ = kwargs.pop("row_offset") # <<<<<<<<<<<<<< * * if "row_limit" in kwargs: */ __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_cur_scope->__pyx_v_kwargs, __pyx_n_s_row_offset, ((PyObject *)NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_v__ = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":587 * raise Exception("read_sas7bcat not supported") * * if "row_offset" in kwargs: # <<<<<<<<<<<<<< * _ = kwargs.pop("row_offset") * */ } /* "pyreadstat/pyreadstat.pyx":590 * _ = kwargs.pop("row_offset") * * if "row_limit" in kwargs: # <<<<<<<<<<<<<< * _ = kwargs.pop("row_limit") * */ __pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_row_limit, __pyx_cur_scope->__pyx_v_kwargs, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 590, __pyx_L1_error) if (__pyx_t_3) { /* "pyreadstat/pyreadstat.pyx":591 * * if "row_limit" in kwargs: * _ = kwargs.pop("row_limit") # <<<<<<<<<<<<<< * * if "num_processes" in kwargs: */ __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_cur_scope->__pyx_v_kwargs, __pyx_n_s_row_limit, ((PyObject *)NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":590 * _ = kwargs.pop("row_offset") * * if "row_limit" in kwargs: # <<<<<<<<<<<<<< * _ = kwargs.pop("row_limit") * */ } /* "pyreadstat/pyreadstat.pyx":593 * _ = kwargs.pop("row_limit") * * if "num_processes" in kwargs: # <<<<<<<<<<<<<< * _ = kwargs.pop("num_processes") * */ __pyx_t_3 = (__Pyx_PyDict_ContainsTF(__pyx_n_s_num_processes, __pyx_cur_scope->__pyx_v_kwargs, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 593, __pyx_L1_error) if (__pyx_t_3) { /* "pyreadstat/pyreadstat.pyx":594 * * if "num_processes" in kwargs: * _ = kwargs.pop("num_processes") # <<<<<<<<<<<<<< * * _, meta = read_function(file_path, metadataonly=True) */ __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_cur_scope->__pyx_v_kwargs, __pyx_n_s_num_processes, ((PyObject *)NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":593 * _ = kwargs.pop("row_limit") * * if "num_processes" in kwargs: # <<<<<<<<<<<<<< * _ = kwargs.pop("num_processes") * */ } /* "pyreadstat/pyreadstat.pyx":596 * _ = kwargs.pop("num_processes") * * _, meta = read_function(file_path, metadataonly=True) # <<<<<<<<<<<<<< * numrows = meta.number_rows * if numrows: */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_file_path); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_file_path); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_file_path)) __PYX_ERR(0, 596, __pyx_L1_error); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_metadataonly, Py_True) < 0) __PYX_ERR(0, 596, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_read_function, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 596, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L8_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 596, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L9_unpacking_done; __pyx_L8_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 596, __pyx_L1_error) __pyx_L9_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_v_meta = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":597 * * _, meta = read_function(file_path, metadataonly=True) * numrows = meta.number_rows # <<<<<<<<<<<<<< * if numrows: * if not limit: */ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_meta, __pyx_n_s_number_rows); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_cur_scope->__pyx_v_numrows = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":598 * _, meta = read_function(file_path, metadataonly=True) * numrows = meta.number_rows * if numrows: # <<<<<<<<<<<<<< * if not limit: * limit = numrows */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_numrows); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 598, __pyx_L1_error) if (__pyx_t_3) { /* "pyreadstat/pyreadstat.pyx":599 * numrows = meta.number_rows * if numrows: * if not limit: # <<<<<<<<<<<<<< * limit = numrows * else: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_limit); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 599, __pyx_L1_error) __pyx_t_7 = (!__pyx_t_3); if (__pyx_t_7) { /* "pyreadstat/pyreadstat.pyx":600 * if numrows: * if not limit: * limit = numrows # <<<<<<<<<<<<<< * else: * limit = min(offset+limit, numrows) */ __Pyx_INCREF(__pyx_cur_scope->__pyx_v_numrows); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_limit); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_limit, __pyx_cur_scope->__pyx_v_numrows); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_numrows); /* "pyreadstat/pyreadstat.pyx":599 * numrows = meta.number_rows * if numrows: * if not limit: # <<<<<<<<<<<<<< * limit = numrows * else: */ goto __pyx_L11; } /* "pyreadstat/pyreadstat.pyx":602 * limit = numrows * else: * limit = min(offset+limit, numrows) # <<<<<<<<<<<<<< * else: * if limit: */ /*else*/ { __Pyx_INCREF(__pyx_cur_scope->__pyx_v_numrows); __pyx_t_4 = __pyx_cur_scope->__pyx_v_numrows; __pyx_t_2 = PyNumber_Add(__pyx_cur_scope->__pyx_v_offset, __pyx_cur_scope->__pyx_v_limit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 602, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 602, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 602, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_7) { __Pyx_INCREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; } else { __Pyx_INCREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_limit); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_limit, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_L11:; /* "pyreadstat/pyreadstat.pyx":598 * _, meta = read_function(file_path, metadataonly=True) * numrows = meta.number_rows * if numrows: # <<<<<<<<<<<<<< * if not limit: * limit = numrows */ goto __pyx_L10; } /* "pyreadstat/pyreadstat.pyx":604 * limit = min(offset+limit, numrows) * else: * if limit: # <<<<<<<<<<<<<< * limit = offset + limit * df = [0] */ /*else*/ { __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_limit); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 604, __pyx_L1_error) if (__pyx_t_7) { /* "pyreadstat/pyreadstat.pyx":605 * else: * if limit: * limit = offset + limit # <<<<<<<<<<<<<< * df = [0] * while len(df): */ __pyx_t_4 = PyNumber_Add(__pyx_cur_scope->__pyx_v_offset, __pyx_cur_scope->__pyx_v_limit); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 605, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_limit); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_limit, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":604 * limit = min(offset+limit, numrows) * else: * if limit: # <<<<<<<<<<<<<< * limit = offset + limit * df = [0] */ } } __pyx_L10:; /* "pyreadstat/pyreadstat.pyx":606 * if limit: * limit = offset + limit * df = [0] # <<<<<<<<<<<<<< * while len(df): * if limit and (offset >= limit): */ __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_int_0)) __PYX_ERR(0, 606, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); __pyx_cur_scope->__pyx_v_df = __pyx_t_4; __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":607 * limit = offset + limit * df = [0] * while len(df): # <<<<<<<<<<<<<< * if limit and (offset >= limit): * break */ while (1) { __pyx_t_8 = PyObject_Length(__pyx_cur_scope->__pyx_v_df); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 607, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 != 0); if (!__pyx_t_7) break; /* "pyreadstat/pyreadstat.pyx":608 * df = [0] * while len(df): * if limit and (offset >= limit): # <<<<<<<<<<<<<< * break * if multiprocess: */ __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_limit); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 608, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_7 = __pyx_t_3; goto __pyx_L16_bool_binop_done; } __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_offset, __pyx_cur_scope->__pyx_v_limit, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 608, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = __pyx_t_3; __pyx_L16_bool_binop_done:; if (__pyx_t_7) { /* "pyreadstat/pyreadstat.pyx":609 * while len(df): * if limit and (offset >= limit): * break # <<<<<<<<<<<<<< * if multiprocess: * df, meta = read_file_multiprocessing(read_function, file_path, num_processes=num_processes, */ goto __pyx_L14_break; /* "pyreadstat/pyreadstat.pyx":608 * df = [0] * while len(df): * if limit and (offset >= limit): # <<<<<<<<<<<<<< * break * if multiprocess: */ } /* "pyreadstat/pyreadstat.pyx":610 * if limit and (offset >= limit): * break * if multiprocess: # <<<<<<<<<<<<<< * df, meta = read_file_multiprocessing(read_function, file_path, num_processes=num_processes, * row_offset=offset, row_limit=chunksize, num_rows=num_rows, **kwargs) */ __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_multiprocess); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 610, __pyx_L1_error) if (__pyx_t_7) { /* "pyreadstat/pyreadstat.pyx":611 * break * if multiprocess: * df, meta = read_file_multiprocessing(read_function, file_path, num_processes=num_processes, # <<<<<<<<<<<<<< * row_offset=offset, row_limit=chunksize, num_rows=num_rows, **kwargs) * else: */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_read_file_multiprocessing); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_read_function); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_read_function); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_read_function)) __PYX_ERR(0, 611, __pyx_L1_error); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_file_path); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_file_path); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_file_path)) __PYX_ERR(0, 611, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_num_processes, __pyx_cur_scope->__pyx_v_num_processes) < 0) __PYX_ERR(0, 611, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":612 * if multiprocess: * df, meta = read_file_multiprocessing(read_function, file_path, num_processes=num_processes, * row_offset=offset, row_limit=chunksize, num_rows=num_rows, **kwargs) # <<<<<<<<<<<<<< * else: * df, meta = read_function(file_path, row_offset=offset, row_limit=chunksize, **kwargs) */ if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_row_offset, __pyx_cur_scope->__pyx_v_offset) < 0) __PYX_ERR(0, 611, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_row_limit, __pyx_cur_scope->__pyx_v_chunksize) < 0) __PYX_ERR(0, 611, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_num_rows, __pyx_cur_scope->__pyx_v_num_rows) < 0) __PYX_ERR(0, 611, __pyx_L1_error) __pyx_t_2 = __pyx_t_5; __pyx_t_5 = 0; if (__Pyx_MergeKeywords(__pyx_t_2, __pyx_cur_scope->__pyx_v_kwargs) < 0) __PYX_ERR(0, 612, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":611 * break * if multiprocess: * df, meta = read_file_multiprocessing(read_function, file_path, num_processes=num_processes, # <<<<<<<<<<<<<< * row_offset=offset, row_limit=chunksize, num_rows=num_rows, **kwargs) * else: */ __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 611, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L19_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_1 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L19_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_4), 2) < 0) __PYX_ERR(0, 611, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L20_unpacking_done; __pyx_L19_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 611, __pyx_L1_error) __pyx_L20_unpacking_done:; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_df); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_df, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_meta); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_meta, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":610 * if limit and (offset >= limit): * break * if multiprocess: # <<<<<<<<<<<<<< * df, meta = read_file_multiprocessing(read_function, file_path, num_processes=num_processes, * row_offset=offset, row_limit=chunksize, num_rows=num_rows, **kwargs) */ goto __pyx_L18; } /* "pyreadstat/pyreadstat.pyx":614 * row_offset=offset, row_limit=chunksize, num_rows=num_rows, **kwargs) * else: * df, meta = read_function(file_path, row_offset=offset, row_limit=chunksize, **kwargs) # <<<<<<<<<<<<<< * if len(df): * yield df, meta */ /*else*/ { __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_file_path); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_file_path); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_file_path)) __PYX_ERR(0, 614, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_row_offset, __pyx_cur_scope->__pyx_v_offset) < 0) __PYX_ERR(0, 614, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_row_limit, __pyx_cur_scope->__pyx_v_chunksize) < 0) __PYX_ERR(0, 614, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; if (__Pyx_MergeKeywords(__pyx_t_1, __pyx_cur_scope->__pyx_v_kwargs) < 0) __PYX_ERR(0, 614, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_read_function, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 614, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L21_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_5 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_5)) goto __pyx_L21_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_4), 2) < 0) __PYX_ERR(0, 614, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L22_unpacking_done; __pyx_L21_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 614, __pyx_L1_error) __pyx_L22_unpacking_done:; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_df); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_df, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_meta); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_meta, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_L18:; /* "pyreadstat/pyreadstat.pyx":615 * else: * df, meta = read_function(file_path, row_offset=offset, row_limit=chunksize, **kwargs) * if len(df): # <<<<<<<<<<<<<< * yield df, meta * offset += chunksize */ __pyx_t_8 = PyObject_Length(__pyx_cur_scope->__pyx_v_df); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 615, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 != 0); if (__pyx_t_7) { /* "pyreadstat/pyreadstat.pyx":616 * df, meta = read_function(file_path, row_offset=offset, row_limit=chunksize, **kwargs) * if len(df): * yield df, meta # <<<<<<<<<<<<<< * offset += chunksize * */ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_df); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_df); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_df)) __PYX_ERR(0, 616, __pyx_L1_error); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_meta); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_meta); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_cur_scope->__pyx_v_meta)) __PYX_ERR(0, 616, __pyx_L1_error); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L24_resume_from_yield:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 616, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":617 * if len(df): * yield df, meta * offset += chunksize # <<<<<<<<<<<<<< * * def read_file_multiprocessing(read_function, file_path, num_processes=None, num_rows=None, **kwargs): */ __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_cur_scope->__pyx_v_offset, __pyx_cur_scope->__pyx_v_chunksize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_offset); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_offset, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":615 * else: * df, meta = read_function(file_path, row_offset=offset, row_limit=chunksize, **kwargs) * if len(df): # <<<<<<<<<<<<<< * yield df, meta * offset += chunksize */ } } __pyx_L14_break:; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* "pyreadstat/pyreadstat.pyx":538 * # convenience functions to read in chunks * * def read_file_in_chunks(read_function, file_path, chunksize=100000, offset=0, limit=0, # <<<<<<<<<<<<<< * multiprocess=False, num_processes=4, num_rows=None, **kwargs): * """ */ /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("read_file_in_chunks", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":619 * offset += chunksize * * def read_file_multiprocessing(read_function, file_path, num_processes=None, num_rows=None, **kwargs): # <<<<<<<<<<<<<< * """ * Reads a file in parallel using multiprocessing. */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_16read_file_multiprocessing(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_15read_file_multiprocessing, "\n Reads a file in parallel using multiprocessing.\n For Xport, Por and some defective sav files where the number of rows in the dataset canot be obtained from the metadata, \n the parameter num_rows must be set to a number equal or larger than the number of rows in the dataset. That information must\n be obtained by the user before running this function.\n\n Parameters\n ----------\n read_function : pyreadstat function\n a pyreadstat reading function\n file_path : string\n path to the file to be read\n num_processes : integer, optional\n number of processes to spawn, by default the min 4 and the max cores on the computer\n num_rows: integer, optional\n number of rows in the dataset. Obligatory for files where the number of rows cannot be obtained from the medatata, such as xport, por and \n some defective sav files. The user must obtain this value by reading the file without multiprocessing first or any other means. A number\n larger than the actual number of rows will work as well. Discarded if the number of rows can be obtained from the metadata.\n kwargs : dict, optional\n any other keyword argument to pass to the read_function. \n\n Returns\n -------\n data_frame : pandas dataframe\n a pandas data frame with the data\n metadata :\n object with metadata. Look at the documentation for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_16read_file_multiprocessing = {"read_file_multiprocessing", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_16read_file_multiprocessing, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_15read_file_multiprocessing}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_16read_file_multiprocessing(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_read_function = 0; PyObject *__pyx_v_file_path = 0; PyObject *__pyx_v_num_processes = 0; PyObject *__pyx_v_num_rows = 0; PyObject *__pyx_v_kwargs = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[4] = {0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_file_multiprocessing (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL; __Pyx_GOTREF(__pyx_v_kwargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_read_function,&__pyx_n_s_file_path,&__pyx_n_s_num_processes,&__pyx_n_s_num_rows,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_read_function)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 619, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_file_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 619, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("read_file_multiprocessing", 0, 2, 4, 1); __PYX_ERR(0, 619, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_num_processes); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 619, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_num_rows); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 619, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kwargs, values + 0, kwd_pos_args, "read_file_multiprocessing") < 0)) __PYX_ERR(0, 619, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_read_function = values[0]; __pyx_v_file_path = values[1]; __pyx_v_num_processes = values[2]; __pyx_v_num_rows = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_file_multiprocessing", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 619, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; __Pyx_AddTraceback("pyreadstat.pyreadstat.read_file_multiprocessing", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_15read_file_multiprocessing(__pyx_self, __pyx_v_read_function, __pyx_v_file_path, __pyx_v_num_processes, __pyx_v_num_rows, __pyx_v_kwargs); /* function exit code */ __Pyx_DECREF(__pyx_v_kwargs); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_15read_file_multiprocessing(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_read_function, PyObject *__pyx_v_file_path, PyObject *__pyx_v_num_processes, PyObject *__pyx_v_num_rows, PyObject *__pyx_v_kwargs) { CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_v_row_offset = NULL; PyObject *__pyx_v_row_limit = NULL; PyObject *__pyx_v_meta = NULL; PyObject *__pyx_v_numrows = NULL; PyObject *__pyx_v_final = NULL; PyObject *__pyx_v_divs = NULL; PyObject *__pyx_v_offsets = NULL; PyObject *__pyx_v_prev_offset = NULL; PyObject *__pyx_v_prev_div = NULL; CYTHON_UNUSED PyObject *__pyx_v_indx = NULL; PyObject *__pyx_v_div = NULL; PyObject *__pyx_v_offset = NULL; PyObject *__pyx_v_jobs = NULL; PyObject *__pyx_v_pool = NULL; PyObject *__pyx_v_chunks = NULL; PyObject *__pyx_v_output_format = NULL; PyObject *__pyx_v_keys = NULL; PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_chunksize = NULL; PyObject *__pyx_v_chunk = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; int __pyx_t_4; int __pyx_t_5; int __pyx_t_6; long __pyx_t_7; int __pyx_t_8; PyObject *__pyx_t_9 = NULL; double __pyx_t_10; PyObject *(*__pyx_t_11)(PyObject *); PyObject *__pyx_t_12 = NULL; Py_ssize_t __pyx_t_13; PyObject *(*__pyx_t_14)(PyObject *); PyObject *__pyx_t_15 = NULL; int __pyx_t_16; PyObject *__pyx_t_17 = NULL; PyObject *__pyx_t_18 = NULL; PyObject *__pyx_t_19 = NULL; int __pyx_t_20; char const *__pyx_t_21; PyObject *__pyx_t_22 = NULL; PyObject *__pyx_t_23 = NULL; PyObject *__pyx_t_24 = NULL; int __pyx_t_25; Py_ssize_t __pyx_t_26; PyObject *(*__pyx_t_27)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_file_multiprocessing", 0); __Pyx_INCREF(__pyx_v_num_processes); /* "pyreadstat/pyreadstat.pyx":649 * """ * * if read_function in (read_sas7bcat,): # <<<<<<<<<<<<<< * raise Exception("read_sas7bcat is not supported") * */ __Pyx_INCREF(__pyx_v_read_function); __pyx_t_1 = __pyx_v_read_function; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_read_sas7bcat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 649, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_4; if (unlikely(__pyx_t_5)) { /* "pyreadstat/pyreadstat.pyx":650 * * if read_function in (read_sas7bcat,): * raise Exception("read_sas7bcat is not supported") # <<<<<<<<<<<<<< * * if read_function in (read_xport, read_por) and num_rows is None: */ __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 650, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":649 * """ * * if read_function in (read_sas7bcat,): # <<<<<<<<<<<<<< * raise Exception("read_sas7bcat is not supported") * */ } /* "pyreadstat/pyreadstat.pyx":652 * raise Exception("read_sas7bcat is not supported") * * if read_function in (read_xport, read_por) and num_rows is None: # <<<<<<<<<<<<<< * raise Exception("num_rows must be specified for read_xport and read_por to be a number equal or larger than the number of rows in the dataset.") * */ __Pyx_INCREF(__pyx_v_read_function); __pyx_t_1 = __pyx_v_read_function; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_read_xport); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_6) { } else { __pyx_t_4 = __pyx_t_6; goto __pyx_L7_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_read_por); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 652, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __pyx_t_6; __pyx_L7_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __pyx_t_4; if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L5_bool_binop_done; } __pyx_t_6 = (__pyx_v_num_rows == Py_None); __pyx_t_5 = __pyx_t_6; __pyx_L5_bool_binop_done:; if (unlikely(__pyx_t_5)) { /* "pyreadstat/pyreadstat.pyx":653 * * if read_function in (read_xport, read_por) and num_rows is None: * raise Exception("num_rows must be specified for read_xport and read_por to be a number equal or larger than the number of rows in the dataset.") # <<<<<<<<<<<<<< * * if not num_processes: */ __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 653, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":652 * raise Exception("read_sas7bcat is not supported") * * if read_function in (read_xport, read_por) and num_rows is None: # <<<<<<<<<<<<<< * raise Exception("num_rows must be specified for read_xport and read_por to be a number equal or larger than the number of rows in the dataset.") * */ } /* "pyreadstat/pyreadstat.pyx":655 * raise Exception("num_rows must be specified for read_xport and read_por to be a number equal or larger than the number of rows in the dataset.") * * if not num_processes: # <<<<<<<<<<<<<< * # let's be conservative with the number of workers * num_processes = min(mp.cpu_count(), 4) */ __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_num_processes); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 655, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* "pyreadstat/pyreadstat.pyx":657 * if not num_processes: * # let's be conservative with the number of workers * num_processes = min(mp.cpu_count(), 4) # <<<<<<<<<<<<<< * _ = kwargs.pop('metadataonly', None) * row_offset = kwargs.pop("row_offset", 0) */ __pyx_t_7 = 4; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_mp); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_cpu_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_6) { __pyx_t_9 = __Pyx_PyInt_From_long(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __pyx_t_9; __pyx_t_9 = 0; } else { __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_num_processes, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":655 * raise Exception("num_rows must be specified for read_xport and read_por to be a number equal or larger than the number of rows in the dataset.") * * if not num_processes: # <<<<<<<<<<<<<< * # let's be conservative with the number of workers * num_processes = min(mp.cpu_count(), 4) */ } /* "pyreadstat/pyreadstat.pyx":658 * # let's be conservative with the number of workers * num_processes = min(mp.cpu_count(), 4) * _ = kwargs.pop('metadataonly', None) # <<<<<<<<<<<<<< * row_offset = kwargs.pop("row_offset", 0) * row_limit = kwargs.pop("row_limit", float('inf')) */ __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_metadataonly, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v__ = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":659 * num_processes = min(mp.cpu_count(), 4) * _ = kwargs.pop('metadataonly', None) * row_offset = kwargs.pop("row_offset", 0) # <<<<<<<<<<<<<< * row_limit = kwargs.pop("row_limit", float('inf')) * _, meta = read_function(file_path, metadataonly=True, **kwargs) */ __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_row_offset, __pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_row_offset = __pyx_t_1; __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":660 * _ = kwargs.pop('metadataonly', None) * row_offset = kwargs.pop("row_offset", 0) * row_limit = kwargs.pop("row_limit", float('inf')) # <<<<<<<<<<<<<< * _, meta = read_function(file_path, metadataonly=True, **kwargs) * numrows = meta.number_rows */ __pyx_t_10 = __Pyx_PyString_AsDouble(__pyx_n_s_inf); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 660, __pyx_L1_error) __pyx_t_1 = PyFloat_FromDouble(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_s_row_limit, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_row_limit = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":661 * row_offset = kwargs.pop("row_offset", 0) * row_limit = kwargs.pop("row_limit", float('inf')) * _, meta = read_function(file_path, metadataonly=True, **kwargs) # <<<<<<<<<<<<<< * numrows = meta.number_rows * */ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_file_path); __Pyx_GIVEREF(__pyx_v_file_path); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_file_path)) __PYX_ERR(0, 661, __pyx_L1_error); __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 661, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_metadataonly, Py_True) < 0) __PYX_ERR(0, 661, __pyx_L1_error) __pyx_t_1 = __pyx_t_9; __pyx_t_9 = 0; if (__Pyx_MergeKeywords(__pyx_t_1, __pyx_v_kwargs) < 0) __PYX_ERR(0, 661, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_v_read_function, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 661, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) { PyObject* sequence = __pyx_t_9; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 661, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 661, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 661, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { Py_ssize_t index = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 661, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); index = 0; __pyx_t_1 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L10_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_2 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L10_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_3), 2) < 0) __PYX_ERR(0, 661, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L11_unpacking_done; __pyx_L10_unpacking_failed:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 661, __pyx_L1_error) __pyx_L11_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v__, __pyx_t_1); __pyx_t_1 = 0; __pyx_v_meta = __pyx_t_2; __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":662 * row_limit = kwargs.pop("row_limit", float('inf')) * _, meta = read_function(file_path, metadataonly=True, **kwargs) * numrows = meta.number_rows # <<<<<<<<<<<<<< * * if numrows is None: */ __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_meta, __pyx_n_s_number_rows); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_numrows = __pyx_t_9; __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":664 * numrows = meta.number_rows * * if numrows is None: # <<<<<<<<<<<<<< * if num_rows is None: * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") */ __pyx_t_6 = (__pyx_v_numrows == Py_None); if (__pyx_t_6) { /* "pyreadstat/pyreadstat.pyx":665 * * if numrows is None: * if num_rows is None: # <<<<<<<<<<<<<< * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") * numrows = num_rows */ __pyx_t_6 = (__pyx_v_num_rows == Py_None); if (unlikely(__pyx_t_6)) { /* "pyreadstat/pyreadstat.pyx":666 * if numrows is None: * if num_rows is None: * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") # <<<<<<<<<<<<<< * numrows = num_rows * elif numrows == 0: */ __pyx_t_9 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 666, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":665 * * if numrows is None: * if num_rows is None: # <<<<<<<<<<<<<< * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") * numrows = num_rows */ } /* "pyreadstat/pyreadstat.pyx":667 * if num_rows is None: * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") * numrows = num_rows # <<<<<<<<<<<<<< * elif numrows == 0: * final, meta = read_function(file_path, **kwargs) */ __Pyx_INCREF(__pyx_v_num_rows); __Pyx_DECREF_SET(__pyx_v_numrows, __pyx_v_num_rows); /* "pyreadstat/pyreadstat.pyx":664 * numrows = meta.number_rows * * if numrows is None: # <<<<<<<<<<<<<< * if num_rows is None: * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") */ goto __pyx_L12; } /* "pyreadstat/pyreadstat.pyx":668 * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") * numrows = num_rows * elif numrows == 0: # <<<<<<<<<<<<<< * final, meta = read_function(file_path, **kwargs) * */ __pyx_t_6 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_numrows, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 668, __pyx_L1_error) if (__pyx_t_6) { /* "pyreadstat/pyreadstat.pyx":669 * numrows = num_rows * elif numrows == 0: * final, meta = read_function(file_path, **kwargs) # <<<<<<<<<<<<<< * * numrows = min(max(numrows - row_offset, 0), row_limit) */ __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_file_path); __Pyx_GIVEREF(__pyx_v_file_path); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_file_path)) __PYX_ERR(0, 669, __pyx_L1_error); __pyx_t_2 = PyDict_Copy(__pyx_v_kwargs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_read_function, __pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 669, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_9 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); index = 0; __pyx_t_2 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_9)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_3), 2) < 0) __PYX_ERR(0, 669, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L15_unpacking_done; __pyx_L14_unpacking_failed:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 669, __pyx_L1_error) __pyx_L15_unpacking_done:; } __pyx_v_final = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_meta, __pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":668 * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") * numrows = num_rows * elif numrows == 0: # <<<<<<<<<<<<<< * final, meta = read_function(file_path, **kwargs) * */ } __pyx_L12:; /* "pyreadstat/pyreadstat.pyx":671 * final, meta = read_function(file_path, **kwargs) * * numrows = min(max(numrows - row_offset, 0), row_limit) # <<<<<<<<<<<<<< * divs = [numrows // num_processes + (1 if x < numrows % num_processes else 0) for x in range (num_processes)] * offsets = list() */ __Pyx_INCREF(__pyx_v_row_limit); __pyx_t_1 = __pyx_v_row_limit; __pyx_t_7 = 0; __pyx_t_9 = PyNumber_Subtract(__pyx_v_numrows, __pyx_v_row_offset); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = PyObject_RichCompare(__pyx_t_3, __pyx_t_9, Py_GT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_6) { __pyx_t_12 = __Pyx_PyInt_From_long(__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_2 = __pyx_t_12; __pyx_t_12 = 0; } else { __Pyx_INCREF(__pyx_t_9); __pyx_t_2 = __pyx_t_9; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_t_2); __pyx_t_9 = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = PyObject_RichCompare(__pyx_t_1, __pyx_t_9, Py_LT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 671, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_6) { __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __pyx_t_1; } else { __Pyx_INCREF(__pyx_t_9); __pyx_t_2 = __pyx_t_9; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_numrows, __pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":672 * * numrows = min(max(numrows - row_offset, 0), row_limit) * divs = [numrows // num_processes + (1 if x < numrows % num_processes else 0) for x in range (num_processes)] # <<<<<<<<<<<<<< * offsets = list() * prev_offset = row_offset */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_num_processes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_9 = __pyx_t_2; __Pyx_INCREF(__pyx_t_9); __pyx_t_13 = 0; __pyx_t_14 = NULL; } else { __pyx_t_13 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 672, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_14)) { if (likely(PyList_CheckExact(__pyx_t_9))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 672, __pyx_L1_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_13); __Pyx_INCREF(__pyx_t_2); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 672, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 672, __pyx_L1_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_13); __Pyx_INCREF(__pyx_t_2); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 672, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_14(__pyx_t_9); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 672, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_FloorDivide(__pyx_v_numrows, __pyx_v_num_processes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyNumber_Remainder(__pyx_v_numrows, __pyx_v_num_processes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = PyObject_RichCompare(__pyx_v_x, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (__pyx_t_6) { __Pyx_INCREF(__pyx_int_1); __pyx_t_12 = __pyx_int_1; } else { __Pyx_INCREF(__pyx_int_0); __pyx_t_12 = __pyx_int_0; } __pyx_t_15 = PyNumber_Add(__pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_15))) __PYX_ERR(0, 672, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_divs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":673 * numrows = min(max(numrows - row_offset, 0), row_limit) * divs = [numrows // num_processes + (1 if x < numrows % num_processes else 0) for x in range (num_processes)] * offsets = list() # <<<<<<<<<<<<<< * prev_offset = row_offset * prev_div = 0 */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 673, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_offsets = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":674 * divs = [numrows // num_processes + (1 if x < numrows % num_processes else 0) for x in range (num_processes)] * offsets = list() * prev_offset = row_offset # <<<<<<<<<<<<<< * prev_div = 0 * for indx, div in enumerate(divs): */ __Pyx_INCREF(__pyx_v_row_offset); __pyx_v_prev_offset = __pyx_v_row_offset; /* "pyreadstat/pyreadstat.pyx":675 * offsets = list() * prev_offset = row_offset * prev_div = 0 # <<<<<<<<<<<<<< * for indx, div in enumerate(divs): * offset = prev_offset + prev_div */ __Pyx_INCREF(__pyx_int_0); __pyx_v_prev_div = __pyx_int_0; /* "pyreadstat/pyreadstat.pyx":676 * prev_offset = row_offset * prev_div = 0 * for indx, div in enumerate(divs): # <<<<<<<<<<<<<< * offset = prev_offset + prev_div * prev_offset = offset */ __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; __pyx_t_9 = __pyx_v_divs; __Pyx_INCREF(__pyx_t_9); __pyx_t_13 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 676, __pyx_L1_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_15 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 676, __pyx_L1_error) #else __pyx_t_15 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); #endif __Pyx_XDECREF_SET(__pyx_v_div, __pyx_t_15); __pyx_t_15 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_indx, __pyx_t_1); __pyx_t_15 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_15; __pyx_t_15 = 0; /* "pyreadstat/pyreadstat.pyx":677 * prev_div = 0 * for indx, div in enumerate(divs): * offset = prev_offset + prev_div # <<<<<<<<<<<<<< * prev_offset = offset * prev_div = div */ __pyx_t_15 = PyNumber_Add(__pyx_v_prev_offset, __pyx_v_prev_div); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_XDECREF_SET(__pyx_v_offset, __pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/pyreadstat.pyx":678 * for indx, div in enumerate(divs): * offset = prev_offset + prev_div * prev_offset = offset # <<<<<<<<<<<<<< * prev_div = div * offsets.append((offset, div)) */ __Pyx_INCREF(__pyx_v_offset); __Pyx_DECREF_SET(__pyx_v_prev_offset, __pyx_v_offset); /* "pyreadstat/pyreadstat.pyx":679 * offset = prev_offset + prev_div * prev_offset = offset * prev_div = div # <<<<<<<<<<<<<< * offsets.append((offset, div)) * jobs = [(read_function, file_path, offset, chunksize, kwargs) for offset, chunksize in offsets] */ __Pyx_INCREF(__pyx_v_div); __Pyx_DECREF_SET(__pyx_v_prev_div, __pyx_v_div); /* "pyreadstat/pyreadstat.pyx":680 * prev_offset = offset * prev_div = div * offsets.append((offset, div)) # <<<<<<<<<<<<<< * jobs = [(read_function, file_path, offset, chunksize, kwargs) for offset, chunksize in offsets] * pool = mp.Pool(processes=num_processes) */ __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_INCREF(__pyx_v_offset); __Pyx_GIVEREF(__pyx_v_offset); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_offset)) __PYX_ERR(0, 680, __pyx_L1_error); __Pyx_INCREF(__pyx_v_div); __Pyx_GIVEREF(__pyx_v_div); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_div)) __PYX_ERR(0, 680, __pyx_L1_error); __pyx_t_16 = __Pyx_PyList_Append(__pyx_v_offsets, __pyx_t_15); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 680, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/pyreadstat.pyx":676 * prev_offset = row_offset * prev_div = 0 * for indx, div in enumerate(divs): # <<<<<<<<<<<<<< * offset = prev_offset + prev_div * prev_offset = offset */ } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":681 * prev_div = div * offsets.append((offset, div)) * jobs = [(read_function, file_path, offset, chunksize, kwargs) for offset, chunksize in offsets] # <<<<<<<<<<<<<< * pool = mp.Pool(processes=num_processes) * try: */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __pyx_v_offsets; __Pyx_INCREF(__pyx_t_9); __pyx_t_13 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 681, __pyx_L1_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_15 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 681, __pyx_L1_error) #else __pyx_t_15 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); #endif if ((likely(PyTuple_CheckExact(__pyx_t_15))) || (PyList_CheckExact(__pyx_t_15))) { PyObject* sequence = __pyx_t_15; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 681, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_12 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_12 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } else { Py_ssize_t index = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); index = 0; __pyx_t_12 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_12)) goto __pyx_L24_unpacking_failed; __Pyx_GOTREF(__pyx_t_12); index = 1; __pyx_t_2 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L24_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_3), 2) < 0) __PYX_ERR(0, 681, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L25_unpacking_done; __pyx_L24_unpacking_failed:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 681, __pyx_L1_error) __pyx_L25_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_offset, __pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF_SET(__pyx_v_chunksize, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_15 = PyTuple_New(5); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_INCREF(__pyx_v_read_function); __Pyx_GIVEREF(__pyx_v_read_function); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_read_function)) __PYX_ERR(0, 681, __pyx_L1_error); __Pyx_INCREF(__pyx_v_file_path); __Pyx_GIVEREF(__pyx_v_file_path); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_file_path)) __PYX_ERR(0, 681, __pyx_L1_error); __Pyx_INCREF(__pyx_v_offset); __Pyx_GIVEREF(__pyx_v_offset); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_v_offset)) __PYX_ERR(0, 681, __pyx_L1_error); __Pyx_INCREF(__pyx_v_chunksize); __Pyx_GIVEREF(__pyx_v_chunksize); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_v_chunksize)) __PYX_ERR(0, 681, __pyx_L1_error); __Pyx_INCREF(__pyx_v_kwargs); __Pyx_GIVEREF(__pyx_v_kwargs); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_v_kwargs)) __PYX_ERR(0, 681, __pyx_L1_error); if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_15))) __PYX_ERR(0, 681, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_jobs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; /* "pyreadstat/pyreadstat.pyx":682 * offsets.append((offset, div)) * jobs = [(read_function, file_path, offset, chunksize, kwargs) for offset, chunksize in offsets] * pool = mp.Pool(processes=num_processes) # <<<<<<<<<<<<<< * try: * chunks = pool.map(worker, jobs) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_mp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Pool); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_processes, __pyx_v_num_processes) < 0) __PYX_ERR(0, 682, __pyx_L1_error) __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_pool = __pyx_t_15; __pyx_t_15 = 0; /* "pyreadstat/pyreadstat.pyx":683 * jobs = [(read_function, file_path, offset, chunksize, kwargs) for offset, chunksize in offsets] * pool = mp.Pool(processes=num_processes) * try: # <<<<<<<<<<<<<< * chunks = pool.map(worker, jobs) * except: */ /*try:*/ { { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); /*try:*/ { /* "pyreadstat/pyreadstat.pyx":684 * pool = mp.Pool(processes=num_processes) * try: * chunks = pool.map(worker, jobs) # <<<<<<<<<<<<<< * except: * raise */ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pool, __pyx_n_s_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 684, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_worker); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 684, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_t_9, __pyx_v_jobs}; __pyx_t_15 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 2+__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 684, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_chunks = __pyx_t_15; __pyx_t_15 = 0; /* "pyreadstat/pyreadstat.pyx":683 * jobs = [(read_function, file_path, offset, chunksize, kwargs) for offset, chunksize in offsets] * pool = mp.Pool(processes=num_processes) * try: # <<<<<<<<<<<<<< * chunks = pool.map(worker, jobs) * except: */ } __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L35_try_end; __pyx_L30_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":685 * try: * chunks = pool.map(worker, jobs) * except: # <<<<<<<<<<<<<< * raise * finally: */ /*except:*/ { __Pyx_AddTraceback("pyreadstat.pyreadstat.read_file_multiprocessing", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 685, __pyx_L32_except_error) __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_9); /* "pyreadstat/pyreadstat.pyx":686 * chunks = pool.map(worker, jobs) * except: * raise # <<<<<<<<<<<<<< * finally: * pool.close() */ __Pyx_GIVEREF(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_15, __pyx_t_1, __pyx_t_9); __pyx_t_15 = 0; __pyx_t_1 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 686, __pyx_L32_except_error) } /* "pyreadstat/pyreadstat.pyx":683 * jobs = [(read_function, file_path, offset, chunksize, kwargs) for offset, chunksize in offsets] * pool = mp.Pool(processes=num_processes) * try: # <<<<<<<<<<<<<< * chunks = pool.map(worker, jobs) * except: */ __pyx_L32_except_error:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); goto __pyx_L28_error; __pyx_L35_try_end:; } } /* "pyreadstat/pyreadstat.pyx":688 * raise * finally: * pool.close() # <<<<<<<<<<<<<< * output_format = kwargs.get("output_format") * if output_format == 'dict': */ /*finally:*/ { /*normal exit:*/{ __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pool, __pyx_n_s_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L29; } __pyx_L28_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_24); __pyx_t_8 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_21 = __pyx_filename; { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pool, __pyx_n_s_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 688, __pyx_L39_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = NULL; __pyx_t_25 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_25 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_25, 0+__pyx_t_25); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 688, __pyx_L39_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24); } __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_19, __pyx_t_18, __pyx_t_17); __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21; goto __pyx_L1_error; __pyx_L39_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_XGIVEREF(__pyx_t_24); __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24); } __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; goto __pyx_L1_error; } __pyx_L29:; } /* "pyreadstat/pyreadstat.pyx":689 * finally: * pool.close() * output_format = kwargs.get("output_format") # <<<<<<<<<<<<<< * if output_format == 'dict': * keys = chunks[0].keys() */ __pyx_t_9 = __Pyx_PyDict_GetItemDefault(__pyx_v_kwargs, __pyx_n_s_output_format, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_output_format = __pyx_t_9; __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":690 * pool.close() * output_format = kwargs.get("output_format") * if output_format == 'dict': # <<<<<<<<<<<<<< * keys = chunks[0].keys() * final = dict() */ __pyx_t_6 = (__Pyx_PyString_Equals(__pyx_v_output_format, __pyx_n_s_dict, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 690, __pyx_L1_error) if (__pyx_t_6) { /* "pyreadstat/pyreadstat.pyx":691 * output_format = kwargs.get("output_format") * if output_format == 'dict': * keys = chunks[0].keys() # <<<<<<<<<<<<<< * final = dict() * for key in keys: */ __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_chunks, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_keys); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_20 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_20 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_20, 0+__pyx_t_20); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_v_keys = __pyx_t_9; __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":692 * if output_format == 'dict': * keys = chunks[0].keys() * final = dict() # <<<<<<<<<<<<<< * for key in keys: * final[key] = np.concatenate([chunk[key] for chunk in chunks]) */ __pyx_t_9 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_final, __pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":693 * keys = chunks[0].keys() * final = dict() * for key in keys: # <<<<<<<<<<<<<< * final[key] = np.concatenate([chunk[key] for chunk in chunks]) * else: */ if (likely(PyList_CheckExact(__pyx_v_keys)) || PyTuple_CheckExact(__pyx_v_keys)) { __pyx_t_9 = __pyx_v_keys; __Pyx_INCREF(__pyx_t_9); __pyx_t_13 = 0; __pyx_t_14 = NULL; } else { __pyx_t_13 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_keys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 693, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_14)) { if (likely(PyList_CheckExact(__pyx_t_9))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 693, __pyx_L1_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_15 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 693, __pyx_L1_error) #else __pyx_t_15 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 693, __pyx_L1_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 693, __pyx_L1_error) #else __pyx_t_15 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); #endif } } else { __pyx_t_15 = __pyx_t_14(__pyx_t_9); if (unlikely(!__pyx_t_15)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 693, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_15); } __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/pyreadstat.pyx":694 * final = dict() * for key in keys: * final[key] = np.concatenate([chunk[key] for chunk in chunks]) # <<<<<<<<<<<<<< * else: * final = pd.concat(chunks, axis=0, ignore_index=True) */ __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_chunks)) || PyTuple_CheckExact(__pyx_v_chunks)) { __pyx_t_12 = __pyx_v_chunks; __Pyx_INCREF(__pyx_t_12); __pyx_t_26 = 0; __pyx_t_27 = NULL; } else { __pyx_t_26 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_v_chunks); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_27 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 694, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_27)) { if (likely(PyList_CheckExact(__pyx_t_12))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 694, __pyx_L1_error) #endif if (__pyx_t_26 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_26); __Pyx_INCREF(__pyx_t_3); __pyx_t_26++; if (unlikely((0 < 0))) __PYX_ERR(0, 694, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_26); __pyx_t_26++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_12); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 694, __pyx_L1_error) #endif if (__pyx_t_26 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_26); __Pyx_INCREF(__pyx_t_3); __pyx_t_26++; if (unlikely((0 < 0))) __PYX_ERR(0, 694, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_26); __pyx_t_26++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_27(__pyx_t_12); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 694, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_chunk, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_chunk, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; __pyx_t_20 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_20 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_t_1}; __pyx_t_15 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_20, 1+__pyx_t_20); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_final, __pyx_v_key, __pyx_t_15) < 0))) __PYX_ERR(0, 694, __pyx_L1_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; /* "pyreadstat/pyreadstat.pyx":693 * keys = chunks[0].keys() * final = dict() * for key in keys: # <<<<<<<<<<<<<< * final[key] = np.concatenate([chunk[key] for chunk in chunks]) * else: */ } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":690 * pool.close() * output_format = kwargs.get("output_format") * if output_format == 'dict': # <<<<<<<<<<<<<< * keys = chunks[0].keys() * final = dict() */ goto __pyx_L40; } /* "pyreadstat/pyreadstat.pyx":696 * final[key] = np.concatenate([chunk[key] for chunk in chunks]) * else: * final = pd.concat(chunks, axis=0, ignore_index=True) # <<<<<<<<<<<<<< * return final, meta * */ /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_pd); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_concat); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_chunks); __Pyx_GIVEREF(__pyx_v_chunks); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_chunks)) __PYX_ERR(0, 696, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 696, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_ignore_index, Py_True) < 0) __PYX_ERR(0, 696, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_9, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_final, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L40:; /* "pyreadstat/pyreadstat.pyx":697 * else: * final = pd.concat(chunks, axis=0, ignore_index=True) * return final, meta # <<<<<<<<<<<<<< * * # Write API */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_final); __Pyx_GIVEREF(__pyx_v_final); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_final)) __PYX_ERR(0, 697, __pyx_L1_error); __Pyx_INCREF(__pyx_v_meta); __Pyx_GIVEREF(__pyx_v_meta); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_meta)) __PYX_ERR(0, 697, __pyx_L1_error); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* "pyreadstat/pyreadstat.pyx":619 * offset += chunksize * * def read_file_multiprocessing(read_function, file_path, num_processes=None, num_rows=None, **kwargs): # <<<<<<<<<<<<<< * """ * Reads a file in parallel using multiprocessing. */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("pyreadstat.pyreadstat.read_file_multiprocessing", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_row_offset); __Pyx_XDECREF(__pyx_v_row_limit); __Pyx_XDECREF(__pyx_v_meta); __Pyx_XDECREF(__pyx_v_numrows); __Pyx_XDECREF(__pyx_v_final); __Pyx_XDECREF(__pyx_v_divs); __Pyx_XDECREF(__pyx_v_offsets); __Pyx_XDECREF(__pyx_v_prev_offset); __Pyx_XDECREF(__pyx_v_prev_div); __Pyx_XDECREF(__pyx_v_indx); __Pyx_XDECREF(__pyx_v_div); __Pyx_XDECREF(__pyx_v_offset); __Pyx_XDECREF(__pyx_v_jobs); __Pyx_XDECREF(__pyx_v_pool); __Pyx_XDECREF(__pyx_v_chunks); __Pyx_XDECREF(__pyx_v_output_format); __Pyx_XDECREF(__pyx_v_keys); __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_chunksize); __Pyx_XDECREF(__pyx_v_chunk); __Pyx_XDECREF(__pyx_v_num_processes); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":701 * # Write API * * def write_sav(df, dst_path, str file_label="", object column_labels=None, compress=False, row_compress=False, str note=None, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_ranges=None, dict variable_display_width=None, * dict variable_measure=None, dict variable_format=None): */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_18write_sav(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_17write_sav, "\n Writes a pandas data frame to a SPSS sav or zsav file.\n\n Parameters\n ----------\n df : pandas data frame\n pandas data frame to write to sav or zsav\n dst_path : str or pathlib.Path\n full path to the result sav or zsav file\n file_label : str, optional\n a label for the file\n column_labels : list or dict, optional\n labels for columns (variables), if list must be the same length as the number of columns. Variables with no\n labels must be represented by None. If dict values must be variable names and values variable labels.\n In such case there is no need to include all variables; labels for non existent\n variables will be ignored with no warning or error.\n compress : boolean, optional\n if true a zsav will be written, by default False, a sav is written\n row_compress : boolean, optional\n if true it applies row compression, by default False, compress and row_compress cannot be both true at the same time\n note : str, optional\n a note to add to the file\n variable_value_labels : dict, optional\n value labels, a dictionary with key variable name and value a dictionary with key values and\n values labels. Variable names must match variable names in the dataframe otherwise will be\n ignored. Value types must match the type of the column in the dataframe.\n missing_ranges : dict, optional\n user defined missing values. Must be a dictionary with keys as variable names matching variable\n names in the dataframe. The values must be a list. Each element in that list can either be\n either a discrete numeric or string value (max 3 per variable) or a dictionary with keys 'hi' and 'lo' to\n indicate the upper and lower range for numeric values (max 1 range value + 1 discrete value per\n variable). hi and lo may also be the same value in which case it will be interpreted as a discrete\n missing value.""\n For this to be effective, values in the dataframe must be the same as reported here and not NaN.\n variable_display_width : dict, optional\n set the display width for variables. Must be a dictonary with keys being variable names and\n values being integers.\n variable_measure: dict, optional\n sets the measure type for a variable. Must be a dictionary with keys being variable names and\n values being strings one of \"nominal\", \"ordinal\", \"scale\" or \"unknown\" (default).\n variable_format: dict, optional\n sets the format of a variable. Must be a dictionary with keys being the variable names and \n values being strings defining the format. See README, setting variable formats section,\n for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_18write_sav = {"write_sav", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_18write_sav, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_17write_sav}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_18write_sav(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_dst_path = 0; PyObject *__pyx_v_file_label = 0; PyObject *__pyx_v_column_labels = 0; PyObject *__pyx_v_compress = 0; PyObject *__pyx_v_row_compress = 0; PyObject *__pyx_v_note = 0; PyObject *__pyx_v_variable_value_labels = 0; PyObject *__pyx_v_missing_ranges = 0; PyObject *__pyx_v_variable_display_width = 0; PyObject *__pyx_v_variable_measure = 0; PyObject *__pyx_v_variable_format = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[12] = {0,0,0,0,0,0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_sav (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_dst_path,&__pyx_n_s_file_label,&__pyx_n_s_column_labels,&__pyx_n_s_compress,&__pyx_n_s_row_compress,&__pyx_n_s_note,&__pyx_n_s_variable_value_labels,&__pyx_n_s_missing_ranges,&__pyx_n_s_variable_display_width,&__pyx_n_s_variable_measure,&__pyx_n_s_variable_format,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_kp_s__6))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":702 * * def write_sav(df, dst_path, str file_label="", object column_labels=None, compress=False, row_compress=False, str note=None, * dict variable_value_labels=None, dict missing_ranges=None, dict variable_display_width=None, # <<<<<<<<<<<<<< * dict variable_measure=None, dict variable_format=None): * """ */ values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":703 * def write_sav(df, dst_path, str file_label="", object column_labels=None, compress=False, row_compress=False, str note=None, * dict variable_value_labels=None, dict missing_ranges=None, dict variable_display_width=None, * dict variable_measure=None, dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a SPSS sav or zsav file. */ values[10] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[11] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dst_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("write_sav", 0, 2, 12, 1); __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_file_label); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_column_labels); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_compress); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row_compress); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_note); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_variable_value_labels); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_missing_ranges); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_variable_display_width); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_variable_measure); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 11: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_variable_format); if (value) { values[11] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 701, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "write_sav") < 0)) __PYX_ERR(0, 701, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_df = values[0]; __pyx_v_dst_path = values[1]; __pyx_v_file_label = ((PyObject*)values[2]); __pyx_v_column_labels = values[3]; __pyx_v_compress = values[4]; __pyx_v_row_compress = values[5]; __pyx_v_note = ((PyObject*)values[6]); __pyx_v_variable_value_labels = ((PyObject*)values[7]); __pyx_v_missing_ranges = ((PyObject*)values[8]); __pyx_v_variable_display_width = ((PyObject*)values[9]); __pyx_v_variable_measure = ((PyObject*)values[10]); __pyx_v_variable_format = ((PyObject*)values[11]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_sav", 0, 2, 12, __pyx_nargs); __PYX_ERR(0, 701, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.write_sav", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_file_label), (&PyString_Type), 1, "file_label", 1))) __PYX_ERR(0, 701, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_note), (&PyString_Type), 1, "note", 1))) __PYX_ERR(0, 701, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable_value_labels), (&PyDict_Type), 1, "variable_value_labels", 1))) __PYX_ERR(0, 702, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_missing_ranges), (&PyDict_Type), 1, "missing_ranges", 1))) __PYX_ERR(0, 702, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable_display_width), (&PyDict_Type), 1, "variable_display_width", 1))) __PYX_ERR(0, 702, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable_measure), (&PyDict_Type), 1, "variable_measure", 1))) __PYX_ERR(0, 703, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable_format), (&PyDict_Type), 1, "variable_format", 1))) __PYX_ERR(0, 703, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_17write_sav(__pyx_self, __pyx_v_df, __pyx_v_dst_path, __pyx_v_file_label, __pyx_v_column_labels, __pyx_v_compress, __pyx_v_row_compress, __pyx_v_note, __pyx_v_variable_value_labels, __pyx_v_missing_ranges, __pyx_v_variable_display_width, __pyx_v_variable_measure, __pyx_v_variable_format); /* "pyreadstat/pyreadstat.pyx":701 * # Write API * * def write_sav(df, dst_path, str file_label="", object column_labels=None, compress=False, row_compress=False, str note=None, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_ranges=None, dict variable_display_width=None, * dict variable_measure=None, dict variable_format=None): */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_17write_sav(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_dst_path, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, PyObject *__pyx_v_compress, PyObject *__pyx_v_row_compress, PyObject *__pyx_v_note, PyObject *__pyx_v_variable_value_labels, PyObject *__pyx_v_missing_ranges, PyObject *__pyx_v_variable_display_width, PyObject *__pyx_v_variable_measure, PyObject *__pyx_v_variable_format) { int __pyx_v_file_format_version; PyObject *__pyx_v_var_width = 0; int __pyx_v_row_compression; PyObject *__pyx_v_table_name = 0; PyObject *__pyx_v_missing_user_values = 0; PyObject *__pyx_v_variable_alignment = 0; PyObject *__pyx_v_formats_presets = NULL; PyObject *__pyx_v_col_name = NULL; PyObject *__pyx_v_col_format = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; int __pyx_t_6; Py_ssize_t __pyx_t_7; PyObject *(*__pyx_t_8)(PyObject *); PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; PyObject *(*__pyx_t_11)(PyObject *); Py_ssize_t __pyx_t_12; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_sav", 1); /* "pyreadstat/pyreadstat.pyx":750 * """ * * cdef int file_format_version = 2 # <<<<<<<<<<<<<< * cdef str var_width * cdef bint row_compression = 0 */ __pyx_v_file_format_version = 2; /* "pyreadstat/pyreadstat.pyx":752 * cdef int file_format_version = 2 * cdef str var_width * cdef bint row_compression = 0 # <<<<<<<<<<<<<< * if compress and row_compress: * raise PyreadstatError("compress and row_compress cannot be both True") */ __pyx_v_row_compression = 0; /* "pyreadstat/pyreadstat.pyx":753 * cdef str var_width * cdef bint row_compression = 0 * if compress and row_compress: # <<<<<<<<<<<<<< * raise PyreadstatError("compress and row_compress cannot be both True") * if compress: */ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_compress); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 753, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_row_compress); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 753, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (unlikely(__pyx_t_1)) { /* "pyreadstat/pyreadstat.pyx":754 * cdef bint row_compression = 0 * if compress and row_compress: * raise PyreadstatError("compress and row_compress cannot be both True") # <<<<<<<<<<<<<< * if compress: * file_format_version = 3 */ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_kp_s_compress_and_row_compress_cannot}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 754, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":753 * cdef str var_width * cdef bint row_compression = 0 * if compress and row_compress: # <<<<<<<<<<<<<< * raise PyreadstatError("compress and row_compress cannot be both True") * if compress: */ } /* "pyreadstat/pyreadstat.pyx":755 * if compress and row_compress: * raise PyreadstatError("compress and row_compress cannot be both True") * if compress: # <<<<<<<<<<<<<< * file_format_version = 3 * if row_compress: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_compress); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 755, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":756 * raise PyreadstatError("compress and row_compress cannot be both True") * if compress: * file_format_version = 3 # <<<<<<<<<<<<<< * if row_compress: * row_compression = 1 */ __pyx_v_file_format_version = 3; /* "pyreadstat/pyreadstat.pyx":755 * if compress and row_compress: * raise PyreadstatError("compress and row_compress cannot be both True") * if compress: # <<<<<<<<<<<<<< * file_format_version = 3 * if row_compress: */ } /* "pyreadstat/pyreadstat.pyx":757 * if compress: * file_format_version = 3 * if row_compress: # <<<<<<<<<<<<<< * row_compression = 1 * cdef table_name = "" */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_row_compress); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 757, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":758 * file_format_version = 3 * if row_compress: * row_compression = 1 # <<<<<<<<<<<<<< * cdef table_name = "" * cdef dict missing_user_values = None */ __pyx_v_row_compression = 1; /* "pyreadstat/pyreadstat.pyx":757 * if compress: * file_format_version = 3 * if row_compress: # <<<<<<<<<<<<<< * row_compression = 1 * cdef table_name = "" */ } /* "pyreadstat/pyreadstat.pyx":759 * if row_compress: * row_compression = 1 * cdef table_name = "" # <<<<<<<<<<<<<< * cdef dict missing_user_values = None * cdef dict variable_alignment = None */ __Pyx_INCREF(__pyx_kp_s__6); __pyx_v_table_name = __pyx_kp_s__6; /* "pyreadstat/pyreadstat.pyx":760 * row_compression = 1 * cdef table_name = "" * cdef dict missing_user_values = None # <<<<<<<<<<<<<< * cdef dict variable_alignment = None * */ __Pyx_INCREF(Py_None); __pyx_v_missing_user_values = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":761 * cdef table_name = "" * cdef dict missing_user_values = None * cdef dict variable_alignment = None # <<<<<<<<<<<<<< * * */ __Pyx_INCREF(Py_None); __pyx_v_variable_alignment = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":765 * * # formats * formats_presets = {'restricted_integer':'N{var_width}', 'integer':'F{var_width}.0'} # <<<<<<<<<<<<<< * if variable_format: * for col_name, col_format in variable_format.items(): */ __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_restricted_integer, __pyx_kp_s_N_var_width) < 0) __PYX_ERR(0, 765, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_integer, __pyx_kp_s_F_var_width_0) < 0) __PYX_ERR(0, 765, __pyx_L1_error) __pyx_v_formats_presets = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/pyreadstat.pyx":766 * # formats * formats_presets = {'restricted_integer':'N{var_width}', 'integer':'F{var_width}.0'} * if variable_format: # <<<<<<<<<<<<<< * for col_name, col_format in variable_format.items(): * if col_format in formats_presets.keys() and col_name in df.columns: */ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_variable_format); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 766, __pyx_L1_error) if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":767 * formats_presets = {'restricted_integer':'N{var_width}', 'integer':'F{var_width}.0'} * if variable_format: * for col_name, col_format in variable_format.items(): # <<<<<<<<<<<<<< * if col_format in formats_presets.keys() and col_name in df.columns: * var_width = str(len(str(max(df[col_name])))) */ if (unlikely(__pyx_v_variable_format == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 767, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyDict_Items(__pyx_v_variable_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 767, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 767, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 767, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 767, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 767, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_8(__pyx_t_4); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 767, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 767, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_9 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 767, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L12_unpacking_done; __pyx_L11_unpacking_failed:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 767, __pyx_L1_error) __pyx_L12_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_col_name, __pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_col_format, __pyx_t_9); __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":768 * if variable_format: * for col_name, col_format in variable_format.items(): * if col_format in formats_presets.keys() and col_name in df.columns: # <<<<<<<<<<<<<< * var_width = str(len(str(max(df[col_name])))) * variable_format[col_name] = formats_presets[col_format].format(var_width=var_width) */ __pyx_t_3 = __Pyx_PyDict_Keys(__pyx_v_formats_presets); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_col_format, __pyx_t_3, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L14_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_col_name, __pyx_t_3, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_2; __pyx_L14_bool_binop_done:; if (__pyx_t_1) { /* "pyreadstat/pyreadstat.pyx":769 * for col_name, col_format in variable_format.items(): * if col_format in formats_presets.keys() and col_name in df.columns: * var_width = str(len(str(max(df[col_name])))) # <<<<<<<<<<<<<< * variable_format[col_name] = formats_presets[col_format].format(var_width=var_width) * */ __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_df, __pyx_v_col_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Str(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_12 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_Str(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(PyString_CheckExact(__pyx_t_9)) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_9))) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_var_width, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0; /* "pyreadstat/pyreadstat.pyx":770 * if col_format in formats_presets.keys() and col_name in df.columns: * var_width = str(len(str(max(df[col_name])))) * variable_format[col_name] = formats_presets[col_format].format(var_width=var_width) # <<<<<<<<<<<<<< * * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_SAV, file_label, column_labels, */ __pyx_t_9 = __Pyx_PyDict_GetItem(__pyx_v_formats_presets, __pyx_v_col_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_var_width, __pyx_v_var_width) < 0) __PYX_ERR(0, 770, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(__pyx_v_variable_format == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 770, __pyx_L1_error) } if (unlikely((PyDict_SetItem(__pyx_v_variable_format, __pyx_v_col_name, __pyx_t_5) < 0))) __PYX_ERR(0, 770, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* "pyreadstat/pyreadstat.pyx":768 * if variable_format: * for col_name, col_format in variable_format.items(): * if col_format in formats_presets.keys() and col_name in df.columns: # <<<<<<<<<<<<<< * var_width = str(len(str(max(df[col_name])))) * variable_format[col_name] = formats_presets[col_format].format(var_width=var_width) */ } /* "pyreadstat/pyreadstat.pyx":767 * formats_presets = {'restricted_integer':'N{var_width}', 'integer':'F{var_width}.0'} * if variable_format: * for col_name, col_format in variable_format.items(): # <<<<<<<<<<<<<< * if col_format in formats_presets.keys() and col_name in df.columns: * var_width = str(len(str(max(df[col_name])))) */ } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":766 * # formats * formats_presets = {'restricted_integer':'N{var_width}', 'integer':'F{var_width}.0'} * if variable_format: # <<<<<<<<<<<<<< * for col_name, col_format in variable_format.items(): * if col_format in formats_presets.keys() and col_name in df.columns: */ } /* "pyreadstat/pyreadstat.pyx":773 * * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_SAV, file_label, column_labels, * file_format_version, note, table_name, variable_value_labels, missing_ranges, missing_user_values, # <<<<<<<<<<<<<< * variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) * */ if (!(likely(PyString_CheckExact(__pyx_v_table_name)) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_v_table_name))) __PYX_ERR(0, 773, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":772 * variable_format[col_name] = formats_presets[col_format].format(var_width=var_width) * * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_SAV, file_label, column_labels, # <<<<<<<<<<<<<< * file_format_version, note, table_name, variable_value_labels, missing_ranges, missing_user_values, * variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) */ __pyx_f_10pyreadstat_16_readstat_writer_run_write(__pyx_v_df, __pyx_v_dst_path, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_SAV, __pyx_v_file_label, __pyx_v_column_labels, __pyx_v_file_format_version, __pyx_v_note, ((PyObject*)__pyx_v_table_name), __pyx_v_variable_value_labels, __pyx_v_missing_ranges, __pyx_v_missing_user_values, __pyx_v_variable_alignment, __pyx_v_variable_display_width, __pyx_v_variable_measure, __pyx_v_variable_format, __pyx_v_row_compression); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 772, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":701 * # Write API * * def write_sav(df, dst_path, str file_label="", object column_labels=None, compress=False, row_compress=False, str note=None, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_ranges=None, dict variable_display_width=None, * dict variable_measure=None, dict variable_format=None): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("pyreadstat.pyreadstat.write_sav", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_var_width); __Pyx_XDECREF(__pyx_v_table_name); __Pyx_XDECREF(__pyx_v_missing_user_values); __Pyx_XDECREF(__pyx_v_variable_alignment); __Pyx_XDECREF(__pyx_v_formats_presets); __Pyx_XDECREF(__pyx_v_col_name); __Pyx_XDECREF(__pyx_v_col_format); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":776 * variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) * * def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): * """ */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_20write_dta(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_19write_dta, "\n Writes a pandas data frame to a STATA dta file\n\n Parameters\n ----------\n df : pandas data frame\n pandas data frame to write to sav or zsav\n dst_path : str or pathlib.Path\n full path to the result dta file\n file_label : str, optional\n a label for the file\n column_labels : list or dict, optional\n labels for columns (variables), if list must be the same length as the number of columns. Variables with no\n labels must be represented by None. If dict values must be variable names and values variable labels.\n In such case there is no need to include all variables; labels for non existent\n variables will be ignored with no warning or error.\n version : int, optional\n dta file version, supported from 8 to 15, default is 15\n variable_value_labels : dict, optional\n value labels, a dictionary with key variable name and value a dictionary with key values and\n values labels. Variable names must match variable names in the dataframe otherwise will be\n ignored. Value types must match the type of the column in the dataframe.\n missing_user_values : dict, optional\n user defined missing values for numeric variables. Must be a dictionary with keys being variable\n names and values being a list of missing values. Missing values must be a single character\n between a and z.\n variable_format: dict, optional\n sets the format of a variable. Must be a dictionary with keys being the variable names and \n values being strings defining the format. See README, setting variable formats section,\n for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_20write_dta = {"write_dta", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_20write_dta, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_19write_dta}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_20write_dta(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_dst_path = 0; PyObject *__pyx_v_file_label = 0; PyObject *__pyx_v_column_labels = 0; int __pyx_v_version; PyObject *__pyx_v_variable_value_labels = 0; PyObject *__pyx_v_missing_user_values = 0; PyObject *__pyx_v_variable_format = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[8] = {0,0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_dta (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_dst_path,&__pyx_n_s_file_label,&__pyx_n_s_column_labels,&__pyx_n_s_version,&__pyx_n_s_variable_value_labels,&__pyx_n_s_missing_user_values,&__pyx_n_s_variable_format,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_kp_s__6))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); /* "pyreadstat/pyreadstat.pyx":777 * * def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, * dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a STATA dta file */ values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dst_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("write_dta", 0, 2, 8, 1); __PYX_ERR(0, 776, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_file_label); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_column_labels); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_version); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_variable_value_labels); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_missing_user_values); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_variable_format); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "write_dta") < 0)) __PYX_ERR(0, 776, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_df = values[0]; __pyx_v_dst_path = values[1]; __pyx_v_file_label = ((PyObject*)values[2]); __pyx_v_column_labels = values[3]; if (values[4]) { __pyx_v_version = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_version == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 776, __pyx_L3_error) } else { __pyx_v_version = ((int)((int)15)); } __pyx_v_variable_value_labels = ((PyObject*)values[5]); __pyx_v_missing_user_values = ((PyObject*)values[6]); __pyx_v_variable_format = ((PyObject*)values[7]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_dta", 0, 2, 8, __pyx_nargs); __PYX_ERR(0, 776, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.write_dta", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_file_label), (&PyString_Type), 1, "file_label", 1))) __PYX_ERR(0, 776, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable_value_labels), (&PyDict_Type), 1, "variable_value_labels", 1))) __PYX_ERR(0, 777, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_missing_user_values), (&PyDict_Type), 1, "missing_user_values", 1))) __PYX_ERR(0, 777, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable_format), (&PyDict_Type), 1, "variable_format", 1))) __PYX_ERR(0, 777, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_19write_dta(__pyx_self, __pyx_v_df, __pyx_v_dst_path, __pyx_v_file_label, __pyx_v_column_labels, __pyx_v_version, __pyx_v_variable_value_labels, __pyx_v_missing_user_values, __pyx_v_variable_format); /* "pyreadstat/pyreadstat.pyx":776 * variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) * * def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): * """ */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_19write_dta(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_dst_path, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, int __pyx_v_version, PyObject *__pyx_v_variable_value_labels, PyObject *__pyx_v_missing_user_values, PyObject *__pyx_v_variable_format) { long __pyx_v_file_format_version; PyObject *__pyx_v_note = 0; PyObject *__pyx_v_table_name = 0; PyObject *__pyx_v_missing_ranges = 0; PyObject *__pyx_v_variable_alignment = 0; PyObject *__pyx_v_variable_display_width = 0; PyObject *__pyx_v_variable_measure = 0; int __pyx_v_row_compression; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_dta", 1); /* "pyreadstat/pyreadstat.pyx":810 * """ * * if version == 15: # <<<<<<<<<<<<<< * file_format_version = 119 * elif version == 14: */ switch (__pyx_v_version) { case 15: /* "pyreadstat/pyreadstat.pyx":811 * * if version == 15: * file_format_version = 119 # <<<<<<<<<<<<<< * elif version == 14: * file_format_version = 118 */ __pyx_v_file_format_version = 0x77; /* "pyreadstat/pyreadstat.pyx":810 * """ * * if version == 15: # <<<<<<<<<<<<<< * file_format_version = 119 * elif version == 14: */ break; case 14: /* "pyreadstat/pyreadstat.pyx":813 * file_format_version = 119 * elif version == 14: * file_format_version = 118 # <<<<<<<<<<<<<< * elif version == 13: * file_format_version = 117 */ __pyx_v_file_format_version = 0x76; /* "pyreadstat/pyreadstat.pyx":812 * if version == 15: * file_format_version = 119 * elif version == 14: # <<<<<<<<<<<<<< * file_format_version = 118 * elif version == 13: */ break; case 13: /* "pyreadstat/pyreadstat.pyx":815 * file_format_version = 118 * elif version == 13: * file_format_version = 117 # <<<<<<<<<<<<<< * elif version == 12: * file_format_version = 115 */ __pyx_v_file_format_version = 0x75; /* "pyreadstat/pyreadstat.pyx":814 * elif version == 14: * file_format_version = 118 * elif version == 13: # <<<<<<<<<<<<<< * file_format_version = 117 * elif version == 12: */ break; case 12: /* "pyreadstat/pyreadstat.pyx":817 * file_format_version = 117 * elif version == 12: * file_format_version = 115 # <<<<<<<<<<<<<< * elif version in {10, 11}: * file_format_version = 114 */ __pyx_v_file_format_version = 0x73; /* "pyreadstat/pyreadstat.pyx":816 * elif version == 13: * file_format_version = 117 * elif version == 12: # <<<<<<<<<<<<<< * file_format_version = 115 * elif version in {10, 11}: */ break; case 10: /* "pyreadstat/pyreadstat.pyx":818 * elif version == 12: * file_format_version = 115 * elif version in {10, 11}: # <<<<<<<<<<<<<< * file_format_version = 114 * elif version in {8, 9}: */ case 11: /* "pyreadstat/pyreadstat.pyx":819 * file_format_version = 115 * elif version in {10, 11}: * file_format_version = 114 # <<<<<<<<<<<<<< * elif version in {8, 9}: * file_format_version = 113 */ __pyx_v_file_format_version = 0x72; /* "pyreadstat/pyreadstat.pyx":818 * elif version == 12: * file_format_version = 115 * elif version in {10, 11}: # <<<<<<<<<<<<<< * file_format_version = 114 * elif version in {8, 9}: */ break; case 8: /* "pyreadstat/pyreadstat.pyx":820 * elif version in {10, 11}: * file_format_version = 114 * elif version in {8, 9}: # <<<<<<<<<<<<<< * file_format_version = 113 * else: */ case 9: /* "pyreadstat/pyreadstat.pyx":821 * file_format_version = 114 * elif version in {8, 9}: * file_format_version = 113 # <<<<<<<<<<<<<< * else: * raise Exception("Version not supported") */ __pyx_v_file_format_version = 0x71; /* "pyreadstat/pyreadstat.pyx":820 * elif version in {10, 11}: * file_format_version = 114 * elif version in {8, 9}: # <<<<<<<<<<<<<< * file_format_version = 113 * else: */ break; default: /* "pyreadstat/pyreadstat.pyx":823 * file_format_version = 113 * else: * raise Exception("Version not supported") # <<<<<<<<<<<<<< * * cdef str note = "" */ __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])), __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 823, __pyx_L1_error) break; } /* "pyreadstat/pyreadstat.pyx":825 * raise Exception("Version not supported") * * cdef str note = "" # <<<<<<<<<<<<<< * cdef str table_name = "" * cdef dict missing_ranges = None */ __Pyx_INCREF(__pyx_kp_s__6); __pyx_v_note = __pyx_kp_s__6; /* "pyreadstat/pyreadstat.pyx":826 * * cdef str note = "" * cdef str table_name = "" # <<<<<<<<<<<<<< * cdef dict missing_ranges = None * cdef dict variable_alignment = None */ __Pyx_INCREF(__pyx_kp_s__6); __pyx_v_table_name = __pyx_kp_s__6; /* "pyreadstat/pyreadstat.pyx":827 * cdef str note = "" * cdef str table_name = "" * cdef dict missing_ranges = None # <<<<<<<<<<<<<< * cdef dict variable_alignment = None * cdef dict variable_display_width = None */ __Pyx_INCREF(Py_None); __pyx_v_missing_ranges = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":828 * cdef str table_name = "" * cdef dict missing_ranges = None * cdef dict variable_alignment = None # <<<<<<<<<<<<<< * cdef dict variable_display_width = None * cdef dict variable_measure = None */ __Pyx_INCREF(Py_None); __pyx_v_variable_alignment = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":829 * cdef dict missing_ranges = None * cdef dict variable_alignment = None * cdef dict variable_display_width = None # <<<<<<<<<<<<<< * cdef dict variable_measure = None * #cdef dict variable_format = None */ __Pyx_INCREF(Py_None); __pyx_v_variable_display_width = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":830 * cdef dict variable_alignment = None * cdef dict variable_display_width = None * cdef dict variable_measure = None # <<<<<<<<<<<<<< * #cdef dict variable_format = None * cdef bint row_compression = 0 */ __Pyx_INCREF(Py_None); __pyx_v_variable_measure = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":832 * cdef dict variable_measure = None * #cdef dict variable_format = None * cdef bint row_compression = 0 # <<<<<<<<<<<<<< * * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_DTA, file_label, column_labels, file_format_version, */ __pyx_v_row_compression = 0; /* "pyreadstat/pyreadstat.pyx":834 * cdef bint row_compression = 0 * * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_DTA, file_label, column_labels, file_format_version, # <<<<<<<<<<<<<< * note, table_name, variable_value_labels, missing_ranges, missing_user_values, variable_alignment, * variable_display_width, variable_measure, variable_format, row_compression) */ __pyx_f_10pyreadstat_16_readstat_writer_run_write(__pyx_v_df, __pyx_v_dst_path, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_DTA, __pyx_v_file_label, __pyx_v_column_labels, __pyx_v_file_format_version, __pyx_v_note, __pyx_v_table_name, __pyx_v_variable_value_labels, __pyx_v_missing_ranges, __pyx_v_missing_user_values, __pyx_v_variable_alignment, __pyx_v_variable_display_width, __pyx_v_variable_measure, __pyx_v_variable_format, __pyx_v_row_compression); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 834, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":776 * variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) * * def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): * """ */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("pyreadstat.pyreadstat.write_dta", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_note); __Pyx_XDECREF(__pyx_v_table_name); __Pyx_XDECREF(__pyx_v_missing_ranges); __Pyx_XDECREF(__pyx_v_variable_alignment); __Pyx_XDECREF(__pyx_v_variable_display_width); __Pyx_XDECREF(__pyx_v_variable_measure); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":838 * variable_display_width, variable_measure, variable_format, row_compression) * * def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, # <<<<<<<<<<<<<< * dict variable_format=None): * """ */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_22write_xport(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_21write_xport, "\n Writes a pandas data frame to a SAS Xport (xpt) file.\n If no table_name is specified the dataset has by default the name DATASET (take it into account if\n reading the file from SAS.)\n Versions 5 and 8 are supported, default is 8.\n\n Parameters\n ----------\n df : pandas data frame\n pandas data frame to write to xport\n dst_path : str or pathlib.Path\n full path to the result xport file\n file_label : str, optional\n a label for the file\n column_labels : list or dict, optional\n labels for columns (variables), if list must be the same length as the number of columns. Variables with no\n labels must be represented by None. If dict values must be variable names and values variable labels.\n In such case there is no need to include all variables; labels for non existent\n variables will be ignored with no warning or error.\n table_name : str, optional\n name of the dataset, by default DATASET\n file_format_version : int, optional\n XPORT file version, either 8 or 5, default is 8\n variable_format: dict, optional\n sets the format of a variable. Must be a dictionary with keys being the variable names and \n values being strings defining the format. See README, setting variable formats section,\n for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_22write_xport = {"write_xport", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_22write_xport, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_21write_xport}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_22write_xport(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_dst_path = 0; PyObject *__pyx_v_file_label = 0; PyObject *__pyx_v_column_labels = 0; PyObject *__pyx_v_table_name = 0; int __pyx_v_file_format_version; PyObject *__pyx_v_variable_format = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[7] = {0,0,0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_xport (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_dst_path,&__pyx_n_s_file_label,&__pyx_n_s_column_labels,&__pyx_n_s_table_name,&__pyx_n_s_file_format_version,&__pyx_n_s_variable_format,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_kp_s__6))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* "pyreadstat/pyreadstat.pyx":839 * * def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, * dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a SAS Xport (xpt) file. */ values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dst_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("write_xport", 0, 2, 7, 1); __PYX_ERR(0, 838, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_file_label); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_column_labels); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_table_name); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_file_format_version); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_variable_format); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "write_xport") < 0)) __PYX_ERR(0, 838, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_df = values[0]; __pyx_v_dst_path = values[1]; __pyx_v_file_label = ((PyObject*)values[2]); __pyx_v_column_labels = values[3]; __pyx_v_table_name = ((PyObject*)values[4]); if (values[5]) { __pyx_v_file_format_version = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_file_format_version == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 838, __pyx_L3_error) } else { __pyx_v_file_format_version = ((int)((int)8)); } __pyx_v_variable_format = ((PyObject*)values[6]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_xport", 0, 2, 7, __pyx_nargs); __PYX_ERR(0, 838, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.write_xport", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_file_label), (&PyString_Type), 1, "file_label", 1))) __PYX_ERR(0, 838, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_table_name), (&PyString_Type), 1, "table_name", 1))) __PYX_ERR(0, 838, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable_format), (&PyDict_Type), 1, "variable_format", 1))) __PYX_ERR(0, 839, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_21write_xport(__pyx_self, __pyx_v_df, __pyx_v_dst_path, __pyx_v_file_label, __pyx_v_column_labels, __pyx_v_table_name, __pyx_v_file_format_version, __pyx_v_variable_format); /* "pyreadstat/pyreadstat.pyx":838 * variable_display_width, variable_measure, variable_format, row_compression) * * def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, # <<<<<<<<<<<<<< * dict variable_format=None): * """ */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_21write_xport(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_dst_path, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, PyObject *__pyx_v_table_name, int __pyx_v_file_format_version, PyObject *__pyx_v_variable_format) { PyObject *__pyx_v_variable_value_labels = 0; PyObject *__pyx_v_note = 0; PyObject *__pyx_v_missing_ranges = 0; PyObject *__pyx_v_missing_user_values = 0; PyObject *__pyx_v_variable_alignment = 0; PyObject *__pyx_v_variable_display_width = 0; PyObject *__pyx_v_variable_measure = 0; int __pyx_v_row_compression; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_xport", 1); /* "pyreadstat/pyreadstat.pyx":869 * """ * * cdef dict variable_value_labels = None # <<<<<<<<<<<<<< * cdef str note = "" * cdef dict missing_ranges = None */ __Pyx_INCREF(Py_None); __pyx_v_variable_value_labels = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":870 * * cdef dict variable_value_labels = None * cdef str note = "" # <<<<<<<<<<<<<< * cdef dict missing_ranges = None * cdef dict missing_user_values = None */ __Pyx_INCREF(__pyx_kp_s__6); __pyx_v_note = __pyx_kp_s__6; /* "pyreadstat/pyreadstat.pyx":871 * cdef dict variable_value_labels = None * cdef str note = "" * cdef dict missing_ranges = None # <<<<<<<<<<<<<< * cdef dict missing_user_values = None * cdef dict variable_alignment = None */ __Pyx_INCREF(Py_None); __pyx_v_missing_ranges = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":872 * cdef str note = "" * cdef dict missing_ranges = None * cdef dict missing_user_values = None # <<<<<<<<<<<<<< * cdef dict variable_alignment = None * cdef dict variable_display_width = None */ __Pyx_INCREF(Py_None); __pyx_v_missing_user_values = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":873 * cdef dict missing_ranges = None * cdef dict missing_user_values = None * cdef dict variable_alignment = None # <<<<<<<<<<<<<< * cdef dict variable_display_width = None * cdef dict variable_measure = None */ __Pyx_INCREF(Py_None); __pyx_v_variable_alignment = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":874 * cdef dict missing_user_values = None * cdef dict variable_alignment = None * cdef dict variable_display_width = None # <<<<<<<<<<<<<< * cdef dict variable_measure = None * #cdef dict variable_format = None */ __Pyx_INCREF(Py_None); __pyx_v_variable_display_width = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":875 * cdef dict variable_alignment = None * cdef dict variable_display_width = None * cdef dict variable_measure = None # <<<<<<<<<<<<<< * #cdef dict variable_format = None * cdef bint row_compression = 0 */ __Pyx_INCREF(Py_None); __pyx_v_variable_measure = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":877 * cdef dict variable_measure = None * #cdef dict variable_format = None * cdef bint row_compression = 0 # <<<<<<<<<<<<<< * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_XPORT, file_label, column_labels, * file_format_version, note, table_name, variable_value_labels, missing_ranges,missing_user_values, */ __pyx_v_row_compression = 0; /* "pyreadstat/pyreadstat.pyx":878 * #cdef dict variable_format = None * cdef bint row_compression = 0 * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_XPORT, file_label, column_labels, # <<<<<<<<<<<<<< * file_format_version, note, table_name, variable_value_labels, missing_ranges,missing_user_values, * variable_alignment,variable_display_width, variable_measure, variable_format, row_compression) */ __pyx_f_10pyreadstat_16_readstat_writer_run_write(__pyx_v_df, __pyx_v_dst_path, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_XPORT, __pyx_v_file_label, __pyx_v_column_labels, __pyx_v_file_format_version, __pyx_v_note, __pyx_v_table_name, __pyx_v_variable_value_labels, __pyx_v_missing_ranges, __pyx_v_missing_user_values, __pyx_v_variable_alignment, __pyx_v_variable_display_width, __pyx_v_variable_measure, __pyx_v_variable_format, __pyx_v_row_compression); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 878, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":838 * variable_display_width, variable_measure, variable_format, row_compression) * * def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, # <<<<<<<<<<<<<< * dict variable_format=None): * """ */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("pyreadstat.pyreadstat.write_xport", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_variable_value_labels); __Pyx_XDECREF(__pyx_v_note); __Pyx_XDECREF(__pyx_v_missing_ranges); __Pyx_XDECREF(__pyx_v_missing_user_values); __Pyx_XDECREF(__pyx_v_variable_alignment); __Pyx_XDECREF(__pyx_v_variable_display_width); __Pyx_XDECREF(__pyx_v_variable_measure); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* "pyreadstat/pyreadstat.pyx":882 * variable_alignment,variable_display_width, variable_measure, variable_format, row_compression) * * def write_por(df, dst_path, str file_label="", object column_labels=None, dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a SPSS POR file. */ /* Python wrapper */ static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_24write_por(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_10pyreadstat_10pyreadstat_23write_por, "\n Writes a pandas data frame to a SPSS POR file.\n\n Parameters\n ----------\n df : pandas data frame\n pandas data frame to write to por\n dst_path : str or pathlib.Path\n full path to the result por file\n file_label : str, optional\n a label for the file\n column_labels : list or dict, optional\n labels for columns (variables), if list must be the same length as the number of columns. Variables with no\n labels must be represented by None. If dict values must be variable names and values variable labels.\n In such case there is no need to include all variables; labels for non existent\n variables will be ignored with no warning or error.\n variable_format: dict, optional\n sets the format of a variable. Must be a dictionary with keys being the variable names and \n values being strings defining the format. See README, setting variable formats section,\n for more information.\n "); static PyMethodDef __pyx_mdef_10pyreadstat_10pyreadstat_24write_por = {"write_por", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10pyreadstat_10pyreadstat_24write_por, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10pyreadstat_10pyreadstat_23write_por}; static PyObject *__pyx_pw_10pyreadstat_10pyreadstat_24write_por(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_dst_path = 0; PyObject *__pyx_v_file_label = 0; PyObject *__pyx_v_column_labels = 0; PyObject *__pyx_v_variable_format = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject* values[5] = {0,0,0,0,0}; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_por (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_dst_path,&__pyx_n_s_file_label,&__pyx_n_s_column_labels,&__pyx_n_s_variable_format,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_kp_s__6))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 882, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dst_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 882, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("write_por", 0, 2, 5, 1); __PYX_ERR(0, 882, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_file_label); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 882, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_column_labels); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 882, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_variable_format); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 882, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "write_por") < 0)) __PYX_ERR(0, 882, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_df = values[0]; __pyx_v_dst_path = values[1]; __pyx_v_file_label = ((PyObject*)values[2]); __pyx_v_column_labels = values[3]; __pyx_v_variable_format = ((PyObject*)values[4]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("write_por", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 882, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("pyreadstat.pyreadstat.write_por", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_file_label), (&PyString_Type), 1, "file_label", 1))) __PYX_ERR(0, 882, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_variable_format), (&PyDict_Type), 1, "variable_format", 1))) __PYX_ERR(0, 882, __pyx_L1_error) __pyx_r = __pyx_pf_10pyreadstat_10pyreadstat_23write_por(__pyx_self, __pyx_v_df, __pyx_v_dst_path, __pyx_v_file_label, __pyx_v_column_labels, __pyx_v_variable_format); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_10pyreadstat_10pyreadstat_23write_por(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_dst_path, PyObject *__pyx_v_file_label, PyObject *__pyx_v_column_labels, PyObject *__pyx_v_variable_format) { PyObject *__pyx_v_note = 0; int __pyx_v_file_format_version; PyObject *__pyx_v_variable_value_labels = 0; PyObject *__pyx_v_missing_ranges = 0; PyObject *__pyx_v_missing_user_values = 0; PyObject *__pyx_v_variable_alignment = 0; PyObject *__pyx_v_variable_display_width = 0; PyObject *__pyx_v_variable_measure = 0; PyObject *__pyx_v_table_name = 0; int __pyx_v_row_compression; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_por", 1); /* "pyreadstat/pyreadstat.pyx":906 * * # atm version 5 and 8 are supported by readstat but only 5 can be later be read by SAS * cdef str note=None # <<<<<<<<<<<<<< * cdef int file_format_version = 0 * cdef dict variable_value_labels=None */ __Pyx_INCREF(Py_None); __pyx_v_note = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":907 * # atm version 5 and 8 are supported by readstat but only 5 can be later be read by SAS * cdef str note=None * cdef int file_format_version = 0 # <<<<<<<<<<<<<< * cdef dict variable_value_labels=None * cdef dict missing_ranges = None */ __pyx_v_file_format_version = 0; /* "pyreadstat/pyreadstat.pyx":908 * cdef str note=None * cdef int file_format_version = 0 * cdef dict variable_value_labels=None # <<<<<<<<<<<<<< * cdef dict missing_ranges = None * cdef dict missing_user_values = None */ __Pyx_INCREF(Py_None); __pyx_v_variable_value_labels = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":909 * cdef int file_format_version = 0 * cdef dict variable_value_labels=None * cdef dict missing_ranges = None # <<<<<<<<<<<<<< * cdef dict missing_user_values = None * cdef dict variable_alignment = None */ __Pyx_INCREF(Py_None); __pyx_v_missing_ranges = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":910 * cdef dict variable_value_labels=None * cdef dict missing_ranges = None * cdef dict missing_user_values = None # <<<<<<<<<<<<<< * cdef dict variable_alignment = None * cdef dict variable_display_width = None */ __Pyx_INCREF(Py_None); __pyx_v_missing_user_values = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":911 * cdef dict missing_ranges = None * cdef dict missing_user_values = None * cdef dict variable_alignment = None # <<<<<<<<<<<<<< * cdef dict variable_display_width = None * cdef dict variable_measure = None */ __Pyx_INCREF(Py_None); __pyx_v_variable_alignment = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":912 * cdef dict missing_user_values = None * cdef dict variable_alignment = None * cdef dict variable_display_width = None # <<<<<<<<<<<<<< * cdef dict variable_measure = None * cdef str table_name = "" */ __Pyx_INCREF(Py_None); __pyx_v_variable_display_width = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":913 * cdef dict variable_alignment = None * cdef dict variable_display_width = None * cdef dict variable_measure = None # <<<<<<<<<<<<<< * cdef str table_name = "" * #cdef dict variable_format = None */ __Pyx_INCREF(Py_None); __pyx_v_variable_measure = ((PyObject*)Py_None); /* "pyreadstat/pyreadstat.pyx":914 * cdef dict variable_display_width = None * cdef dict variable_measure = None * cdef str table_name = "" # <<<<<<<<<<<<<< * #cdef dict variable_format = None * cdef bint row_compression = 0 */ __Pyx_INCREF(__pyx_kp_s__6); __pyx_v_table_name = __pyx_kp_s__6; /* "pyreadstat/pyreadstat.pyx":916 * cdef str table_name = "" * #cdef dict variable_format = None * cdef bint row_compression = 0 # <<<<<<<<<<<<<< * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_POR, file_label, column_labels, * file_format_version, note, table_name, variable_value_labels, missing_ranges,missing_user_values, */ __pyx_v_row_compression = 0; /* "pyreadstat/pyreadstat.pyx":917 * #cdef dict variable_format = None * cdef bint row_compression = 0 * run_write(df, dst_path, _readstat_writer.FILE_FORMAT_POR, file_label, column_labels, # <<<<<<<<<<<<<< * file_format_version, note, table_name, variable_value_labels, missing_ranges,missing_user_values, * variable_alignment,variable_display_width, variable_measure, variable_format, row_compression) */ __pyx_f_10pyreadstat_16_readstat_writer_run_write(__pyx_v_df, __pyx_v_dst_path, __pyx_e_10pyreadstat_16_readstat_writer_FILE_FORMAT_POR, __pyx_v_file_label, __pyx_v_column_labels, __pyx_v_file_format_version, __pyx_v_note, __pyx_v_table_name, __pyx_v_variable_value_labels, __pyx_v_missing_ranges, __pyx_v_missing_user_values, __pyx_v_variable_alignment, __pyx_v_variable_display_width, __pyx_v_variable_measure, __pyx_v_variable_format, __pyx_v_row_compression); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 917, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":882 * variable_alignment,variable_display_width, variable_measure, variable_format, row_compression) * * def write_por(df, dst_path, str file_label="", object column_labels=None, dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a SPSS POR file. */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("pyreadstat.pyreadstat.write_por", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_note); __Pyx_XDECREF(__pyx_v_variable_value_labels); __Pyx_XDECREF(__pyx_v_missing_ranges); __Pyx_XDECREF(__pyx_v_missing_user_values); __Pyx_XDECREF(__pyx_v_variable_alignment); __Pyx_XDECREF(__pyx_v_variable_display_width); __Pyx_XDECREF(__pyx_v_variable_measure); __Pyx_XDECREF(__pyx_v_table_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *__pyx_freelist_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks[8]; static int __pyx_freecount_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks = 0; static PyObject *__pyx_tp_new_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; #if CYTHON_COMPILING_IN_LIMITED_API allocfunc alloc_func = (allocfunc)PyType_GetSlot(t, Py_tp_alloc); o = alloc_func(t, 0); #else #if CYTHON_COMPILING_IN_CPYTHON if (likely((int)(__pyx_freecount_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks > 0) & (int)(t->tp_basicsize == sizeof(struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks)))) { o = (PyObject*)__pyx_freelist_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks[--__pyx_freecount_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks]; memset(o, 0, sizeof(struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks)); (void) PyObject_INIT(o, t); PyObject_GC_Track(o); } else #endif { o = (*t->tp_alloc)(t, 0); if (unlikely(!o)) return 0; } #endif return o; } static void __pyx_tp_dealloc_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks(PyObject *o) { struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *p = (struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *)o; #if CYTHON_USE_TP_FINALIZE if (unlikely((PY_VERSION_HEX >= 0x03080000 || __Pyx_PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE)) && __Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) { if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks) { if (PyObject_CallFinalizerFromDealloc(o)) return; } } #endif PyObject_GC_UnTrack(o); Py_CLEAR(p->__pyx_v__); Py_CLEAR(p->__pyx_v_chunksize); Py_CLEAR(p->__pyx_v_df); Py_CLEAR(p->__pyx_v_file_path); Py_CLEAR(p->__pyx_v_kwargs); Py_CLEAR(p->__pyx_v_limit); Py_CLEAR(p->__pyx_v_meta); Py_CLEAR(p->__pyx_v_multiprocess); Py_CLEAR(p->__pyx_v_num_processes); Py_CLEAR(p->__pyx_v_num_rows); Py_CLEAR(p->__pyx_v_numrows); Py_CLEAR(p->__pyx_v_offset); Py_CLEAR(p->__pyx_v_read_function); #if CYTHON_COMPILING_IN_CPYTHON if (((int)(__pyx_freecount_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks < 8) & (int)(Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks)))) { __pyx_freelist_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks[__pyx_freecount_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks++] = ((struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *)o); } else #endif { #if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY (*Py_TYPE(o)->tp_free)(o); #else { freefunc tp_free = (freefunc)PyType_GetSlot(Py_TYPE(o), Py_tp_free); if (tp_free) tp_free(o); } #endif } } static int __pyx_tp_traverse_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks(PyObject *o, visitproc v, void *a) { int e; struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *p = (struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks *)o; if (p->__pyx_v__) { e = (*v)(p->__pyx_v__, a); if (e) return e; } if (p->__pyx_v_chunksize) { e = (*v)(p->__pyx_v_chunksize, a); if (e) return e; } if (p->__pyx_v_df) { e = (*v)(p->__pyx_v_df, a); if (e) return e; } if (p->__pyx_v_file_path) { e = (*v)(p->__pyx_v_file_path, a); if (e) return e; } if (p->__pyx_v_kwargs) { e = (*v)(p->__pyx_v_kwargs, a); if (e) return e; } if (p->__pyx_v_limit) { e = (*v)(p->__pyx_v_limit, a); if (e) return e; } if (p->__pyx_v_meta) { e = (*v)(p->__pyx_v_meta, a); if (e) return e; } if (p->__pyx_v_multiprocess) { e = (*v)(p->__pyx_v_multiprocess, a); if (e) return e; } if (p->__pyx_v_num_processes) { e = (*v)(p->__pyx_v_num_processes, a); if (e) return e; } if (p->__pyx_v_num_rows) { e = (*v)(p->__pyx_v_num_rows, a); if (e) return e; } if (p->__pyx_v_numrows) { e = (*v)(p->__pyx_v_numrows, a); if (e) return e; } if (p->__pyx_v_offset) { e = (*v)(p->__pyx_v_offset, a); if (e) return e; } if (p->__pyx_v_read_function) { e = (*v)(p->__pyx_v_read_function, a); if (e) return e; } return 0; } #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks_slots[] = { {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks}, {Py_tp_traverse, (void *)__pyx_tp_traverse_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks}, {Py_tp_new, (void *)__pyx_tp_new_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks}, {0, 0}, }; static PyType_Spec __pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks_spec = { "pyreadstat.pyreadstat.__pyx_scope_struct__read_file_in_chunks", sizeof(struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks), 0, Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_FINALIZE, __pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks_slots, }; #else static PyTypeObject __pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks = { PyVarObject_HEAD_INIT(0, 0) "pyreadstat.pyreadstat.""__pyx_scope_struct__read_file_in_chunks", /*tp_name*/ sizeof(struct __pyx_obj_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks), /*tp_basicsize*/ 0, /*tp_itemsize*/ __pyx_tp_dealloc_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks, /*tp_dealloc*/ #if PY_VERSION_HEX < 0x030800b4 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030800b4 0, /*tp_vectorcall_offset*/ #endif 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 0, /*tp_compare*/ #endif #if PY_MAJOR_VERSION >= 3 0, /*tp_as_async*/ #endif 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/ 0, /*tp_doc*/ __pyx_tp_traverse_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ #if !CYTHON_USE_TYPE_SPECS 0, /*tp_dictoffset*/ #endif 0, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ 0, /*tp_mro*/ 0, /*tp_cache*/ 0, /*tp_subclasses*/ 0, /*tp_weaklist*/ 0, /*tp_del*/ 0, /*tp_version_tag*/ #if PY_VERSION_HEX >= 0x030400a1 #if CYTHON_USE_TP_FINALIZE 0, /*tp_finalize*/ #else NULL, /*tp_finalize*/ #endif #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, /*tp_vectorcall*/ #endif #if __PYX_NEED_TP_PRINT_SLOT == 1 0, /*tp_print*/ #endif #if PY_VERSION_HEX >= 0x030C0000 0, /*tp_watched*/ #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, /*tp_pypy_flags*/ #endif }; #endif static PyMethodDef __pyx_methods[] = { {0, 0, 0, 0} }; #ifndef CYTHON_SMALL_CODE #if defined(__clang__) #define CYTHON_SMALL_CODE #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) #define CYTHON_SMALL_CODE __attribute__((cold)) #else #define CYTHON_SMALL_CODE #endif #endif /* #### Code section: pystring_table ### */ static int __Pyx_CreateStringTabAndInitStrings(void) { __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_F_var_width_0, __pyx_k_F_var_width_0, sizeof(__pyx_k_F_var_width_0), 0, 0, 1, 0}, {&__pyx_kp_s_N_var_width, __pyx_k_N_var_width, sizeof(__pyx_k_N_var_width), 0, 0, 1, 0}, {&__pyx_n_s_Pool, __pyx_k_Pool, sizeof(__pyx_k_Pool), 0, 0, 1, 1}, {&__pyx_n_s_PyreadstatError, __pyx_k_PyreadstatError, sizeof(__pyx_k_PyreadstatError), 0, 0, 1, 1}, {&__pyx_kp_s_The_number_of_rows_of_the_file_c, __pyx_k_The_number_of_rows_of_the_file_c, sizeof(__pyx_k_The_number_of_rows_of_the_file_c), 0, 0, 1, 0}, {&__pyx_kp_s_Version_not_supported, __pyx_k_Version_not_supported, sizeof(__pyx_k_Version_not_supported), 0, 0, 1, 0}, {&__pyx_n_s__10, __pyx_k__10, sizeof(__pyx_k__10), 0, 0, 1, 1}, {&__pyx_n_s__37, __pyx_k__37, sizeof(__pyx_k__37), 0, 0, 1, 1}, {&__pyx_kp_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 0}, {&__pyx_n_s__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 0, 1, 1}, {&__pyx_kp_u__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 1, 0, 0}, {&__pyx_n_s_apply_value_formats, __pyx_k_apply_value_formats, sizeof(__pyx_k_apply_value_formats), 0, 0, 1, 1}, {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1}, {&__pyx_n_s_asyncio_coroutines, __pyx_k_asyncio_coroutines, sizeof(__pyx_k_asyncio_coroutines), 0, 0, 1, 1}, {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1}, {&__pyx_n_s_catalog, __pyx_k_catalog, sizeof(__pyx_k_catalog), 0, 0, 1, 1}, {&__pyx_n_s_catalog_file, __pyx_k_catalog_file, sizeof(__pyx_k_catalog_file), 0, 0, 1, 1}, {&__pyx_n_s_chunk, __pyx_k_chunk, sizeof(__pyx_k_chunk), 0, 0, 1, 1}, {&__pyx_n_s_chunks, __pyx_k_chunks, sizeof(__pyx_k_chunks), 0, 0, 1, 1}, {&__pyx_n_s_chunksize, __pyx_k_chunksize, sizeof(__pyx_k_chunksize), 0, 0, 1, 1}, {&__pyx_n_s_class_getitem, __pyx_k_class_getitem, sizeof(__pyx_k_class_getitem), 0, 0, 1, 1}, {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, {&__pyx_n_s_col_format, __pyx_k_col_format, sizeof(__pyx_k_col_format), 0, 0, 1, 1}, {&__pyx_n_s_col_name, __pyx_k_col_name, sizeof(__pyx_k_col_name), 0, 0, 1, 1}, {&__pyx_n_s_column_labels, __pyx_k_column_labels, sizeof(__pyx_k_column_labels), 0, 0, 1, 1}, {&__pyx_n_s_columns, __pyx_k_columns, sizeof(__pyx_k_columns), 0, 0, 1, 1}, {&__pyx_n_s_compress, __pyx_k_compress, sizeof(__pyx_k_compress), 0, 0, 1, 1}, {&__pyx_kp_s_compress_and_row_compress_cannot, __pyx_k_compress_and_row_compress_cannot, sizeof(__pyx_k_compress_and_row_compress_cannot), 0, 0, 1, 0}, {&__pyx_n_s_concat, __pyx_k_concat, sizeof(__pyx_k_concat), 0, 0, 1, 1}, {&__pyx_n_s_concatenate, __pyx_k_concatenate, sizeof(__pyx_k_concatenate), 0, 0, 1, 1}, {&__pyx_n_s_cpu_count, __pyx_k_cpu_count, sizeof(__pyx_k_cpu_count), 0, 0, 1, 1}, {&__pyx_n_s_data_frame, __pyx_k_data_frame, sizeof(__pyx_k_data_frame), 0, 0, 1, 1}, {&__pyx_n_s_dates_as_pandas, __pyx_k_dates_as_pandas, sizeof(__pyx_k_dates_as_pandas), 0, 0, 1, 1}, {&__pyx_n_s_dates_as_pandas_datetime, __pyx_k_dates_as_pandas_datetime, sizeof(__pyx_k_dates_as_pandas_datetime), 0, 0, 1, 1}, {&__pyx_n_s_df, __pyx_k_df, sizeof(__pyx_k_df), 0, 0, 1, 1}, {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, {&__pyx_kp_u_disable, __pyx_k_disable, sizeof(__pyx_k_disable), 0, 1, 0, 0}, {&__pyx_n_s_disable_datetime_conversion, __pyx_k_disable_datetime_conversion, sizeof(__pyx_k_disable_datetime_conversion), 0, 0, 1, 1}, {&__pyx_n_s_div, __pyx_k_div, sizeof(__pyx_k_div), 0, 0, 1, 1}, {&__pyx_n_s_divs, __pyx_k_divs, sizeof(__pyx_k_divs), 0, 0, 1, 1}, {&__pyx_n_s_dst_path, __pyx_k_dst_path, sizeof(__pyx_k_dst_path), 0, 0, 1, 1}, {&__pyx_n_s_dta, __pyx_k_dta, sizeof(__pyx_k_dta), 0, 0, 1, 1}, {&__pyx_kp_u_enable, __pyx_k_enable, sizeof(__pyx_k_enable), 0, 1, 0, 0}, {&__pyx_n_s_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 0, 0, 1, 1}, {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, {&__pyx_n_s_extra_date_formats, __pyx_k_extra_date_formats, sizeof(__pyx_k_extra_date_formats), 0, 0, 1, 1}, {&__pyx_n_s_extra_datetime_formats, __pyx_k_extra_datetime_formats, sizeof(__pyx_k_extra_datetime_formats), 0, 0, 1, 1}, {&__pyx_n_s_file_extension, __pyx_k_file_extension, sizeof(__pyx_k_file_extension), 0, 0, 1, 1}, {&__pyx_n_s_file_format, __pyx_k_file_format, sizeof(__pyx_k_file_format), 0, 0, 1, 1}, {&__pyx_n_s_file_format_version, __pyx_k_file_format_version, sizeof(__pyx_k_file_format_version), 0, 0, 1, 1}, {&__pyx_n_s_file_label, __pyx_k_file_label, sizeof(__pyx_k_file_label), 0, 0, 1, 1}, {&__pyx_n_s_file_path, __pyx_k_file_path, sizeof(__pyx_k_file_path), 0, 0, 1, 1}, {&__pyx_n_s_filename_path, __pyx_k_filename_path, sizeof(__pyx_k_filename_path), 0, 0, 1, 1}, {&__pyx_n_s_final, __pyx_k_final, sizeof(__pyx_k_final), 0, 0, 1, 1}, {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, {&__pyx_n_s_formats_as_category, __pyx_k_formats_as_category, sizeof(__pyx_k_formats_as_category), 0, 0, 1, 1}, {&__pyx_n_s_formats_as_ordered_category, __pyx_k_formats_as_ordered_category, sizeof(__pyx_k_formats_as_ordered_category), 0, 0, 1, 1}, {&__pyx_n_s_formats_presets, __pyx_k_formats_presets, sizeof(__pyx_k_formats_presets), 0, 0, 1, 1}, {&__pyx_kp_u_gc, __pyx_k_gc, sizeof(__pyx_k_gc), 0, 1, 0, 0}, {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, {&__pyx_n_s_ignore_index, __pyx_k_ignore_index, sizeof(__pyx_k_ignore_index), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_indx, __pyx_k_indx, sizeof(__pyx_k_indx), 0, 0, 1, 1}, {&__pyx_n_s_inf, __pyx_k_inf, sizeof(__pyx_k_inf), 0, 0, 1, 1}, {&__pyx_n_s_initializing, __pyx_k_initializing, sizeof(__pyx_k_initializing), 0, 0, 1, 1}, {&__pyx_n_s_integer, __pyx_k_integer, sizeof(__pyx_k_integer), 0, 0, 1, 1}, {&__pyx_n_s_is_coroutine, __pyx_k_is_coroutine, sizeof(__pyx_k_is_coroutine), 0, 0, 1, 1}, {&__pyx_kp_u_isenabled, __pyx_k_isenabled, sizeof(__pyx_k_isenabled), 0, 1, 0, 0}, {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1}, {&__pyx_n_s_jobs, __pyx_k_jobs, sizeof(__pyx_k_jobs), 0, 0, 1, 1}, {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1}, {&__pyx_n_s_keys, __pyx_k_keys, sizeof(__pyx_k_keys), 0, 0, 1, 1}, {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1}, {&__pyx_n_s_limit, __pyx_k_limit, sizeof(__pyx_k_limit), 0, 0, 1, 1}, {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, {&__pyx_n_s_map, __pyx_k_map, sizeof(__pyx_k_map), 0, 0, 1, 1}, {&__pyx_n_s_max, __pyx_k_max, sizeof(__pyx_k_max), 0, 0, 1, 1}, {&__pyx_n_s_meta, __pyx_k_meta, sizeof(__pyx_k_meta), 0, 0, 1, 1}, {&__pyx_n_s_metadata, __pyx_k_metadata, sizeof(__pyx_k_metadata), 0, 0, 1, 1}, {&__pyx_n_s_metadataonly, __pyx_k_metadataonly, sizeof(__pyx_k_metadataonly), 0, 0, 1, 1}, {&__pyx_n_s_metaonly, __pyx_k_metaonly, sizeof(__pyx_k_metaonly), 0, 0, 1, 1}, {&__pyx_n_s_missing_ranges, __pyx_k_missing_ranges, sizeof(__pyx_k_missing_ranges), 0, 0, 1, 1}, {&__pyx_n_s_missing_user_values, __pyx_k_missing_user_values, sizeof(__pyx_k_missing_user_values), 0, 0, 1, 1}, {&__pyx_n_s_mp, __pyx_k_mp, sizeof(__pyx_k_mp), 0, 0, 1, 1}, {&__pyx_n_s_multiprocess, __pyx_k_multiprocess, sizeof(__pyx_k_multiprocess), 0, 0, 1, 1}, {&__pyx_n_s_multiprocessing, __pyx_k_multiprocessing, sizeof(__pyx_k_multiprocessing), 0, 0, 1, 1}, {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, {&__pyx_n_s_no_datetime_conversion, __pyx_k_no_datetime_conversion, sizeof(__pyx_k_no_datetime_conversion), 0, 0, 1, 1}, {&__pyx_n_s_note, __pyx_k_note, sizeof(__pyx_k_note), 0, 0, 1, 1}, {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, {&__pyx_n_s_num_processes, __pyx_k_num_processes, sizeof(__pyx_k_num_processes), 0, 0, 1, 1}, {&__pyx_n_s_num_rows, __pyx_k_num_rows, sizeof(__pyx_k_num_rows), 0, 0, 1, 1}, {&__pyx_kp_s_num_rows_must_be_specified_for_r, __pyx_k_num_rows_must_be_specified_for_r, sizeof(__pyx_k_num_rows_must_be_specified_for_r), 0, 0, 1, 0}, {&__pyx_n_s_number_rows, __pyx_k_number_rows, sizeof(__pyx_k_number_rows), 0, 0, 1, 1}, {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, {&__pyx_n_s_numrows, __pyx_k_numrows, sizeof(__pyx_k_numrows), 0, 0, 1, 1}, {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1}, {&__pyx_n_s_offsets, __pyx_k_offsets, sizeof(__pyx_k_offsets), 0, 0, 1, 1}, {&__pyx_n_s_output_format, __pyx_k_output_format, sizeof(__pyx_k_output_format), 0, 0, 1, 1}, {&__pyx_n_s_pandas, __pyx_k_pandas, sizeof(__pyx_k_pandas), 0, 0, 1, 1}, {&__pyx_n_s_pd, __pyx_k_pd, sizeof(__pyx_k_pd), 0, 0, 1, 1}, {&__pyx_n_s_pool, __pyx_k_pool, sizeof(__pyx_k_pool), 0, 0, 1, 1}, {&__pyx_n_s_pop, __pyx_k_pop, sizeof(__pyx_k_pop), 0, 0, 1, 1}, {&__pyx_n_s_por, __pyx_k_por, sizeof(__pyx_k_por), 0, 0, 1, 1}, {&__pyx_n_s_prev_div, __pyx_k_prev_div, sizeof(__pyx_k_prev_div), 0, 0, 1, 1}, {&__pyx_n_s_prev_offset, __pyx_k_prev_offset, sizeof(__pyx_k_prev_offset), 0, 0, 1, 1}, {&__pyx_n_s_processes, __pyx_k_processes, sizeof(__pyx_k_processes), 0, 0, 1, 1}, {&__pyx_n_s_pyfunctions, __pyx_k_pyfunctions, sizeof(__pyx_k_pyfunctions), 0, 0, 1, 1}, {&__pyx_n_s_pyreadstat_pyreadstat, __pyx_k_pyreadstat_pyreadstat, sizeof(__pyx_k_pyreadstat_pyreadstat), 0, 0, 1, 1}, {&__pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_k_pyreadstat_pyreadstat_pyx, sizeof(__pyx_k_pyreadstat_pyreadstat_pyx), 0, 0, 1, 0}, {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, {&__pyx_n_s_read_dta, __pyx_k_read_dta, sizeof(__pyx_k_read_dta), 0, 0, 1, 1}, {&__pyx_n_s_read_file_in_chunks, __pyx_k_read_file_in_chunks, sizeof(__pyx_k_read_file_in_chunks), 0, 0, 1, 1}, {&__pyx_n_s_read_file_multiprocessing, __pyx_k_read_file_multiprocessing, sizeof(__pyx_k_read_file_multiprocessing), 0, 0, 1, 1}, {&__pyx_n_s_read_function, __pyx_k_read_function, sizeof(__pyx_k_read_function), 0, 0, 1, 1}, {&__pyx_n_s_read_por, __pyx_k_read_por, sizeof(__pyx_k_read_por), 0, 0, 1, 1}, {&__pyx_n_s_read_sas7bcat, __pyx_k_read_sas7bcat, sizeof(__pyx_k_read_sas7bcat), 0, 0, 1, 1}, {&__pyx_kp_s_read_sas7bcat_is_not_supported, __pyx_k_read_sas7bcat_is_not_supported, sizeof(__pyx_k_read_sas7bcat_is_not_supported), 0, 0, 1, 0}, {&__pyx_kp_s_read_sas7bcat_not_supported, __pyx_k_read_sas7bcat_not_supported, sizeof(__pyx_k_read_sas7bcat_not_supported), 0, 0, 1, 0}, {&__pyx_n_s_read_sas7bdat, __pyx_k_read_sas7bdat, sizeof(__pyx_k_read_sas7bdat), 0, 0, 1, 1}, {&__pyx_n_s_read_sav, __pyx_k_read_sav, sizeof(__pyx_k_read_sav), 0, 0, 1, 1}, {&__pyx_n_s_read_xport, __pyx_k_read_xport, sizeof(__pyx_k_read_xport), 0, 0, 1, 1}, {&__pyx_n_s_readstat_parser, __pyx_k_readstat_parser, sizeof(__pyx_k_readstat_parser), 0, 0, 1, 1}, {&__pyx_n_s_restricted_integer, __pyx_k_restricted_integer, sizeof(__pyx_k_restricted_integer), 0, 0, 1, 1}, {&__pyx_n_s_row_compress, __pyx_k_row_compress, sizeof(__pyx_k_row_compress), 0, 0, 1, 1}, {&__pyx_n_s_row_compression, __pyx_k_row_compression, sizeof(__pyx_k_row_compression), 0, 0, 1, 1}, {&__pyx_n_s_row_limit, __pyx_k_row_limit, sizeof(__pyx_k_row_limit), 0, 0, 1, 1}, {&__pyx_n_s_row_offset, __pyx_k_row_offset, sizeof(__pyx_k_row_offset), 0, 0, 1, 1}, {&__pyx_n_s_sas7bcat, __pyx_k_sas7bcat, sizeof(__pyx_k_sas7bcat), 0, 0, 1, 1}, {&__pyx_n_s_sas7bdat, __pyx_k_sas7bdat, sizeof(__pyx_k_sas7bdat), 0, 0, 1, 1}, {&__pyx_kp_s_sav_zsav, __pyx_k_sav_zsav, sizeof(__pyx_k_sav_zsav), 0, 0, 1, 0}, {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1}, {&__pyx_n_s_set_catalog_to_sas, __pyx_k_set_catalog_to_sas, sizeof(__pyx_k_set_catalog_to_sas), 0, 0, 1, 1}, {&__pyx_n_s_set_value_labels, __pyx_k_set_value_labels, sizeof(__pyx_k_set_value_labels), 0, 0, 1, 1}, {&__pyx_n_s_spec, __pyx_k_spec, sizeof(__pyx_k_spec), 0, 0, 1, 1}, {&__pyx_n_s_table_name, __pyx_k_table_name, sizeof(__pyx_k_table_name), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1}, {&__pyx_n_s_usecols, __pyx_k_usecols, sizeof(__pyx_k_usecols), 0, 0, 1, 1}, {&__pyx_n_s_user_missing, __pyx_k_user_missing, sizeof(__pyx_k_user_missing), 0, 0, 1, 1}, {&__pyx_n_s_usernan, __pyx_k_usernan, sizeof(__pyx_k_usernan), 0, 0, 1, 1}, {&__pyx_n_s_var_width, __pyx_k_var_width, sizeof(__pyx_k_var_width), 0, 0, 1, 1}, {&__pyx_n_s_variable_alignment, __pyx_k_variable_alignment, sizeof(__pyx_k_variable_alignment), 0, 0, 1, 1}, {&__pyx_n_s_variable_display_width, __pyx_k_variable_display_width, sizeof(__pyx_k_variable_display_width), 0, 0, 1, 1}, {&__pyx_n_s_variable_format, __pyx_k_variable_format, sizeof(__pyx_k_variable_format), 0, 0, 1, 1}, {&__pyx_n_s_variable_measure, __pyx_k_variable_measure, sizeof(__pyx_k_variable_measure), 0, 0, 1, 1}, {&__pyx_n_s_variable_value_labels, __pyx_k_variable_value_labels, sizeof(__pyx_k_variable_value_labels), 0, 0, 1, 1}, {&__pyx_n_s_version, __pyx_k_version, sizeof(__pyx_k_version), 0, 0, 1, 1}, {&__pyx_n_s_worker, __pyx_k_worker, sizeof(__pyx_k_worker), 0, 0, 1, 1}, {&__pyx_n_s_write_dta, __pyx_k_write_dta, sizeof(__pyx_k_write_dta), 0, 0, 1, 1}, {&__pyx_n_s_write_por, __pyx_k_write_por, sizeof(__pyx_k_write_por), 0, 0, 1, 1}, {&__pyx_n_s_write_sav, __pyx_k_write_sav, sizeof(__pyx_k_write_sav), 0, 0, 1, 1}, {&__pyx_n_s_write_xport, __pyx_k_write_xport, sizeof(__pyx_k_write_xport), 0, 0, 1, 1}, {&__pyx_n_s_x, __pyx_k_x, sizeof(__pyx_k_x), 0, 0, 1, 1}, {&__pyx_n_s_xport, __pyx_k_xport, sizeof(__pyx_k_xport), 0, 0, 1, 1}, {0, 0, 0, 0, 0, 0, 0} }; return __Pyx_InitStrings(__pyx_string_tab); } /* #### Code section: cached_builtins ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 672, __pyx_L1_error) __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 676, __pyx_L1_error) __pyx_builtin_max = __Pyx_GetBuiltinName(__pyx_n_s_max); if (!__pyx_builtin_max) __PYX_ERR(0, 769, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: cached_constants ### */ static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); /* "pyreadstat/pyreadstat.pyx":585 * * if read_function == read_sas7bcat: * raise Exception("read_sas7bcat not supported") # <<<<<<<<<<<<<< * * if "row_offset" in kwargs: */ __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_read_sas7bcat_not_supported); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 585, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); /* "pyreadstat/pyreadstat.pyx":650 * * if read_function in (read_sas7bcat,): * raise Exception("read_sas7bcat is not supported") # <<<<<<<<<<<<<< * * if read_function in (read_xport, read_por) and num_rows is None: */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_read_sas7bcat_is_not_supported); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); /* "pyreadstat/pyreadstat.pyx":653 * * if read_function in (read_xport, read_por) and num_rows is None: * raise Exception("num_rows must be specified for read_xport and read_por to be a number equal or larger than the number of rows in the dataset.") # <<<<<<<<<<<<<< * * if not num_processes: */ __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_num_rows_must_be_specified_for_r); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 653, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); /* "pyreadstat/pyreadstat.pyx":666 * if numrows is None: * if num_rows is None: * raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") # <<<<<<<<<<<<<< * numrows = num_rows * elif numrows == 0: */ __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_The_number_of_rows_of_the_file_c); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* "pyreadstat/pyreadstat.pyx":823 * file_format_version = 113 * else: * raise Exception("Version not supported") # <<<<<<<<<<<<<< * * cdef str note = "" */ __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Version_not_supported); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); /* "pyreadstat/pyreadstat.pyx":42 * # Parsing functions * * def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ __pyx_tuple__11 = PyTuple_Pack(25, __pyx_n_s_filename_path, __pyx_n_s_metadataonly, __pyx_n_s_dates_as_pandas_datetime, __pyx_n_s_catalog_file, __pyx_n_s_formats_as_category, __pyx_n_s_formats_as_ordered_category, __pyx_n_s_encoding, __pyx_n_s_usecols, __pyx_n_s_user_missing, __pyx_n_s_disable_datetime_conversion, __pyx_n_s_row_limit, __pyx_n_s_row_offset, __pyx_n_s_output_format, __pyx_n_s_extra_datetime_formats, __pyx_n_s_extra_date_formats, __pyx_n_s_metaonly, __pyx_n_s_dates_as_pandas, __pyx_n_s_usernan, __pyx_n_s_no_datetime_conversion, __pyx_n_s_file_format, __pyx_n_s_file_extension, __pyx_n_s_data_frame, __pyx_n_s_metadata, __pyx_n_s__10, __pyx_n_s_catalog); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(15, 0, 0, 25, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_read_sas7bdat, 42, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 42, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":142 * * * def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, # <<<<<<<<<<<<<< * list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, * str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): */ __pyx_tuple__13 = PyTuple_Pack(19, __pyx_n_s_filename_path, __pyx_n_s_metadataonly, __pyx_n_s_dates_as_pandas_datetime, __pyx_n_s_encoding, __pyx_n_s_usecols, __pyx_n_s_disable_datetime_conversion, __pyx_n_s_row_limit, __pyx_n_s_row_offset, __pyx_n_s_output_format, __pyx_n_s_extra_datetime_formats, __pyx_n_s_extra_date_formats, __pyx_n_s_metaonly, __pyx_n_s_dates_as_pandas, __pyx_n_s_usernan, __pyx_n_s_no_datetime_conversion, __pyx_n_s_file_format, __pyx_n_s_file_extension, __pyx_n_s_data_frame, __pyx_n_s_metadata); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(11, 0, 0, 19, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_read_xport, 142, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 142, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":215 * * * def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ __pyx_tuple__15 = PyTuple_Pack(23, __pyx_n_s_filename_path, __pyx_n_s_metadataonly, __pyx_n_s_dates_as_pandas_datetime, __pyx_n_s_apply_value_formats, __pyx_n_s_formats_as_category, __pyx_n_s_formats_as_ordered_category, __pyx_n_s_encoding, __pyx_n_s_usecols, __pyx_n_s_user_missing, __pyx_n_s_disable_datetime_conversion, __pyx_n_s_row_limit, __pyx_n_s_row_offset, __pyx_n_s_output_format, __pyx_n_s_extra_datetime_formats, __pyx_n_s_extra_date_formats, __pyx_n_s_metaonly, __pyx_n_s_dates_as_pandas, __pyx_n_s_usernan, __pyx_n_s_no_datetime_conversion, __pyx_n_s_file_format, __pyx_n_s_file_extension, __pyx_n_s_data_frame, __pyx_n_s_metadata); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15); __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(15, 0, 0, 23, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_read_dta, 215, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 215, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":308 * * * def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, */ __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(15, 0, 0, 23, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_read_sav, 308, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) __PYX_ERR(0, 308, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":401 * * * def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ __pyx_tuple__18 = PyTuple_Pack(22, __pyx_n_s_filename_path, __pyx_n_s_metadataonly, __pyx_n_s_dates_as_pandas_datetime, __pyx_n_s_apply_value_formats, __pyx_n_s_formats_as_category, __pyx_n_s_formats_as_ordered_category, __pyx_n_s_usecols, __pyx_n_s_disable_datetime_conversion, __pyx_n_s_row_limit, __pyx_n_s_row_offset, __pyx_n_s_output_format, __pyx_n_s_extra_datetime_formats, __pyx_n_s_extra_date_formats, __pyx_n_s_metaonly, __pyx_n_s_dates_as_pandas, __pyx_n_s_usernan, __pyx_n_s_no_datetime_conversion, __pyx_n_s_encoding, __pyx_n_s_file_format, __pyx_n_s_file_extension, __pyx_n_s_data_frame, __pyx_n_s_metadata); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__18); __Pyx_GIVEREF(__pyx_tuple__18); __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(13, 0, 0, 22, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_read_por, 401, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) __PYX_ERR(0, 401, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":486 * * * def read_sas7bcat(filename_path, str encoding=None, str output_format=None): # <<<<<<<<<<<<<< * r""" * Read a SAS sas7bcat file. The returning dataframe will be empty. The metadata object will contain a dictionary */ __pyx_tuple__20 = PyTuple_Pack(16, __pyx_n_s_filename_path, __pyx_n_s_encoding, __pyx_n_s_output_format, __pyx_n_s_metaonly, __pyx_n_s_dates_as_pandas, __pyx_n_s_usecols, __pyx_n_s_usernan, __pyx_n_s_no_datetime_conversion, __pyx_n_s_row_limit, __pyx_n_s_row_offset, __pyx_n_s_extra_datetime_formats, __pyx_n_s_extra_date_formats, __pyx_n_s_file_format, __pyx_n_s_file_extension, __pyx_n_s_data_frame, __pyx_n_s_metadata); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 486, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_read_sas7bcat, 486, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 486, __pyx_L1_error) __pyx_tuple__22 = PyTuple_Pack(2, Py_None, Py_None); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 486, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); /* "pyreadstat/pyreadstat.pyx":538 * # convenience functions to read in chunks * * def read_file_in_chunks(read_function, file_path, chunksize=100000, offset=0, limit=0, # <<<<<<<<<<<<<< * multiprocess=False, num_processes=4, num_rows=None, **kwargs): * """ */ __pyx_tuple__23 = PyTuple_Pack(13, __pyx_n_s_read_function, __pyx_n_s_file_path, __pyx_n_s_chunksize, __pyx_n_s_offset, __pyx_n_s_limit, __pyx_n_s_multiprocess, __pyx_n_s_num_processes, __pyx_n_s_num_rows, __pyx_n_s_kwargs, __pyx_n_s__10, __pyx_n_s_meta, __pyx_n_s_numrows, __pyx_n_s_df); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 538, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__23); __Pyx_GIVEREF(__pyx_tuple__23); __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(8, 0, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS|CO_GENERATOR, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_read_file_in_chunks, 538, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 538, __pyx_L1_error) __pyx_tuple__24 = PyTuple_Pack(6, ((PyObject *)__pyx_int_100000), ((PyObject *)__pyx_int_0), ((PyObject *)__pyx_int_0), ((PyObject *)Py_False), ((PyObject *)__pyx_int_4), Py_None); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 538, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); /* "pyreadstat/pyreadstat.pyx":619 * offset += chunksize * * def read_file_multiprocessing(read_function, file_path, num_processes=None, num_rows=None, **kwargs): # <<<<<<<<<<<<<< * """ * Reads a file in parallel using multiprocessing. */ __pyx_tuple__25 = PyTuple_Pack(27, __pyx_n_s_read_function, __pyx_n_s_file_path, __pyx_n_s_num_processes, __pyx_n_s_num_rows, __pyx_n_s_kwargs, __pyx_n_s__10, __pyx_n_s_row_offset, __pyx_n_s_row_limit, __pyx_n_s_meta, __pyx_n_s_numrows, __pyx_n_s_final, __pyx_n_s_divs, __pyx_n_s_offsets, __pyx_n_s_prev_offset, __pyx_n_s_prev_div, __pyx_n_s_indx, __pyx_n_s_div, __pyx_n_s_offset, __pyx_n_s_jobs, __pyx_n_s_pool, __pyx_n_s_chunks, __pyx_n_s_output_format, __pyx_n_s_keys, __pyx_n_s_key, __pyx_n_s_x, __pyx_n_s_chunksize, __pyx_n_s_chunk); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__25); __Pyx_GIVEREF(__pyx_tuple__25); __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 27, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_read_file_multiprocessing, 619, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 619, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":701 * # Write API * * def write_sav(df, dst_path, str file_label="", object column_labels=None, compress=False, row_compress=False, str note=None, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_ranges=None, dict variable_display_width=None, * dict variable_measure=None, dict variable_format=None): */ __pyx_tuple__27 = PyTuple_Pack(21, __pyx_n_s_df, __pyx_n_s_dst_path, __pyx_n_s_file_label, __pyx_n_s_column_labels, __pyx_n_s_compress, __pyx_n_s_row_compress, __pyx_n_s_note, __pyx_n_s_variable_value_labels, __pyx_n_s_missing_ranges, __pyx_n_s_variable_display_width, __pyx_n_s_variable_measure, __pyx_n_s_variable_format, __pyx_n_s_file_format_version, __pyx_n_s_var_width, __pyx_n_s_row_compression, __pyx_n_s_table_name, __pyx_n_s_missing_user_values, __pyx_n_s_variable_alignment, __pyx_n_s_formats_presets, __pyx_n_s_col_name, __pyx_n_s_col_format); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__27); __Pyx_GIVEREF(__pyx_tuple__27); __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(12, 0, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_write_sav, 701, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 701, __pyx_L1_error) __pyx_tuple__29 = PyTuple_Pack(10, ((PyObject*)__pyx_kp_s__6), Py_None, ((PyObject *)Py_False), ((PyObject *)Py_False), Py_None, Py_None, Py_None, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29); /* "pyreadstat/pyreadstat.pyx":776 * variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) * * def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): * """ */ __pyx_tuple__30 = PyTuple_Pack(16, __pyx_n_s_df, __pyx_n_s_dst_path, __pyx_n_s_file_label, __pyx_n_s_column_labels, __pyx_n_s_version, __pyx_n_s_variable_value_labels, __pyx_n_s_missing_user_values, __pyx_n_s_variable_format, __pyx_n_s_file_format_version, __pyx_n_s_note, __pyx_n_s_table_name, __pyx_n_s_missing_ranges, __pyx_n_s_variable_alignment, __pyx_n_s_variable_display_width, __pyx_n_s_variable_measure, __pyx_n_s_row_compression); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 776, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__30); __Pyx_GIVEREF(__pyx_tuple__30); __pyx_codeobj__31 = (PyObject*)__Pyx_PyCode_New(8, 0, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__30, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_write_dta, 776, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__31)) __PYX_ERR(0, 776, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":838 * variable_display_width, variable_measure, variable_format, row_compression) * * def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, # <<<<<<<<<<<<<< * dict variable_format=None): * """ */ __pyx_tuple__32 = PyTuple_Pack(15, __pyx_n_s_df, __pyx_n_s_dst_path, __pyx_n_s_file_label, __pyx_n_s_column_labels, __pyx_n_s_table_name, __pyx_n_s_file_format_version, __pyx_n_s_variable_format, __pyx_n_s_variable_value_labels, __pyx_n_s_note, __pyx_n_s_missing_ranges, __pyx_n_s_missing_user_values, __pyx_n_s_variable_alignment, __pyx_n_s_variable_display_width, __pyx_n_s_variable_measure, __pyx_n_s_row_compression); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(0, 838, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__32); __Pyx_GIVEREF(__pyx_tuple__32); __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(7, 0, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__32, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_write_xport, 838, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 838, __pyx_L1_error) /* "pyreadstat/pyreadstat.pyx":882 * variable_alignment,variable_display_width, variable_measure, variable_format, row_compression) * * def write_por(df, dst_path, str file_label="", object column_labels=None, dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a SPSS POR file. */ __pyx_tuple__34 = PyTuple_Pack(15, __pyx_n_s_df, __pyx_n_s_dst_path, __pyx_n_s_file_label, __pyx_n_s_column_labels, __pyx_n_s_variable_format, __pyx_n_s_note, __pyx_n_s_file_format_version, __pyx_n_s_variable_value_labels, __pyx_n_s_missing_ranges, __pyx_n_s_missing_user_values, __pyx_n_s_variable_alignment, __pyx_n_s_variable_display_width, __pyx_n_s_variable_measure, __pyx_n_s_table_name, __pyx_n_s_row_compression); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 882, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34); __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__34, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pyreadstat_pyreadstat_pyx, __pyx_n_s_write_por, 882, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 882, __pyx_L1_error) __pyx_tuple__36 = PyTuple_Pack(3, ((PyObject*)__pyx_kp_s__6), Py_None, Py_None); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 882, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } /* #### Code section: init_constants ### */ static CYTHON_SMALL_CODE int __Pyx_InitConstants(void) { __pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_get.method_name = &__pyx_n_s_get; __pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_items.method_name = &__pyx_n_s_items; __pyx_umethod_PyDict_Type_keys.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_keys.method_name = &__pyx_n_s_keys; __pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type; __pyx_umethod_PyDict_Type_pop.method_name = &__pyx_n_s_pop; if (__Pyx_CreateStringTabAndInitStrings() < 0) __PYX_ERR(0, 1, __pyx_L1_error); __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_int_100000 = PyInt_FromLong(100000L); if (unlikely(!__pyx_int_100000)) __PYX_ERR(0, 1, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; } /* #### Code section: init_globals ### */ static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { return 0; } /* #### Code section: init_module ### */ static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ static int __Pyx_modinit_global_init_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); /*--- Global init code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_variable_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); /*--- Variable export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_function_export_code(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); /*--- Function export code ---*/ __Pyx_RefNannyFinishContext(); return 0; } static int __Pyx_modinit_type_init_code(void) { __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); /*--- Type init code ---*/ #if CYTHON_USE_TYPE_SPECS __pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks_spec, NULL); if (unlikely(!__pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks)) __PYX_ERR(0, 538, __pyx_L1_error) if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks_spec, __pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks) < 0) __PYX_ERR(0, 538, __pyx_L1_error) #else __pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks = &__pyx_type_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks; #endif #if !CYTHON_COMPILING_IN_LIMITED_API #endif #if !CYTHON_USE_TYPE_SPECS if (__Pyx_PyType_Ready(__pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks) < 0) __PYX_ERR(0, 538, __pyx_L1_error) #endif #if PY_MAJOR_VERSION < 3 __pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks->tp_print = 0; #endif #if !CYTHON_COMPILING_IN_LIMITED_API if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks->tp_dictoffset && __pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks->tp_getattro == PyObject_GenericGetAttr)) { __pyx_ptype_10pyreadstat_10pyreadstat___pyx_scope_struct__read_file_in_chunks->tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; } #endif __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_type_import_code(void) { __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); /*--- Type import code ---*/ __pyx_t_1 = PyImport_ImportModule("pyreadstat._readstat_parser"); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_ptype_10pyreadstat_16_readstat_parser_data_container = __Pyx_ImportType_3_0_9(__pyx_t_1, "pyreadstat._readstat_parser", "data_container", sizeof(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container), __PYX_GET_STRUCT_ALIGNMENT_3_0_9(struct __pyx_obj_10pyreadstat_16_readstat_parser_data_container),__Pyx_ImportType_CheckSize_Warn_3_0_9); if (!__pyx_ptype_10pyreadstat_16_readstat_parser_data_container) __PYX_ERR(1, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_variable_import_code(void) { __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); /*--- Variable import code ---*/ __pyx_t_1 = PyImport_ImportModule("pyreadstat._readstat_parser"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "readstat_to_numpy_types", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_readstat_to_numpy_types, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_date_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_datetime_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_time_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_all_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "sas_origin", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_sas_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_datetime_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_date_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_time_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_all_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "spss_origin", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_spss_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_datetime_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_datetime_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_date_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_date_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_time_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_time_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_all_formats", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_all_formats, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (__Pyx_ImportVoidPtr_3_0_9(__pyx_t_1, "stata_origin", (void **)&__pyx_vp_10pyreadstat_16_readstat_parser_stata_origin, "PyObject *") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } static int __Pyx_modinit_function_import_code(void) { __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); /*--- Function import code ---*/ __pyx_t_1 = PyImport_ImportModule("pyreadstat._readstat_parser"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_ImportFunction_3_0_9(__pyx_t_1, "run_conversion", (void (**)(void))&__pyx_f_10pyreadstat_16_readstat_parser_run_conversion, "PyObject *(PyObject *, __pyx_t_10pyreadstat_16_readstat_parser_py_file_format, __pyx_t_10pyreadstat_16_readstat_parser_py_file_extension, PyObject *, int, int, PyObject *, int, int, long, long, PyObject *, PyObject *, PyObject *)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyImport_ImportModule("pyreadstat._readstat_writer"); if (!__pyx_t_1) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (__Pyx_ImportFunction_3_0_9(__pyx_t_1, "run_write", (void (**)(void))&__pyx_f_10pyreadstat_16_readstat_writer_run_write, "int (PyObject *, PyObject *, __pyx_t_10pyreadstat_16_readstat_writer_dst_file_format, PyObject *, PyObject *, int, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, PyObject *, int)") < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_RefNannyFinishContext(); return -1; } #if PY_MAJOR_VERSION >= 3 #if CYTHON_PEP489_MULTI_PHASE_INIT static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ static int __pyx_pymod_exec_pyreadstat(PyObject* module); /*proto*/ static PyModuleDef_Slot __pyx_moduledef_slots[] = { {Py_mod_create, (void*)__pyx_pymod_create}, {Py_mod_exec, (void*)__pyx_pymod_exec_pyreadstat}, {0, NULL} }; #endif #ifdef __cplusplus namespace { struct PyModuleDef __pyx_moduledef = #else static struct PyModuleDef __pyx_moduledef = #endif { PyModuleDef_HEAD_INIT, "pyreadstat", 0, /* m_doc */ #if CYTHON_PEP489_MULTI_PHASE_INIT 0, /* m_size */ #elif CYTHON_USE_MODULE_STATE sizeof(__pyx_mstate), /* m_size */ #else -1, /* m_size */ #endif __pyx_methods /* m_methods */, #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_moduledef_slots, /* m_slots */ #else NULL, /* m_reload */ #endif #if CYTHON_USE_MODULE_STATE __pyx_m_traverse, /* m_traverse */ __pyx_m_clear, /* m_clear */ NULL /* m_free */ #else NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ #endif }; #ifdef __cplusplus } /* anonymous namespace */ #endif #endif #ifndef CYTHON_NO_PYINIT_EXPORT #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC #elif PY_MAJOR_VERSION < 3 #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" void #else #define __Pyx_PyMODINIT_FUNC void #endif #else #ifdef __cplusplus #define __Pyx_PyMODINIT_FUNC extern "C" PyObject * #else #define __Pyx_PyMODINIT_FUNC PyObject * #endif #endif #if PY_MAJOR_VERSION < 3 __Pyx_PyMODINIT_FUNC initpyreadstat(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC initpyreadstat(void) #else __Pyx_PyMODINIT_FUNC PyInit_pyreadstat(void) CYTHON_SMALL_CODE; /*proto*/ __Pyx_PyMODINIT_FUNC PyInit_pyreadstat(void) #if CYTHON_PEP489_MULTI_PHASE_INIT { return PyModuleDef_Init(&__pyx_moduledef); } static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { #if PY_VERSION_HEX >= 0x030700A1 static PY_INT64_T main_interpreter_id = -1; PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); if (main_interpreter_id == -1) { main_interpreter_id = current_id; return (unlikely(current_id == -1)) ? -1 : 0; } else if (unlikely(main_interpreter_id != current_id)) #else static PyInterpreterState *main_interpreter = NULL; PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; if (!main_interpreter) { main_interpreter = current_interpreter; } else if (unlikely(main_interpreter != current_interpreter)) #endif { PyErr_SetString( PyExc_ImportError, "Interpreter change detected - this module can only be loaded into one interpreter per process."); return -1; } return 0; } #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *module, const char* from_name, const char* to_name, int allow_none) #else static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) #endif { PyObject *value = PyObject_GetAttrString(spec, from_name); int result = 0; if (likely(value)) { if (allow_none || value != Py_None) { #if CYTHON_COMPILING_IN_LIMITED_API result = PyModule_AddObject(module, to_name, value); #else result = PyDict_SetItemString(moddict, to_name, value); #endif } Py_DECREF(value); } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); } else { result = -1; } return result; } static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) { PyObject *module = NULL, *moddict, *modname; CYTHON_UNUSED_VAR(def); if (__Pyx_check_single_interpreter()) return NULL; if (__pyx_m) return __Pyx_NewRef(__pyx_m); modname = PyObject_GetAttrString(spec, "name"); if (unlikely(!modname)) goto bad; module = PyModule_NewObject(modname); Py_DECREF(modname); if (unlikely(!module)) goto bad; #if CYTHON_COMPILING_IN_LIMITED_API moddict = module; #else moddict = PyModule_GetDict(module); if (unlikely(!moddict)) goto bad; #endif if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; return module; bad: Py_XDECREF(module); return NULL; } static CYTHON_SMALL_CODE int __pyx_pymod_exec_pyreadstat(PyObject *__pyx_pyinit_module) #endif #endif { int stringtab_initialized = 0; #if CYTHON_USE_MODULE_STATE int pystate_addmodule_run = 0; #endif PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannyDeclarations #if CYTHON_PEP489_MULTI_PHASE_INIT if (__pyx_m) { if (__pyx_m == __pyx_pyinit_module) return 0; PyErr_SetString(PyExc_RuntimeError, "Module 'pyreadstat' has already been imported. Re-initialisation is not supported."); return -1; } #elif PY_MAJOR_VERSION >= 3 if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif /*--- Module creation code ---*/ #if CYTHON_PEP489_MULTI_PHASE_INIT __pyx_m = __pyx_pyinit_module; Py_INCREF(__pyx_m); #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("pyreadstat", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #elif CYTHON_USE_MODULE_STATE __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) { int add_module_result = PyState_AddModule(__pyx_t_1, &__pyx_moduledef); __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "pyreadstat" pseudovariable */ if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error) pystate_addmodule_run = 1; } #else __pyx_m = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) #endif #endif CYTHON_UNUSED_VAR(__pyx_t_1); __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_cython_runtime = __Pyx_PyImport_AddModuleRef((const char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_REFNANNY __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); if (!__Pyx_RefNanny) { PyErr_Clear(); __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); if (!__Pyx_RefNanny) Py_FatalError("failed to import 'refnanny' module"); } #endif __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_pyreadstat(void)", 0); if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pxy_PyFrame_Initialize_Offsets __Pxy_PyFrame_Initialize_Offsets(); #endif __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) #ifdef __Pyx_CyFunction_USED if (__pyx_CyFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_FusedFunction_USED if (__pyx_FusedFunction_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Coroutine_USED if (__pyx_Coroutine_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_Generator_USED if (__pyx_Generator_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_AsyncGen_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init(__pyx_m) < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /*--- Library function declarations ---*/ /*--- Threads initialization code ---*/ #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS PyEval_InitThreads(); #endif /*--- Initialize various global constants etc. ---*/ if (__Pyx_InitConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) stringtab_initialized = 1; if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif if (__pyx_module_is_main_pyreadstat__pyreadstat) { if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) if (!PyDict_GetItemString(modules, "pyreadstat.pyreadstat")) { if (unlikely((PyDict_SetItemString(modules, "pyreadstat.pyreadstat", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif /*--- Builtin init code ---*/ if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Global type/function init code ---*/ (void)__Pyx_modinit_global_init_code(); (void)__Pyx_modinit_variable_export_code(); (void)__Pyx_modinit_function_export_code(); if (unlikely((__Pyx_modinit_type_init_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_type_import_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_variable_import_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) if (unlikely((__Pyx_modinit_function_import_code() < 0))) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif /* "pyreadstat/pyreadstat.pyx":22 * ## if want to profile: # cython: profile=True * * import multiprocessing as mp # <<<<<<<<<<<<<< * * import pandas as pd */ __pyx_t_2 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_multiprocessing, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_mp, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":24 * import multiprocessing as mp * * import pandas as pd # <<<<<<<<<<<<<< * import numpy as np * */ __pyx_t_2 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_pandas, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pd, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":25 * * import pandas as pd * import numpy as np # <<<<<<<<<<<<<< * * #from readstat_api cimport readstat_parse_sas7bdat, readstat_parse_dta, readstat_parse_sav */ __pyx_t_2 = __Pyx_ImportDottedModuleRelFirst(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":32 * #from readstat_api cimport readstat_begin_writing_dta, readstat_begin_writing_por, readstat_begin_writing_sav * from _readstat_parser cimport py_file_format, py_file_extension, run_conversion * from _readstat_parser import PyreadstatError # <<<<<<<<<<<<<< * from _readstat_writer cimport run_write * cimport _readstat_parser, _readstat_writer */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_PyreadstatError); __Pyx_GIVEREF(__pyx_n_s_PyreadstatError); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PyreadstatError)) __PYX_ERR(0, 32, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_readstat_parser, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PyreadstatError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_PyreadstatError, __pyx_t_2) < 0) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/pyreadstat.pyx":35 * from _readstat_writer cimport run_write * cimport _readstat_parser, _readstat_writer * from worker import worker # <<<<<<<<<<<<<< * from pyfunctions import set_value_labels, set_catalog_to_sas * */ __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_worker); __Pyx_GIVEREF(__pyx_n_s_worker); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_worker)) __PYX_ERR(0, 35, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_worker, __pyx_t_3, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_worker); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_worker, __pyx_t_3) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":36 * cimport _readstat_parser, _readstat_writer * from worker import worker * from pyfunctions import set_value_labels, set_catalog_to_sas # <<<<<<<<<<<<<< * * # Public interface */ __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_set_value_labels); __Pyx_GIVEREF(__pyx_n_s_set_value_labels); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_set_value_labels)) __PYX_ERR(0, 36, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_set_catalog_to_sas); __Pyx_GIVEREF(__pyx_n_s_set_catalog_to_sas); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_set_catalog_to_sas)) __PYX_ERR(0, 36, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_pyfunctions, __pyx_t_2, -1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_set_value_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_value_labels, __pyx_t_2) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_set_catalog_to_sas); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_catalog_to_sas, __pyx_t_2) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/pyreadstat.pyx":44 * def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, # <<<<<<<<<<<<<< * list extra_datetime_formats=None, list extra_date_formats=None): * r""" */ __pyx_t_3 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* "pyreadstat/pyreadstat.pyx":42 * # Parsing functions * * def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ __pyx_t_4 = PyTuple_New(14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_False))) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)Py_False))) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None)) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_True)); __Pyx_GIVEREF(((PyObject *)Py_True)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 3, ((PyObject *)Py_True))) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 4, ((PyObject *)Py_False))) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 5, Py_None)) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 6, Py_None)) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 7, ((PyObject *)Py_False))) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 8, ((PyObject *)Py_False))) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 9, __pyx_t_3)) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 10, __pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 11, Py_None)) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 12, Py_None)) __PYX_ERR(0, 42, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 13, Py_None)) __PYX_ERR(0, 42, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_1read_sas7bdat, 0, __pyx_n_s_read_sas7bdat, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_sas7bdat, __pyx_t_2) < 0) __PYX_ERR(0, 42, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":143 * * def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, * list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, # <<<<<<<<<<<<<< * str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): * r""" */ __pyx_t_2 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* "pyreadstat/pyreadstat.pyx":142 * * * def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, # <<<<<<<<<<<<<< * list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, * str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): */ __pyx_t_3 = PyTuple_New(10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_False))) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)Py_False))) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None)) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 3, Py_None)) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)Py_False))) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 7, Py_None)) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 8, Py_None)) __PYX_ERR(0, 142, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 9, Py_None)) __PYX_ERR(0, 142, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_3read_xport, 0, __pyx_n_s_read_xport, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_xport, __pyx_t_4) < 0) __PYX_ERR(0, 142, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":217 * def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, # <<<<<<<<<<<<<< * list extra_datetime_formats=None, list extra_date_formats=None): * r""" */ __pyx_t_4 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* "pyreadstat/pyreadstat.pyx":215 * * * def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ __pyx_t_2 = PyTuple_New(14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)Py_False))) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)Py_False))) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)Py_False))) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_True)); __Pyx_GIVEREF(((PyObject *)Py_True)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)Py_True))) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 4, ((PyObject *)Py_False))) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 5, Py_None)) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 6, Py_None)) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 7, ((PyObject *)Py_False))) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 8, ((PyObject *)Py_False))) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 9, __pyx_t_4)) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 10, __pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 11, Py_None)) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 12, Py_None)) __PYX_ERR(0, 215, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 13, Py_None)) __PYX_ERR(0, 215, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_5read_dta, 0, __pyx_n_s_read_dta, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_dta, __pyx_t_3) < 0) __PYX_ERR(0, 215, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "pyreadstat/pyreadstat.pyx":310 * def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, # <<<<<<<<<<<<<< * list extra_date_formats=None): * r""" */ __pyx_t_3 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 310, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* "pyreadstat/pyreadstat.pyx":308 * * * def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, */ __pyx_t_4 = PyTuple_New(14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)Py_False))) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)Py_False))) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)Py_False))) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_True)); __Pyx_GIVEREF(((PyObject *)Py_True)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 3, ((PyObject *)Py_True))) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 4, ((PyObject *)Py_False))) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 5, Py_None)) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 6, Py_None)) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 7, ((PyObject *)Py_False))) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 8, ((PyObject *)Py_False))) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 9, __pyx_t_3)) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 10, __pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 11, Py_None)) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 12, Py_None)) __PYX_ERR(0, 308, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 13, Py_None)) __PYX_ERR(0, 308, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_7read_sav, 0, __pyx_n_s_read_sav, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__17)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_sav, __pyx_t_2) < 0) __PYX_ERR(0, 308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* "pyreadstat/pyreadstat.pyx":403 * def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, # <<<<<<<<<<<<<< * list extra_datetime_formats=None, list extra_date_formats=None): * r""" */ __pyx_t_2 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* "pyreadstat/pyreadstat.pyx":401 * * * def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, # <<<<<<<<<<<<<< * formats_as_category=True, formats_as_ordered_category=False, list usecols=None, * disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, */ __pyx_t_3 = PyTuple_New(12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_False))) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)Py_False))) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)Py_False))) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_True)); __Pyx_GIVEREF(((PyObject *)Py_True)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)Py_True))) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)Py_False))) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 5, Py_None)) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(((PyObject *)Py_False)); __Pyx_GIVEREF(((PyObject *)Py_False)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 6, ((PyObject *)Py_False))) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 7, __pyx_t_2)) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 8, __pyx_t_4)) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 9, Py_None)) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 10, Py_None)) __PYX_ERR(0, 401, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 11, Py_None)) __PYX_ERR(0, 401, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_9read_por, 0, __pyx_n_s_read_por, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__19)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_por, __pyx_t_4) < 0) __PYX_ERR(0, 401, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":486 * * * def read_sas7bcat(filename_path, str encoding=None, str output_format=None): # <<<<<<<<<<<<<< * r""" * Read a SAS sas7bcat file. The returning dataframe will be empty. The metadata object will contain a dictionary */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_11read_sas7bcat, 0, __pyx_n_s_read_sas7bcat, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 486, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__22); if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_sas7bcat, __pyx_t_4) < 0) __PYX_ERR(0, 486, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":538 * # convenience functions to read in chunks * * def read_file_in_chunks(read_function, file_path, chunksize=100000, offset=0, limit=0, # <<<<<<<<<<<<<< * multiprocess=False, num_processes=4, num_rows=None, **kwargs): * """ */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_13read_file_in_chunks, 0, __pyx_n_s_read_file_in_chunks, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj_)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__24); if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_file_in_chunks, __pyx_t_4) < 0) __PYX_ERR(0, 538, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":619 * offset += chunksize * * def read_file_multiprocessing(read_function, file_path, num_processes=None, num_rows=None, **kwargs): # <<<<<<<<<<<<<< * """ * Reads a file in parallel using multiprocessing. */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_16read_file_multiprocessing, 0, __pyx_n_s_read_file_multiprocessing, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__26)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__22); if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_file_multiprocessing, __pyx_t_4) < 0) __PYX_ERR(0, 619, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":701 * # Write API * * def write_sav(df, dst_path, str file_label="", object column_labels=None, compress=False, row_compress=False, str note=None, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_ranges=None, dict variable_display_width=None, * dict variable_measure=None, dict variable_format=None): */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_18write_sav, 0, __pyx_n_s_write_sav, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__28)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__29); if (PyDict_SetItem(__pyx_d, __pyx_n_s_write_sav, __pyx_t_4) < 0) __PYX_ERR(0, 701, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":776 * variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) * * def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): * """ */ __pyx_t_4 = __Pyx_PyInt_From_int(((int)15)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* "pyreadstat/pyreadstat.pyx":777 * * def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, * dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a STATA dta file */ __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject*)__pyx_kp_s__6)); __Pyx_GIVEREF(((PyObject*)__pyx_kp_s__6)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject*)__pyx_kp_s__6))) __PYX_ERR(0, 776, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, Py_None)) __PYX_ERR(0, 776, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4)) __PYX_ERR(0, 776, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 3, Py_None)) __PYX_ERR(0, 776, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 4, Py_None)) __PYX_ERR(0, 776, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 5, Py_None)) __PYX_ERR(0, 776, __pyx_L1_error); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":776 * variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) * * def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, # <<<<<<<<<<<<<< * dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): * """ */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_20write_dta, 0, __pyx_n_s_write_dta, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__31)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_write_dta, __pyx_t_4) < 0) __PYX_ERR(0, 776, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":838 * variable_display_width, variable_measure, variable_format, row_compression) * * def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, # <<<<<<<<<<<<<< * dict variable_format=None): * """ */ __pyx_t_4 = __Pyx_PyInt_From_int(((int)8)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* "pyreadstat/pyreadstat.pyx":839 * * def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, * dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a SAS Xport (xpt) file. */ __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject*)__pyx_kp_s__6)); __Pyx_GIVEREF(((PyObject*)__pyx_kp_s__6)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject*)__pyx_kp_s__6))) __PYX_ERR(0, 838, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, Py_None)) __PYX_ERR(0, 838, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None)) __PYX_ERR(0, 838, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_4)) __PYX_ERR(0, 838, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 4, Py_None)) __PYX_ERR(0, 838, __pyx_L1_error); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":838 * variable_display_width, variable_measure, variable_format, row_compression) * * def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, # <<<<<<<<<<<<<< * dict variable_format=None): * """ */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_22write_xport, 0, __pyx_n_s_write_xport, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_write_xport, __pyx_t_4) < 0) __PYX_ERR(0, 838, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":882 * variable_alignment,variable_display_width, variable_measure, variable_format, row_compression) * * def write_por(df, dst_path, str file_label="", object column_labels=None, dict variable_format=None): # <<<<<<<<<<<<<< * """ * Writes a pandas data frame to a SPSS POR file. */ __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10pyreadstat_10pyreadstat_24write_por, 0, __pyx_n_s_write_por, NULL, __pyx_n_s_pyreadstat_pyreadstat, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__36); if (PyDict_SetItem(__pyx_d, __pyx_n_s_write_por, __pyx_t_4) < 0) __PYX_ERR(0, 882, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "pyreadstat/pyreadstat.pyx":1 * # cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # <<<<<<<<<<<<<< * * # ############################################################################# */ __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_4) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /*--- Wrapped vars code ---*/ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); if (__pyx_m) { if (__pyx_d && stringtab_initialized) { __Pyx_AddTraceback("init pyreadstat.pyreadstat", __pyx_clineno, __pyx_lineno, __pyx_filename); } #if !CYTHON_USE_MODULE_STATE Py_CLEAR(__pyx_m); #else Py_DECREF(__pyx_m); if (pystate_addmodule_run) { PyObject *tp, *value, *tb; PyErr_Fetch(&tp, &value, &tb); PyState_RemoveModule(&__pyx_moduledef); PyErr_Restore(tp, value, tb); } #endif } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ImportError, "init pyreadstat.pyreadstat"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); #if CYTHON_PEP489_MULTI_PHASE_INIT return (__pyx_m != NULL) ? 0 : -1; #elif PY_MAJOR_VERSION >= 3 return __pyx_m; #else return; #endif } /* #### Code section: cleanup_globals ### */ /* #### Code section: cleanup_module ### */ /* #### Code section: main_method ### */ /* #### Code section: utility_code_pragmas ### */ #ifdef _MSC_VER #pragma warning( push ) /* Warning 4127: conditional expression is constant * Cython uses constant conditional expressions to allow in inline functions to be optimized at * compile-time, so this warning is not useful */ #pragma warning( disable : 4127 ) #endif /* #### Code section: utility_code_def ### */ /* --- Runtime support code --- */ /* Refnanny */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; void *r = NULL; m = PyImport_ImportModule(modname); if (!m) goto end; p = PyObject_GetAttrString(m, "RefNannyAPI"); if (!p) goto end; r = PyLong_AsVoidPtr(p); end: Py_XDECREF(p); Py_XDECREF(m); return (__Pyx_RefNannyAPIStruct *)r; } #endif /* PyErrExceptionMatches */ #if CYTHON_FAST_THREAD_STATE static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i= 0x030C00A6 PyObject *current_exception = tstate->current_exception; if (unlikely(!current_exception)) return 0; exc_type = (PyObject*) Py_TYPE(current_exception); if (exc_type == err) return 1; #else exc_type = tstate->curexc_type; if (exc_type == err) return 1; if (unlikely(!exc_type)) return 0; #endif #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(exc_type); #endif if (unlikely(PyTuple_Check(err))) { result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); } else { result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err); } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(exc_type); #endif return result; } #endif /* PyErrFetchRestore */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject *tmp_value; assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value))); if (value) { #if CYTHON_COMPILING_IN_CPYTHON if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb)) #endif PyException_SetTraceback(value, tb); } tmp_value = tstate->current_exception; tstate->current_exception = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; tmp_value = tstate->curexc_value; tmp_tb = tstate->curexc_traceback; tstate->curexc_type = type; tstate->curexc_value = value; tstate->curexc_traceback = tb; Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyObject* exc_value; exc_value = tstate->current_exception; tstate->current_exception = 0; *value = exc_value; *type = NULL; *tb = NULL; if (exc_value) { *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); #if CYTHON_COMPILING_IN_CPYTHON *tb = ((PyBaseExceptionObject*) exc_value)->traceback; Py_XINCREF(*tb); #else *tb = PyException_GetTraceback(exc_value); #endif } #else *type = tstate->curexc_type; *value = tstate->curexc_value; *tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif } #endif /* PyObjectGetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); } #endif /* PyObjectGetAttrStrNoError */ #if __PYX_LIMITED_VERSION_HEX < 0x030d00A1 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) __Pyx_PyErr_Clear(); } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { PyObject *result; #if __PYX_LIMITED_VERSION_HEX >= 0x030d00A1 (void) PyObject_GetOptionalAttr(obj, attr_name, &result); return result; #else #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); } #endif result = __Pyx_PyObject_GetAttrStr(obj, attr_name); if (unlikely(!result)) { __Pyx_PyObject_GetAttrStr_ClearAttributeError(); } return result; #endif } /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_b, name); if (unlikely(!result) && !PyErr_Occurred()) { PyErr_Format(PyExc_NameError, #if PY_MAJOR_VERSION >= 3 "name '%U' is not defined", name); #else "name '%.200s' is not defined", PyString_AS_STRING(name)); #endif } return result; } /* TupleAndListFromArray */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) { PyObject *v; Py_ssize_t i; for (i = 0; i < length; i++) { v = dest[i] = src[i]; Py_INCREF(v); } } static CYTHON_INLINE PyObject * __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { Py_INCREF(__pyx_empty_tuple); return __pyx_empty_tuple; } res = PyTuple_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n); return res; } static CYTHON_INLINE PyObject * __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n) { PyObject *res; if (n <= 0) { return PyList_New(0); } res = PyList_New(n); if (unlikely(res == NULL)) return NULL; __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n); return res; } #endif /* BytesEquals */ static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API return PyObject_RichCompareBool(s1, s2, equals); #else if (s1 == s2) { return (equals == Py_EQ); } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { const char *ps1, *ps2; Py_ssize_t length = PyBytes_GET_SIZE(s1); if (length != PyBytes_GET_SIZE(s2)) return (equals == Py_NE); ps1 = PyBytes_AS_STRING(s1); ps2 = PyBytes_AS_STRING(s2); if (ps1[0] != ps2[0]) { return (equals == Py_NE); } else if (length == 1) { return (equals == Py_EQ); } else { int result; #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) Py_hash_t hash1, hash2; hash1 = ((PyBytesObject*)s1)->ob_shash; hash2 = ((PyBytesObject*)s2)->ob_shash; if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { return (equals == Py_NE); } #endif result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { return (equals == Py_NE); } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { return (equals == Py_NE); } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } #endif } /* UnicodeEquals */ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API return PyObject_RichCompareBool(s1, s2, equals); #else #if PY_MAJOR_VERSION < 3 PyObject* owned_ref = NULL; #endif int s1_is_unicode, s2_is_unicode; if (s1 == s2) { goto return_eq; } s1_is_unicode = PyUnicode_CheckExact(s1); s2_is_unicode = PyUnicode_CheckExact(s2); #if PY_MAJOR_VERSION < 3 if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { owned_ref = PyUnicode_FromObject(s2); if (unlikely(!owned_ref)) return -1; s2 = owned_ref; s2_is_unicode = 1; } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { owned_ref = PyUnicode_FromObject(s1); if (unlikely(!owned_ref)) return -1; s1 = owned_ref; s1_is_unicode = 1; } else if (((!s2_is_unicode) & (!s1_is_unicode))) { return __Pyx_PyBytes_Equals(s1, s2, equals); } #endif if (s1_is_unicode & s2_is_unicode) { Py_ssize_t length; int kind; void *data1, *data2; if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) return -1; length = __Pyx_PyUnicode_GET_LENGTH(s1); if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { goto return_ne; } #if CYTHON_USE_UNICODE_INTERNALS { Py_hash_t hash1, hash2; #if CYTHON_PEP393_ENABLED hash1 = ((PyASCIIObject*)s1)->hash; hash2 = ((PyASCIIObject*)s2)->hash; #else hash1 = ((PyUnicodeObject*)s1)->hash; hash2 = ((PyUnicodeObject*)s2)->hash; #endif if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { goto return_ne; } } #endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; } data1 = __Pyx_PyUnicode_DATA(s1); data2 = __Pyx_PyUnicode_DATA(s2); if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { goto return_ne; } else if (length == 1) { goto return_eq; } else { int result = memcmp(data1, data2, (size_t)(length * kind)); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & s2_is_unicode) { goto return_ne; } else if ((s2 == Py_None) & s1_is_unicode) { goto return_ne; } else { int result; PyObject* py_result = PyObject_RichCompare(s1, s2, equals); #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif if (!py_result) return -1; result = __Pyx_PyObject_IsTrue(py_result); Py_DECREF(py_result); return result; } return_eq: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_EQ); return_ne: #if PY_MAJOR_VERSION < 3 Py_XDECREF(owned_ref); #endif return (equals == Py_NE); #endif } /* fastcall */ #if CYTHON_METH_FASTCALL static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s) { Py_ssize_t i, n = PyTuple_GET_SIZE(kwnames); for (i = 0; i < n; i++) { if (s == PyTuple_GET_ITEM(kwnames, i)) return kwvalues[i]; } for (i = 0; i < n; i++) { int eq = __Pyx_PyUnicode_Equals(s, PyTuple_GET_ITEM(kwnames, i), Py_EQ); if (unlikely(eq != 0)) { if (unlikely(eq < 0)) return NULL; return kwvalues[i]; } } return NULL; } #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) { Py_ssize_t i, nkwargs = PyTuple_GET_SIZE(kwnames); PyObject *dict; dict = PyDict_New(); if (unlikely(!dict)) return NULL; for (i=0; i= 3 "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, PyString_AsString(kw_name)); #endif } /* ParseKeywords */ static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject *const *kwvalues, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name) { PyObject *key = 0, *value = 0; Py_ssize_t pos = 0; PyObject*** name; PyObject*** first_kw_arg = argnames + num_pos_args; int kwds_is_tuple = CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds)); while (1) { Py_XDECREF(key); key = NULL; Py_XDECREF(value); value = NULL; if (kwds_is_tuple) { Py_ssize_t size; #if CYTHON_ASSUME_SAFE_MACROS size = PyTuple_GET_SIZE(kwds); #else size = PyTuple_Size(kwds); if (size < 0) goto bad; #endif if (pos >= size) break; #if CYTHON_AVOID_BORROWED_REFS key = __Pyx_PySequence_ITEM(kwds, pos); if (!key) goto bad; #elif CYTHON_ASSUME_SAFE_MACROS key = PyTuple_GET_ITEM(kwds, pos); #else key = PyTuple_GetItem(kwds, pos); if (!key) goto bad; #endif value = kwvalues[pos]; pos++; } else { if (!PyDict_Next(kwds, &pos, &key, &value)) break; #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(key); #endif } name = first_kw_arg; while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; #if CYTHON_AVOID_BORROWED_REFS Py_INCREF(value); Py_DECREF(key); #endif key = NULL; value = NULL; continue; } #if !CYTHON_AVOID_BORROWED_REFS Py_INCREF(key); #endif Py_INCREF(value); name = first_kw_arg; #if PY_MAJOR_VERSION < 3 if (likely(PyString_Check(key))) { while (*name) { if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) && _PyString_Eq(**name, key)) { values[name-argnames] = value; #if CYTHON_AVOID_BORROWED_REFS value = NULL; #endif break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { if ((**argname == key) || ( (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) && _PyString_Eq(**argname, key))) { goto arg_passed_twice; } argname++; } } } else #endif if (likely(PyUnicode_Check(key))) { while (*name) { int cmp = ( #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif PyUnicode_Compare(**name, key) ); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) { values[name-argnames] = value; #if CYTHON_AVOID_BORROWED_REFS value = NULL; #endif break; } name++; } if (*name) continue; else { PyObject*** argname = argnames; while (argname != first_kw_arg) { int cmp = (**argname == key) ? 0 : #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : #endif PyUnicode_Compare(**argname, key); if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; if (cmp == 0) goto arg_passed_twice; argname++; } } } else goto invalid_keyword_type; if (kwds2) { if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; } else { goto invalid_keyword; } } Py_XDECREF(key); Py_XDECREF(value); return 0; arg_passed_twice: __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, "%.200s() keywords must be strings", function_name); goto bad; invalid_keyword: #if PY_MAJOR_VERSION < 3 PyErr_Format(PyExc_TypeError, "%.200s() got an unexpected keyword argument '%.200s'", function_name, PyString_AsString(key)); #else PyErr_Format(PyExc_TypeError, "%s() got an unexpected keyword argument '%U'", function_name, key); #endif bad: Py_XDECREF(key); Py_XDECREF(value); return -1; } /* RaiseArgTupleInvalid */ static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found) { Py_ssize_t num_expected; const char *more_or_less; if (num_found < num_min) { num_expected = num_min; more_or_less = "at least"; } else { num_expected = num_max; more_or_less = "at most"; } if (exact) { more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } /* ArgTypeTest */ static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { __Pyx_TypeName type_name; __Pyx_TypeName obj_type_name; if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } else if (exact) { #if PY_MAJOR_VERSION == 2 if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { if (likely(__Pyx_TypeCheck(obj, type))) return 1; } type_name = __Pyx_PyType_GetName(type); obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME ", got " __Pyx_FMT_TYPENAME ")", name, type_name, obj_type_name); __Pyx_DECREF_TypeName(type_name); __Pyx_DECREF_TypeName(obj_type_name); return 0; } /* RaiseTooManyValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } /* RaiseNeedMoreValuesToUnpack */ static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", index, (index == 1) ? "" : "s"); } /* IterFinish */ static CYTHON_INLINE int __Pyx_IterFinish(void) { PyObject* exc_type; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign exc_type = __Pyx_PyErr_CurrentExceptionType(); if (unlikely(exc_type)) { if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) return -1; __Pyx_PyErr_Clear(); return 0; } return 0; } /* UnpackItemEndCheck */ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { if (unlikely(retval)) { Py_DECREF(retval); __Pyx_RaiseTooManyValuesError(expected); return -1; } return __Pyx_IterFinish(); } /* PyObjectSetAttrStr */ #if CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_setattro)) return tp->tp_setattro(obj, attr_name, value); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_setattr)) return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); #endif return PyObject_SetAttr(obj, attr_name, value); } #endif /* PyDictVersioning */ #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { PyObject *dict = Py_TYPE(obj)->tp_dict; return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; } static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { PyObject **dictptr = NULL; Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; if (offset) { #if CYTHON_COMPILING_IN_CPYTHON dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); #else dictptr = _PyObject_GetDictPtr(obj); #endif } return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; } static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { PyObject *dict = Py_TYPE(obj)->tp_dict; if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) return 0; return obj_dict_version == __Pyx_get_object_dict_version(obj); } #endif /* GetModuleGlobalName */ #if CYTHON_USE_DICT_VERSIONS static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) #else static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) #endif { PyObject *result; #if !CYTHON_AVOID_BORROWED_REFS #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && PY_VERSION_HEX < 0x030d0000 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } else if (unlikely(PyErr_Occurred())) { return NULL; } #elif CYTHON_COMPILING_IN_LIMITED_API if (unlikely(!__pyx_m)) { return NULL; } result = PyObject_GetAttr(__pyx_m, name); if (likely(result)) { return result; } #else result = PyDict_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } #endif #else result = PyObject_GetItem(__pyx_d, name); __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) if (likely(result)) { return __Pyx_NewRef(result); } PyErr_Clear(); #endif return __Pyx_GetBuiltinName(name); } /* PyObjectCall */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = Py_TYPE(func)->tp_call; if (unlikely(!call)) return PyObject_Call(func, arg, kw); #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; #endif result = (*call)(func, arg, kw); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* RaiseException */ #if PY_MAJOR_VERSION < 3 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { __Pyx_PyThreadState_declare CYTHON_UNUSED_VAR(cause); Py_XINCREF(type); if (!value || value == Py_None) value = NULL; else Py_INCREF(value); if (!tb || tb == Py_None) tb = NULL; else { Py_INCREF(tb); if (!PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto raise_error; } } if (PyType_Check(type)) { #if CYTHON_COMPILING_IN_PYPY if (!value) { Py_INCREF(Py_None); value = Py_None; } #endif PyErr_NormalizeException(&type, &value, &tb); } else { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } value = type; type = (PyObject*) Py_TYPE(type); Py_INCREF(type); if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto raise_error; } } __Pyx_PyThreadState_assign __Pyx_ErrRestore(type, value, tb); return; raise_error: Py_XDECREF(value); Py_XDECREF(type); Py_XDECREF(tb); return; } #else static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { PyErr_SetString(PyExc_TypeError, "raise: arg 3 must be a traceback or None"); goto bad; } if (value == Py_None) value = 0; if (PyExceptionInstance_Check(type)) { if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto bad; } value = type; type = (PyObject*) Py_TYPE(value); } else if (PyExceptionClass_Check(type)) { PyObject *instance_class = NULL; if (value && PyExceptionInstance_Check(value)) { instance_class = (PyObject*) Py_TYPE(value); if (instance_class != type) { int is_subclass = PyObject_IsSubclass(instance_class, type); if (!is_subclass) { instance_class = NULL; } else if (unlikely(is_subclass == -1)) { goto bad; } else { type = instance_class; } } } if (!instance_class) { PyObject *args; if (!value) args = PyTuple_New(0); else if (PyTuple_Check(value)) { Py_INCREF(value); args = value; } else args = PyTuple_Pack(1, value); if (!args) goto bad; owned_instance = PyObject_Call(type, args, NULL); Py_DECREF(args); if (!owned_instance) goto bad; value = owned_instance; if (!PyExceptionInstance_Check(value)) { PyErr_Format(PyExc_TypeError, "calling %R should have returned an instance of " "BaseException, not %R", type, Py_TYPE(value)); goto bad; } } } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } if (cause) { PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; } else if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); if (fixed_cause == NULL) goto bad; } else if (PyExceptionInstance_Check(cause)) { fixed_cause = cause; Py_INCREF(fixed_cause); } else { PyErr_SetString(PyExc_TypeError, "exception causes must derive from " "BaseException"); goto bad; } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); if (tb) { #if PY_VERSION_HEX >= 0x030C00A6 PyException_SetTraceback(value, tb); #elif CYTHON_FAST_THREAD_STATE PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } #else PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); Py_INCREF(tb); PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #endif } bad: Py_XDECREF(owned_instance); return; } #endif /* UnpackUnboundCMethod */ static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) { PyObject *result; PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args)); if (unlikely(!selfless_args)) return NULL; result = PyObject_Call(method, selfless_args, kwargs); Py_DECREF(selfless_args); return result; } static PyMethodDef __Pyx_UnboundCMethod_Def = { "CythonUnboundCMethod", __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall), METH_VARARGS | METH_KEYWORDS, NULL }; static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) { PyObject *method; method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name); if (unlikely(!method)) return -1; target->method = method; #if CYTHON_COMPILING_IN_CPYTHON #if PY_MAJOR_VERSION >= 3 if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type))) #else if (likely(!__Pyx_CyOrPyCFunction_Check(method))) #endif { PyMethodDescrObject *descr = (PyMethodDescrObject*) method; target->func = descr->d_method->ml_meth; target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS); } else #endif #if CYTHON_COMPILING_IN_PYPY #else if (PyCFunction_Check(method)) #endif { PyObject *self; int self_found; #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY self = PyObject_GetAttrString(method, "__self__"); if (!self) { PyErr_Clear(); } #else self = PyCFunction_GET_SELF(method); #endif self_found = (self && self != Py_None); #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY Py_XDECREF(self); #endif if (self_found) { PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method); if (unlikely(!unbound_method)) return -1; Py_DECREF(method); target->method = unbound_method; } } return 0; } /* CallUnboundCMethod2 */ #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030600B1 static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) { if (likely(cfunc->func)) { PyObject *args[2] = {arg1, arg2}; if (cfunc->flag == METH_FASTCALL) { #if PY_VERSION_HEX >= 0x030700A0 return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, args, 2); #else return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL); #endif } #if PY_VERSION_HEX >= 0x030700A0 if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS)) return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, 2, NULL); #endif } return __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2); } #endif static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){ PyObject *args, *result = NULL; if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { args = PyTuple_New(2); if (unlikely(!args)) goto bad; Py_INCREF(arg1); PyTuple_SET_ITEM(args, 0, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 1, arg2); if (cfunc->flag & METH_KEYWORDS) result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL); else result = (*cfunc->func)(self, args); } else { args = PyTuple_New(3); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg1); PyTuple_SET_ITEM(args, 1, arg1); Py_INCREF(arg2); PyTuple_SET_ITEM(args, 2, arg2); result = __Pyx_PyObject_Call(cfunc->method, args, NULL); } #else args = PyTuple_Pack(3, self, arg1, arg2); if (unlikely(!args)) goto bad; result = __Pyx_PyObject_Call(cfunc->method, args, NULL); #endif bad: Py_XDECREF(args); return result; } /* CallUnboundCMethod1 */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) { if (likely(cfunc->func)) { int flag = cfunc->flag; if (flag == METH_O) { return (*(cfunc->func))(self, arg); } else if ((PY_VERSION_HEX >= 0x030600B1) && flag == METH_FASTCALL) { #if PY_VERSION_HEX >= 0x030700A0 return (*(__Pyx_PyCFunctionFast)(void*)(PyCFunction)cfunc->func)(self, &arg, 1); #else return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); #endif } else if ((PY_VERSION_HEX >= 0x030700A0) && flag == (METH_FASTCALL | METH_KEYWORDS)) { return (*(__Pyx_PyCFunctionFastWithKeywords)(void*)(PyCFunction)cfunc->func)(self, &arg, 1, NULL); } } return __Pyx__CallUnboundCMethod1(cfunc, self, arg); } #endif static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){ PyObject *args, *result = NULL; if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_COMPILING_IN_CPYTHON if (cfunc->func && (cfunc->flag & METH_VARARGS)) { args = PyTuple_New(1); if (unlikely(!args)) goto bad; Py_INCREF(arg); PyTuple_SET_ITEM(args, 0, arg); if (cfunc->flag & METH_KEYWORDS) result = (*(PyCFunctionWithKeywords)(void*)(PyCFunction)cfunc->func)(self, args, NULL); else result = (*cfunc->func)(self, args); } else { args = PyTuple_New(2); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); Py_INCREF(arg); PyTuple_SET_ITEM(args, 1, arg); result = __Pyx_PyObject_Call(cfunc->method, args, NULL); } #else args = PyTuple_Pack(2, self, arg); if (unlikely(!args)) goto bad; result = __Pyx_PyObject_Call(cfunc->method, args, NULL); #endif bad: Py_XDECREF(args); return result; } /* py_dict_pop */ static CYTHON_INLINE PyObject *__Pyx_PyDict_Pop(PyObject *d, PyObject *key, PyObject *default_value) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030600B3 & PY_VERSION_HEX < 0x030d0000 if ((1)) { return _PyDict_Pop(d, key, default_value); } else #endif if (default_value) { return __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_pop, d, key, default_value); } else { return __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_pop, d, key); } } /* PyFunctionFastCall */ #if CYTHON_FAST_PYCALL && !CYTHON_VECTORCALL static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, PyObject *globals) { PyFrameObject *f; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject **fastlocals; Py_ssize_t i; PyObject *result; assert(globals != NULL); /* XXX Perhaps we should create a specialized PyFrame_New() that doesn't take locals, but does take builtins without sanity checking them. */ assert(tstate != NULL); f = PyFrame_New(tstate, co, globals, NULL); if (f == NULL) { return NULL; } fastlocals = __Pyx_PyFrame_GetLocalsplus(f); for (i = 0; i < na; i++) { Py_INCREF(*args); fastlocals[i] = *args++; } result = PyEval_EvalFrameEx(f,0); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; return result; } static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); PyObject *closure; #if PY_MAJOR_VERSION >= 3 PyObject *kwdefs; #endif PyObject *kwtuple, **k; PyObject **d; Py_ssize_t nd; Py_ssize_t nk; PyObject *result; assert(kwargs == NULL || PyDict_Check(kwargs)); nk = kwargs ? PyDict_Size(kwargs) : 0; #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) { return NULL; } #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) { return NULL; } #endif if ( #if PY_MAJOR_VERSION >= 3 co->co_kwonlyargcount == 0 && #endif likely(kwargs == NULL || nk == 0) && co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { if (argdefs == NULL && co->co_argcount == nargs) { result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); goto done; } else if (nargs == 0 && argdefs != NULL && co->co_argcount == Py_SIZE(argdefs)) { /* function called with no arguments, but all parameters have a default value: use default values as arguments .*/ args = &PyTuple_GET_ITEM(argdefs, 0); result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); goto done; } } if (kwargs != NULL) { Py_ssize_t pos, i; kwtuple = PyTuple_New(2 * nk); if (kwtuple == NULL) { result = NULL; goto done; } k = &PyTuple_GET_ITEM(kwtuple, 0); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { Py_INCREF(k[i]); Py_INCREF(k[i+1]); i += 2; } nk = i / 2; } else { kwtuple = NULL; k = NULL; } closure = PyFunction_GET_CLOSURE(func); #if PY_MAJOR_VERSION >= 3 kwdefs = PyFunction_GET_KW_DEFAULTS(func); #endif if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); nd = Py_SIZE(argdefs); } else { d = NULL; nd = 0; } #if PY_MAJOR_VERSION >= 3 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, kwdefs, closure); #else result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, args, (int)nargs, k, (int)nk, d, (int)nd, closure); #endif Py_XDECREF(kwtuple); done: Py_LeaveRecursiveCall(); return result; } #endif /* PyObjectCallMethO */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func); self = __Pyx_CyOrPyCFunction_GET_SELF(func); #if PY_MAJOR_VERSION < 3 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) return NULL; #else if (unlikely(Py_EnterRecursiveCall(" while calling a Python object"))) return NULL; #endif result = cfunc(self, arg); Py_LeaveRecursiveCall(); if (unlikely(!result) && unlikely(!PyErr_Occurred())) { PyErr_SetString( PyExc_SystemError, "NULL result without error in PyObject_Call"); } return result; } #endif /* PyObjectFastCall */ #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject **args, size_t nargs, PyObject *kwargs) { PyObject *argstuple; PyObject *result = 0; size_t i; argstuple = PyTuple_New((Py_ssize_t)nargs); if (unlikely(!argstuple)) return NULL; for (i = 0; i < nargs; i++) { Py_INCREF(args[i]); if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) < 0) goto bad; } result = __Pyx_PyObject_Call(func, argstuple, kwargs); bad: Py_DECREF(argstuple); return result; } #endif static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t _nargs, PyObject *kwargs) { Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs); #if CYTHON_COMPILING_IN_CPYTHON if (nargs == 0 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS)) return __Pyx_PyObject_CallMethO(func, NULL); } else if (nargs == 1 && kwargs == NULL) { if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O)) return __Pyx_PyObject_CallMethO(func, args[0]); } #endif #if PY_VERSION_HEX < 0x030800B1 #if CYTHON_FAST_PYCCALL if (PyCFunction_Check(func)) { if (kwargs) { return _PyCFunction_FastCallDict(func, args, nargs, kwargs); } else { return _PyCFunction_FastCallKeywords(func, args, nargs, NULL); } } #if PY_VERSION_HEX >= 0x030700A1 if (!kwargs && __Pyx_IS_TYPE(func, &PyMethodDescr_Type)) { return _PyMethodDescr_FastCallKeywords(func, args, nargs, NULL); } #endif #endif #if CYTHON_FAST_PYCALL if (PyFunction_Check(func)) { return __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs); } #endif #endif if (kwargs == NULL) { #if CYTHON_VECTORCALL #if PY_VERSION_HEX < 0x03090000 vectorcallfunc f = _PyVectorcall_Function(func); #else vectorcallfunc f = PyVectorcall_Function(func); #endif if (f) { return f(func, args, (size_t)nargs, NULL); } #elif defined(__Pyx_CyFunction_USED) && CYTHON_BACKPORT_VECTORCALL if (__Pyx_CyFunction_CheckExact(func)) { __pyx_vectorcallfunc f = __Pyx_CyFunction_func_vectorcall(func); if (f) return f(func, args, (size_t)nargs, NULL); } #endif } if (nargs == 0) { return __Pyx_PyObject_Call(func, __pyx_empty_tuple, kwargs); } #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs); #else return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs); #endif } /* PyObjectCallNoArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { PyObject *arg[2] = {NULL, NULL}; return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectCallOneArg */ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *args[2] = {NULL, arg}; return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } /* PyObjectGetMethod */ static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) { PyObject *attr; #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP __Pyx_TypeName type_name; PyTypeObject *tp = Py_TYPE(obj); PyObject *descr; descrgetfunc f = NULL; PyObject **dictptr, *dict; int meth_found = 0; assert (*method == NULL); if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) { attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; } if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) { return 0; } descr = _PyType_Lookup(tp, name); if (likely(descr != NULL)) { Py_INCREF(descr); #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR)) #elif PY_MAJOR_VERSION >= 3 #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type))) #endif #else #ifdef __Pyx_CyFunction_USED if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr))) #else if (likely(PyFunction_Check(descr))) #endif #endif { meth_found = 1; } else { f = Py_TYPE(descr)->tp_descr_get; if (f != NULL && PyDescr_IsData(descr)) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } } } dictptr = _PyObject_GetDictPtr(obj); if (dictptr != NULL && (dict = *dictptr) != NULL) { Py_INCREF(dict); attr = __Pyx_PyDict_GetItemStr(dict, name); if (attr != NULL) { Py_INCREF(attr); Py_DECREF(dict); Py_XDECREF(descr); goto try_unpack; } Py_DECREF(dict); } if (meth_found) { *method = descr; return 1; } if (f != NULL) { attr = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto try_unpack; } if (likely(descr != NULL)) { *method = descr; return 0; } type_name = __Pyx_PyType_GetName(tp); PyErr_Format(PyExc_AttributeError, #if PY_MAJOR_VERSION >= 3 "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", type_name, name); #else "'" __Pyx_FMT_TYPENAME "' object has no attribute '%.400s'", type_name, PyString_AS_STRING(name)); #endif __Pyx_DECREF_TypeName(type_name); return 0; #else attr = __Pyx_PyObject_GetAttrStr(obj, name); goto try_unpack; #endif try_unpack: #if CYTHON_UNPACK_METHODS if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) { PyObject *function = PyMethod_GET_FUNCTION(attr); Py_INCREF(function); Py_DECREF(attr); *method = function; return 1; } #endif *method = attr; return 0; } /* PyObjectCallMethod0 */ static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) { PyObject *method = NULL, *result = NULL; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_CallOneArg(method, obj); Py_DECREF(method); return result; } if (unlikely(!method)) goto bad; result = __Pyx_PyObject_CallNoArg(method); Py_DECREF(method); bad: return result; } /* RaiseNoneIterError */ static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); } /* UnpackTupleError */ static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) { if (t == Py_None) { __Pyx_RaiseNoneNotIterableError(); } else if (PyTuple_GET_SIZE(t) < index) { __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t)); } else { __Pyx_RaiseTooManyValuesError(index); } } /* UnpackTuple2 */ static CYTHON_INLINE int __Pyx_unpack_tuple2_exact( PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) { PyObject *value1 = NULL, *value2 = NULL; #if CYTHON_COMPILING_IN_PYPY value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad; value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad; #else value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1); value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2); #endif if (decref_tuple) { Py_DECREF(tuple); } *pvalue1 = value1; *pvalue2 = value2; return 0; #if CYTHON_COMPILING_IN_PYPY bad: Py_XDECREF(value1); Py_XDECREF(value2); if (decref_tuple) { Py_XDECREF(tuple); } return -1; #endif } static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int has_known_size, int decref_tuple) { Py_ssize_t index; PyObject *value1 = NULL, *value2 = NULL, *iter = NULL; iternextfunc iternext; iter = PyObject_GetIter(tuple); if (unlikely(!iter)) goto bad; if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; } iternext = __Pyx_PyObject_GetIterNextFunc(iter); value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; } value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; } if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad; Py_DECREF(iter); *pvalue1 = value1; *pvalue2 = value2; return 0; unpacking_failed: if (!has_known_size && __Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); bad: Py_XDECREF(iter); Py_XDECREF(value1); Py_XDECREF(value2); if (decref_tuple) { Py_XDECREF(tuple); } return -1; } /* dict_iter */ #if CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 #include #endif static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name, Py_ssize_t* p_orig_length, int* p_source_is_dict) { is_dict = is_dict || likely(PyDict_CheckExact(iterable)); *p_source_is_dict = is_dict; if (is_dict) { #if !CYTHON_COMPILING_IN_PYPY *p_orig_length = PyDict_Size(iterable); Py_INCREF(iterable); return iterable; #elif PY_MAJOR_VERSION >= 3 static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL; PyObject **pp = NULL; if (method_name) { const char *name = PyUnicode_AsUTF8(method_name); if (strcmp(name, "iteritems") == 0) pp = &py_items; else if (strcmp(name, "iterkeys") == 0) pp = &py_keys; else if (strcmp(name, "itervalues") == 0) pp = &py_values; if (pp) { if (!*pp) { *pp = PyUnicode_FromString(name + 4); if (!*pp) return NULL; } method_name = *pp; } } #endif } *p_orig_length = 0; if (method_name) { PyObject* iter; iterable = __Pyx_PyObject_CallMethod0(iterable, method_name); if (!iterable) return NULL; #if !CYTHON_COMPILING_IN_PYPY if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable)) return iterable; #endif iter = PyObject_GetIter(iterable); Py_DECREF(iterable); return iter; } return PyObject_GetIter(iterable); } static CYTHON_INLINE int __Pyx_dict_iter_next( PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos, PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) { PyObject* next_item; #if !CYTHON_COMPILING_IN_PYPY if (source_is_dict) { PyObject *key, *value; if (unlikely(orig_length != PyDict_Size(iter_obj))) { PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration"); return -1; } if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) { return 0; } if (pitem) { PyObject* tuple = PyTuple_New(2); if (unlikely(!tuple)) { return -1; } Py_INCREF(key); Py_INCREF(value); PyTuple_SET_ITEM(tuple, 0, key); PyTuple_SET_ITEM(tuple, 1, value); *pitem = tuple; } else { if (pkey) { Py_INCREF(key); *pkey = key; } if (pvalue) { Py_INCREF(value); *pvalue = value; } } return 1; } else if (PyTuple_CheckExact(iter_obj)) { Py_ssize_t pos = *ppos; if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0; *ppos = pos + 1; next_item = PyTuple_GET_ITEM(iter_obj, pos); Py_INCREF(next_item); } else if (PyList_CheckExact(iter_obj)) { Py_ssize_t pos = *ppos; if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0; *ppos = pos + 1; next_item = PyList_GET_ITEM(iter_obj, pos); Py_INCREF(next_item); } else #endif { next_item = PyIter_Next(iter_obj); if (unlikely(!next_item)) { return __Pyx_IterFinish(); } } if (pitem) { *pitem = next_item; } else if (pkey && pvalue) { if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1)) return -1; } else if (pkey) { *pkey = next_item; } else { *pvalue = next_item; } return 1; } /* MergeKeywords */ static int __Pyx_MergeKeywords(PyObject *kwdict, PyObject *source_mapping) { PyObject *iter, *key = NULL, *value = NULL; int source_is_dict, result; Py_ssize_t orig_length, ppos = 0; iter = __Pyx_dict_iterator(source_mapping, 0, __pyx_n_s_items, &orig_length, &source_is_dict); if (unlikely(!iter)) { PyObject *args; if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError))) goto bad; PyErr_Clear(); args = PyTuple_Pack(1, source_mapping); if (likely(args)) { PyObject *fallback = PyObject_Call((PyObject*)&PyDict_Type, args, NULL); Py_DECREF(args); if (likely(fallback)) { iter = __Pyx_dict_iterator(fallback, 1, __pyx_n_s_items, &orig_length, &source_is_dict); Py_DECREF(fallback); } } if (unlikely(!iter)) goto bad; } while (1) { result = __Pyx_dict_iter_next(iter, orig_length, &ppos, &key, &value, NULL, source_is_dict); if (unlikely(result < 0)) goto bad; if (!result) break; if (unlikely(PyDict_Contains(kwdict, key))) { __Pyx_RaiseDoubleKeywordsError("function", key); result = -1; } else { result = PyDict_SetItem(kwdict, key, value); } Py_DECREF(key); Py_DECREF(value); if (unlikely(result < 0)) goto bad; } Py_XDECREF(iter); return 0; bad: Py_XDECREF(iter); return -1; } /* pybytes_as_double */ static double __Pyx_SlowPyString_AsDouble(PyObject *obj) { PyObject *float_value; #if PY_MAJOR_VERSION >= 3 float_value = PyFloat_FromString(obj); #else float_value = PyFloat_FromString(obj, 0); #endif if (likely(float_value)) { #if CYTHON_ASSUME_SAFE_MACROS double value = PyFloat_AS_DOUBLE(float_value); #else double value = PyFloat_AsDouble(float_value); #endif Py_DECREF(float_value); return value; } return (double)-1; } static const char* __Pyx__PyBytes_AsDouble_Copy(const char* start, char* buffer, Py_ssize_t length) { int last_was_punctuation = 1; Py_ssize_t i; for (i=0; i < length; i++) { char chr = start[i]; int is_punctuation = (chr == '_') | (chr == '.') | (chr == 'e') | (chr == 'E'); *buffer = chr; buffer += (chr != '_'); if (unlikely(last_was_punctuation & is_punctuation)) goto parse_failure; last_was_punctuation = is_punctuation; } if (unlikely(last_was_punctuation)) goto parse_failure; *buffer = '\0'; return buffer; parse_failure: return NULL; } static double __Pyx__PyBytes_AsDouble_inf_nan(const char* start, Py_ssize_t length) { int matches = 1; char sign = start[0]; int is_signed = (sign == '+') | (sign == '-'); start += is_signed; length -= is_signed; switch (start[0]) { #ifdef Py_NAN case 'n': case 'N': if (unlikely(length != 3)) goto parse_failure; matches &= (start[1] == 'a' || start[1] == 'A'); matches &= (start[2] == 'n' || start[2] == 'N'); if (unlikely(!matches)) goto parse_failure; return (sign == '-') ? -Py_NAN : Py_NAN; #endif case 'i': case 'I': if (unlikely(length < 3)) goto parse_failure; matches &= (start[1] == 'n' || start[1] == 'N'); matches &= (start[2] == 'f' || start[2] == 'F'); if (likely(length == 3 && matches)) return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL; if (unlikely(length != 8)) goto parse_failure; matches &= (start[3] == 'i' || start[3] == 'I'); matches &= (start[4] == 'n' || start[4] == 'N'); matches &= (start[5] == 'i' || start[5] == 'I'); matches &= (start[6] == 't' || start[6] == 'T'); matches &= (start[7] == 'y' || start[7] == 'Y'); if (unlikely(!matches)) goto parse_failure; return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL; case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': break; default: goto parse_failure; } return 0.0; parse_failure: return -1.0; } static CYTHON_INLINE int __Pyx__PyBytes_AsDouble_IsSpace(char ch) { return (ch == 0x20) | !((ch < 0x9) | (ch > 0xd)); } CYTHON_UNUSED static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) { double value; Py_ssize_t i, digits; const char *last = start + length; char *end; while (__Pyx__PyBytes_AsDouble_IsSpace(*start)) start++; while (start < last - 1 && __Pyx__PyBytes_AsDouble_IsSpace(last[-1])) last--; length = last - start; if (unlikely(length <= 0)) goto fallback; value = __Pyx__PyBytes_AsDouble_inf_nan(start, length); if (unlikely(value == -1.0)) goto fallback; if (value != 0.0) return value; digits = 0; for (i=0; i < length; digits += start[i++] != '_'); if (likely(digits == length)) { value = PyOS_string_to_double(start, &end, NULL); } else if (digits < 40) { char number[40]; last = __Pyx__PyBytes_AsDouble_Copy(start, number, length); if (unlikely(!last)) goto fallback; value = PyOS_string_to_double(number, &end, NULL); } else { char *number = (char*) PyMem_Malloc((digits + 1) * sizeof(char)); if (unlikely(!number)) goto fallback; last = __Pyx__PyBytes_AsDouble_Copy(start, number, length); if (unlikely(!last)) { PyMem_Free(number); goto fallback; } value = PyOS_string_to_double(number, &end, NULL); PyMem_Free(number); } if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) { return value; } fallback: return __Pyx_SlowPyString_AsDouble(obj); } /* PyIntCompare */ static CYTHON_INLINE int __Pyx_PyInt_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace) { CYTHON_MAYBE_UNUSED_VAR(intval); CYTHON_UNUSED_VAR(inplace); if (op1 == op2) { return 1; } #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long a = PyInt_AS_LONG(op1); return (a == b); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { int unequal; unsigned long uintval; Py_ssize_t size = __Pyx_PyLong_DigitCount(op1); const digit* digits = __Pyx_PyLong_Digits(op1); if (intval == 0) { return (__Pyx_PyLong_IsZero(op1) == 1); } else if (intval < 0) { if (__Pyx_PyLong_IsNonNeg(op1)) return 0; intval = -intval; } else { if (__Pyx_PyLong_IsNeg(op1)) return 0; } uintval = (unsigned long) intval; #if PyLong_SHIFT * 4 < SIZEOF_LONG*8 if (uintval >> (PyLong_SHIFT * 4)) { unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); } else #endif #if PyLong_SHIFT * 3 < SIZEOF_LONG*8 if (uintval >> (PyLong_SHIFT * 3)) { unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); } else #endif #if PyLong_SHIFT * 2 < SIZEOF_LONG*8 if (uintval >> (PyLong_SHIFT * 2)) { unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); } else #endif #if PyLong_SHIFT * 1 < SIZEOF_LONG*8 if (uintval >> (PyLong_SHIFT * 1)) { unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK)) | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)); } else #endif unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK)); return (unequal == 0); } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; #if CYTHON_COMPILING_IN_LIMITED_API double a = __pyx_PyFloat_AsDouble(op1); #else double a = PyFloat_AS_DOUBLE(op1); #endif return ((double)a == (double)b); } return __Pyx_PyObject_IsTrueAndDecref( PyObject_RichCompare(op1, op2, Py_EQ)); } /* PyIntBinop */ #if !CYTHON_COMPILING_IN_PYPY static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) { CYTHON_MAYBE_UNUSED_VAR(intval); CYTHON_MAYBE_UNUSED_VAR(inplace); CYTHON_UNUSED_VAR(zerodivision_check); #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(op1))) { const long b = intval; long x; long a = PyInt_AS_LONG(op1); x = (long)((unsigned long)a + (unsigned long)b); if (likely((x^a) >= 0 || (x^b) >= 0)) return PyInt_FromLong(x); return PyLong_Type.tp_as_number->nb_add(op1, op2); } #endif #if CYTHON_USE_PYLONG_INTERNALS if (likely(PyLong_CheckExact(op1))) { const long b = intval; long a, x; #ifdef HAVE_LONG_LONG const PY_LONG_LONG llb = intval; PY_LONG_LONG lla, llx; #endif if (unlikely(__Pyx_PyLong_IsZero(op1))) { return __Pyx_NewRef(op2); } if (likely(__Pyx_PyLong_IsCompact(op1))) { a = __Pyx_PyLong_CompactValue(op1); } else { const digit* digits = __Pyx_PyLong_Digits(op1); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(op1); switch (size) { case -2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; #ifdef HAVE_LONG_LONG } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; #endif } CYTHON_FALLTHROUGH; default: return PyLong_Type.tp_as_number->nb_add(op1, op2); } } x = a + b; return PyLong_FromLong(x); #ifdef HAVE_LONG_LONG long_long: llx = lla + llb; return PyLong_FromLongLong(llx); #endif } #endif if (PyFloat_CheckExact(op1)) { const long b = intval; #if CYTHON_COMPILING_IN_LIMITED_API double a = __pyx_PyFloat_AsDouble(op1); #else double a = PyFloat_AS_DOUBLE(op1); #endif double result; PyFPE_START_PROTECT("add", return NULL) result = ((double)a) + (double)b; PyFPE_END_PROTECT(result) return PyFloat_FromDouble(result); } return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); } #endif /* GetTopmostException */ #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate) { _PyErr_StackItem *exc_info = tstate->exc_info; while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) && exc_info->previous_item != NULL) { exc_info = exc_info->previous_item; } return exc_info; } #endif /* SaveResetException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); PyObject *exc_value = exc_info->exc_value; if (exc_value == NULL || exc_value == Py_None) { *value = NULL; *type = NULL; *tb = NULL; } else { *value = exc_value; Py_INCREF(*value); *type = (PyObject*) Py_TYPE(exc_value); Py_INCREF(*type); *tb = PyException_GetTraceback(exc_value); } #elif CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); *type = exc_info->exc_type; *value = exc_info->exc_value; *tb = exc_info->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #else *type = tstate->exc_type; *value = tstate->exc_value; *tb = tstate->exc_traceback; Py_XINCREF(*type); Py_XINCREF(*value); Py_XINCREF(*tb); #endif } static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = tstate->exc_info; PyObject *tmp_value = exc_info->exc_value; exc_info->exc_value = value; Py_XDECREF(tmp_value); Py_XDECREF(type); Py_XDECREF(tb); #else PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = type; exc_info->exc_value = value; exc_info->exc_traceback = tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = type; tstate->exc_value = value; tstate->exc_traceback = tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #endif } #endif /* GetException */ #if CYTHON_FAST_THREAD_STATE static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) #else static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) #endif { PyObject *local_type = NULL, *local_value, *local_tb = NULL; #if CYTHON_FAST_THREAD_STATE PyObject *tmp_type, *tmp_value, *tmp_tb; #if PY_VERSION_HEX >= 0x030C00A6 local_value = tstate->current_exception; tstate->current_exception = 0; if (likely(local_value)) { local_type = (PyObject*) Py_TYPE(local_value); Py_INCREF(local_type); local_tb = PyException_GetTraceback(local_value); } #else local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; #endif #else PyErr_Fetch(&local_type, &local_value, &local_tb); #endif PyErr_NormalizeException(&local_type, &local_value, &local_tb); #if CYTHON_FAST_THREAD_STATE && PY_VERSION_HEX >= 0x030C00A6 if (unlikely(tstate->current_exception)) #elif CYTHON_FAST_THREAD_STATE if (unlikely(tstate->curexc_type)) #else if (unlikely(PyErr_Occurred())) #endif goto bad; #if PY_MAJOR_VERSION >= 3 if (local_tb) { if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; } #endif Py_XINCREF(local_tb); Py_XINCREF(local_type); Py_XINCREF(local_value); *type = local_type; *value = local_value; *tb = local_tb; #if CYTHON_FAST_THREAD_STATE #if CYTHON_USE_EXC_INFO_STACK { _PyErr_StackItem *exc_info = tstate->exc_info; #if PY_VERSION_HEX >= 0x030B00a4 tmp_value = exc_info->exc_value; exc_info->exc_value = local_value; tmp_type = NULL; tmp_tb = NULL; Py_XDECREF(local_type); Py_XDECREF(local_tb); #else tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = local_type; exc_info->exc_value = local_value; exc_info->exc_traceback = local_tb; #endif } #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; #endif Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); #else PyErr_SetExcInfo(local_type, local_value, local_tb); #endif return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; } /* SwapException */ #if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4 _PyErr_StackItem *exc_info = tstate->exc_info; tmp_value = exc_info->exc_value; exc_info->exc_value = *value; if (tmp_value == NULL || tmp_value == Py_None) { Py_XDECREF(tmp_value); tmp_value = NULL; tmp_type = NULL; tmp_tb = NULL; } else { tmp_type = (PyObject*) Py_TYPE(tmp_value); Py_INCREF(tmp_type); #if CYTHON_COMPILING_IN_CPYTHON tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback; Py_XINCREF(tmp_tb); #else tmp_tb = PyException_GetTraceback(tmp_value); #endif } #elif CYTHON_USE_EXC_INFO_STACK _PyErr_StackItem *exc_info = tstate->exc_info; tmp_type = exc_info->exc_type; tmp_value = exc_info->exc_value; tmp_tb = exc_info->exc_traceback; exc_info->exc_type = *type; exc_info->exc_value = *value; exc_info->exc_traceback = *tb; #else tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = *type; tstate->exc_value = *value; tstate->exc_traceback = *tb; #endif *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #else static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); PyErr_SetExcInfo(*type, *value, *tb); *type = tmp_type; *value = tmp_value; *tb = tmp_tb; } #endif /* dict_getitem_default */ static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) { PyObject* value; #if PY_MAJOR_VERSION >= 3 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000) value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (unlikely(PyErr_Occurred())) return NULL; value = default_value; } Py_INCREF(value); if ((1)); #else if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) { value = PyDict_GetItem(d, key); if (unlikely(!value)) { value = default_value; } Py_INCREF(value); } #endif else { if (default_value == Py_None) value = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyDict_Type_get, d, key); else value = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyDict_Type_get, d, key, default_value); } return value; } /* GetItemInt */ static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (unlikely(!j)) return NULL; r = PyObject_GetItem(o, j); Py_DECREF(j); return r; } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyList_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS Py_ssize_t wrapped_i = i; if (wraparound & unlikely(i < 0)) { wrapped_i += PyTuple_GET_SIZE(o); } if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); #else return PySequence_GetItem(o, i); #endif } static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { PyObject *r = PyList_GET_ITEM(o, n); Py_INCREF(r); return r; } } else if (PyTuple_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { PyObject *r = PyTuple_GET_ITEM(o, n); Py_INCREF(r); return r; } } else { PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping; PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence; if (mm && mm->mp_subscript) { PyObject *r, *key = PyInt_FromSsize_t(i); if (unlikely(!key)) return NULL; r = mm->mp_subscript(o, key); Py_DECREF(key); return r; } if (likely(sm && sm->sq_item)) { if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) { Py_ssize_t l = sm->sq_length(o); if (likely(l >= 0)) { i += l; } else { if (!PyErr_ExceptionMatches(PyExc_OverflowError)) return NULL; PyErr_Clear(); } } return sm->sq_item(o, i); } } #else if (is_list || !PyMapping_Check(o)) { return PySequence_GetItem(o, i); } #endif return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); } /* ObjectGetItem */ #if CYTHON_USE_TYPE_SLOTS static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) { PyObject *runerr = NULL; Py_ssize_t key_value; key_value = __Pyx_PyIndex_AsSsize_t(index); if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); } if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { __Pyx_TypeName index_type_name = __Pyx_PyType_GetName(Py_TYPE(index)); PyErr_Clear(); PyErr_Format(PyExc_IndexError, "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name); __Pyx_DECREF_TypeName(index_type_name); } return NULL; } static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) { __Pyx_TypeName obj_type_name; if (likely(PyType_Check(obj))) { PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, __pyx_n_s_class_getitem); if (!meth) { PyErr_Clear(); } else { PyObject *result = __Pyx_PyObject_CallOneArg(meth, key); Py_DECREF(meth); return result; } } obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); return NULL; } static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) { PyTypeObject *tp = Py_TYPE(obj); PyMappingMethods *mm = tp->tp_as_mapping; PySequenceMethods *sm = tp->tp_as_sequence; if (likely(mm && mm->mp_subscript)) { return mm->mp_subscript(obj, key); } if (likely(sm && sm->sq_item)) { return __Pyx_PyObject_GetIndex(obj, key); } return __Pyx_PyObject_GetItem_Slow(obj, key); } #endif /* CallUnboundCMethod0 */ static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) { PyObject *args, *result = NULL; if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL; #if CYTHON_ASSUME_SAFE_MACROS args = PyTuple_New(1); if (unlikely(!args)) goto bad; Py_INCREF(self); PyTuple_SET_ITEM(args, 0, self); #else args = PyTuple_Pack(1, self); if (unlikely(!args)) goto bad; #endif result = __Pyx_PyObject_Call(cfunc->method, args, NULL); Py_DECREF(args); bad: return result; } /* py_dict_items */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_items, d); else return PyDict_Items(d); } /* py_dict_keys */ static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) { if (PY_MAJOR_VERSION >= 3) return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_keys, d); else return PyDict_Keys(d); } /* RaiseUnexpectedTypeError */ static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj) { __Pyx_TypeName obj_type_name = __Pyx_PyType_GetName(Py_TYPE(obj)); PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME, expected, obj_type_name); __Pyx_DECREF_TypeName(obj_type_name); return 0; } /* DictGetItem */ #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { PyObject *value; value = PyDict_GetItemWithError(d, key); if (unlikely(!value)) { if (!PyErr_Occurred()) { if (unlikely(PyTuple_Check(key))) { PyObject* args = PyTuple_Pack(1, key); if (likely(args)) { PyErr_SetObject(PyExc_KeyError, args); Py_DECREF(args); } } else { PyErr_SetObject(PyExc_KeyError, key); } } return NULL; } Py_INCREF(value); return value; } #endif /* FixUpExtensionType */ #if CYTHON_USE_TYPE_SPECS static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) { #if PY_VERSION_HEX > 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API CYTHON_UNUSED_VAR(spec); CYTHON_UNUSED_VAR(type); #else const PyType_Slot *slot = spec->slots; while (slot && slot->slot && slot->slot != Py_tp_members) slot++; if (slot && slot->slot == Py_tp_members) { int changed = 0; #if !(PY_VERSION_HEX <= 0x030900b1 && CYTHON_COMPILING_IN_CPYTHON) const #endif PyMemberDef *memb = (PyMemberDef*) slot->pfunc; while (memb && memb->name) { if (memb->name[0] == '_' && memb->name[1] == '_') { #if PY_VERSION_HEX < 0x030900b1 if (strcmp(memb->name, "__weaklistoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_weaklistoffset = memb->offset; changed = 1; } else if (strcmp(memb->name, "__dictoffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); type->tp_dictoffset = memb->offset; changed = 1; } #if CYTHON_METH_FASTCALL else if (strcmp(memb->name, "__vectorcalloffset__") == 0) { assert(memb->type == T_PYSSIZET); assert(memb->flags == READONLY); #if PY_VERSION_HEX >= 0x030800b4 type->tp_vectorcall_offset = memb->offset; #else type->tp_print = (printfunc) memb->offset; #endif changed = 1; } #endif #else if ((0)); #endif #if PY_VERSION_HEX <= 0x030900b1 && CYTHON_COMPILING_IN_CPYTHON else if (strcmp(memb->name, "__module__") == 0) { PyObject *descr; assert(memb->type == T_OBJECT); assert(memb->flags == 0 || memb->flags == READONLY); descr = PyDescr_NewMember(type, memb); if (unlikely(!descr)) return -1; if (unlikely(PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr) < 0)) { Py_DECREF(descr); return -1; } Py_DECREF(descr); changed = 1; } #endif } memb++; } if (changed) PyType_Modified(type); } #endif return 0; } #endif /* ValidateBasesTuple */ #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) { Py_ssize_t i, n; #if CYTHON_ASSUME_SAFE_MACROS n = PyTuple_GET_SIZE(bases); #else n = PyTuple_Size(bases); if (n < 0) return -1; #endif for (i = 1; i < n; i++) { #if CYTHON_AVOID_BORROWED_REFS PyObject *b0 = PySequence_GetItem(bases, i); if (!b0) return -1; #elif CYTHON_ASSUME_SAFE_MACROS PyObject *b0 = PyTuple_GET_ITEM(bases, i); #else PyObject *b0 = PyTuple_GetItem(bases, i); if (!b0) return -1; #endif PyTypeObject *b; #if PY_MAJOR_VERSION < 3 if (PyClass_Check(b0)) { PyErr_Format(PyExc_TypeError, "base class '%.200s' is an old-style class", PyString_AS_STRING(((PyClassObject*)b0)->cl_name)); #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } #endif b = (PyTypeObject*) b0; if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE)) { __Pyx_TypeName b_name = __Pyx_PyType_GetName(b); PyErr_Format(PyExc_TypeError, "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name); __Pyx_DECREF_TypeName(b_name); #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } if (dictoffset == 0) { Py_ssize_t b_dictoffset = 0; #if CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY b_dictoffset = b->tp_dictoffset; #else PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__"); if (!py_b_dictoffset) goto dictoffset_return; b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset); Py_DECREF(py_b_dictoffset); if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return; #endif if (b_dictoffset) { { __Pyx_TypeName b_name = __Pyx_PyType_GetName(b); PyErr_Format(PyExc_TypeError, "extension type '%.200s' has no __dict__ slot, " "but base type '" __Pyx_FMT_TYPENAME "' has: " "either add 'cdef dict __dict__' to the extension type " "or add '__slots__ = [...]' to the base type", type_name, b_name); __Pyx_DECREF_TypeName(b_name); } #if !(CYTHON_USE_TYPE_SLOTS || CYTHON_COMPILING_IN_PYPY) dictoffset_return: #endif #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif return -1; } } #if CYTHON_AVOID_BORROWED_REFS Py_DECREF(b0); #endif } return 0; } #endif /* PyType_Ready */ static int __Pyx_PyType_Ready(PyTypeObject *t) { #if CYTHON_USE_TYPE_SPECS || !(CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API) || defined(PYSTON_MAJOR_VERSION) (void)__Pyx_PyObject_CallMethod0; #if CYTHON_USE_TYPE_SPECS (void)__Pyx_validate_bases_tuple; #endif return PyType_Ready(t); #else int r; PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*); if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1)) return -1; #if PY_VERSION_HEX >= 0x03050000 && !defined(PYSTON_MAJOR_VERSION) { int gc_was_enabled; #if PY_VERSION_HEX >= 0x030A00b1 gc_was_enabled = PyGC_Disable(); (void)__Pyx_PyObject_CallMethod0; #else PyObject *ret, *py_status; PyObject *gc = NULL; #if PY_VERSION_HEX >= 0x030700a1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) gc = PyImport_GetModule(__pyx_kp_u_gc); #endif if (unlikely(!gc)) gc = PyImport_Import(__pyx_kp_u_gc); if (unlikely(!gc)) return -1; py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_isenabled); if (unlikely(!py_status)) { Py_DECREF(gc); return -1; } gc_was_enabled = __Pyx_PyObject_IsTrue(py_status); Py_DECREF(py_status); if (gc_was_enabled > 0) { ret = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_disable); if (unlikely(!ret)) { Py_DECREF(gc); return -1; } Py_DECREF(ret); } else if (unlikely(gc_was_enabled == -1)) { Py_DECREF(gc); return -1; } #endif t->tp_flags |= Py_TPFLAGS_HEAPTYPE; #if PY_VERSION_HEX >= 0x030A0000 t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE; #endif #else (void)__Pyx_PyObject_CallMethod0; #endif r = PyType_Ready(t); #if PY_VERSION_HEX >= 0x03050000 && !defined(PYSTON_MAJOR_VERSION) t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE; #if PY_VERSION_HEX >= 0x030A00b1 if (gc_was_enabled) PyGC_Enable(); #else if (gc_was_enabled) { PyObject *tp, *v, *tb; PyErr_Fetch(&tp, &v, &tb); ret = __Pyx_PyObject_CallMethod0(gc, __pyx_kp_u_enable); if (likely(ret || r == -1)) { Py_XDECREF(ret); PyErr_Restore(tp, v, tb); } else { Py_XDECREF(tp); Py_XDECREF(v); Py_XDECREF(tb); r = -1; } } Py_DECREF(gc); #endif } #endif return r; #endif } /* PyObject_GenericGetAttrNoDict */ #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { __Pyx_TypeName type_name = __Pyx_PyType_GetName(tp); PyErr_Format(PyExc_AttributeError, #if PY_MAJOR_VERSION >= 3 "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'", type_name, attr_name); #else "'" __Pyx_FMT_TYPENAME "' object has no attribute '%.400s'", type_name, PyString_AS_STRING(attr_name)); #endif __Pyx_DECREF_TypeName(type_name); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { PyObject *descr; PyTypeObject *tp = Py_TYPE(obj); if (unlikely(!PyString_Check(attr_name))) { return PyObject_GenericGetAttr(obj, attr_name); } assert(!tp->tp_dictoffset); descr = _PyType_Lookup(tp, attr_name); if (unlikely(!descr)) { return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); } Py_INCREF(descr); #if PY_MAJOR_VERSION < 3 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) #endif { descrgetfunc f = Py_TYPE(descr)->tp_descr_get; if (unlikely(f)) { PyObject *res = f(descr, obj, (PyObject *)tp); Py_DECREF(descr); return res; } } return descr; } #endif /* TypeImport */ #ifndef __PYX_HAVE_RT_ImportType_3_0_9 #define __PYX_HAVE_RT_ImportType_3_0_9 static PyTypeObject *__Pyx_ImportType_3_0_9(PyObject *module, const char *module_name, const char *class_name, size_t size, size_t alignment, enum __Pyx_ImportType_CheckSize_3_0_9 check_size) { PyObject *result = 0; char warning[200]; Py_ssize_t basicsize; Py_ssize_t itemsize; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; PyObject *py_itemsize; #endif result = PyObject_GetAttrString(module, class_name); if (!result) goto bad; if (!PyType_Check(result)) { PyErr_Format(PyExc_TypeError, "%.200s.%.200s is not a type object", module_name, class_name); goto bad; } #if !CYTHON_COMPILING_IN_LIMITED_API basicsize = ((PyTypeObject *)result)->tp_basicsize; itemsize = ((PyTypeObject *)result)->tp_itemsize; #else py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); if (!py_basicsize) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; py_itemsize = PyObject_GetAttrString(result, "__itemsize__"); if (!py_itemsize) goto bad; itemsize = PyLong_AsSsize_t(py_itemsize); Py_DECREF(py_itemsize); py_itemsize = 0; if (itemsize == (Py_ssize_t)-1 && PyErr_Occurred()) goto bad; #endif if (itemsize) { if (size % alignment) { alignment = size % alignment; } if (itemsize < (Py_ssize_t)alignment) itemsize = (Py_ssize_t)alignment; } if ((size_t)(basicsize + itemsize) < size) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize+itemsize); goto bad; } if (check_size == __Pyx_ImportType_CheckSize_Error_3_0_9 && ((size_t)basicsize > size || (size_t)(basicsize + itemsize) < size)) { PyErr_Format(PyExc_ValueError, "%.200s.%.200s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd-%zd from PyObject", module_name, class_name, size, basicsize, basicsize+itemsize); goto bad; } else if (check_size == __Pyx_ImportType_CheckSize_Warn_3_0_9 && (size_t)basicsize > size) { PyOS_snprintf(warning, sizeof(warning), "%s.%s size changed, may indicate binary incompatibility. " "Expected %zd from C header, got %zd from PyObject", module_name, class_name, size, basicsize); if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; } return (PyTypeObject *)result; bad: Py_XDECREF(result); return NULL; } #endif /* Import */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *module = 0; PyObject *empty_dict = 0; PyObject *empty_list = 0; #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (unlikely(!py_import)) goto bad; if (!from_list) { empty_list = PyList_New(0); if (unlikely(!empty_list)) goto bad; from_list = empty_list; } #endif empty_dict = PyDict_New(); if (unlikely(!empty_dict)) goto bad; { #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.') != NULL) { module = PyImport_ImportModuleLevelObject( name, __pyx_d, empty_dict, from_list, 1); if (unlikely(!module)) { if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) goto bad; PyErr_Clear(); } } level = 0; } #endif if (!module) { #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (unlikely(!py_level)) goto bad; module = PyObject_CallFunctionObjArgs(py_import, name, __pyx_d, empty_dict, from_list, py_level, (PyObject *)NULL); Py_DECREF(py_level); #else module = PyImport_ImportModuleLevelObject( name, __pyx_d, empty_dict, from_list, level); #endif } } bad: Py_XDECREF(empty_dict); Py_XDECREF(empty_list); #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif return module; } /* ImportDottedModule */ #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx__ImportDottedModule_Error(PyObject *name, PyObject *parts_tuple, Py_ssize_t count) { PyObject *partial_name = NULL, *slice = NULL, *sep = NULL; if (unlikely(PyErr_Occurred())) { PyErr_Clear(); } if (likely(PyTuple_GET_SIZE(parts_tuple) == count)) { partial_name = name; } else { slice = PySequence_GetSlice(parts_tuple, 0, count); if (unlikely(!slice)) goto bad; sep = PyUnicode_FromStringAndSize(".", 1); if (unlikely(!sep)) goto bad; partial_name = PyUnicode_Join(sep, slice); } PyErr_Format( #if PY_MAJOR_VERSION < 3 PyExc_ImportError, "No module named '%s'", PyString_AS_STRING(partial_name)); #else #if PY_VERSION_HEX >= 0x030600B1 PyExc_ModuleNotFoundError, #else PyExc_ImportError, #endif "No module named '%U'", partial_name); #endif bad: Py_XDECREF(sep); Py_XDECREF(slice); Py_XDECREF(partial_name); return NULL; } #endif #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx__ImportDottedModule_Lookup(PyObject *name) { PyObject *imported_module; #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) return NULL; imported_module = __Pyx_PyDict_GetItemStr(modules, name); Py_XINCREF(imported_module); #else imported_module = PyImport_GetModule(name); #endif return imported_module; } #endif #if PY_MAJOR_VERSION >= 3 static PyObject *__Pyx_ImportDottedModule_WalkParts(PyObject *module, PyObject *name, PyObject *parts_tuple) { Py_ssize_t i, nparts; nparts = PyTuple_GET_SIZE(parts_tuple); for (i=1; i < nparts && module; i++) { PyObject *part, *submodule; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS part = PyTuple_GET_ITEM(parts_tuple, i); #else part = PySequence_ITEM(parts_tuple, i); #endif submodule = __Pyx_PyObject_GetAttrStrNoError(module, part); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(part); #endif Py_DECREF(module); module = submodule; } if (unlikely(!module)) { return __Pyx__ImportDottedModule_Error(name, parts_tuple, i); } return module; } #endif static PyObject *__Pyx__ImportDottedModule(PyObject *name, PyObject *parts_tuple) { #if PY_MAJOR_VERSION < 3 PyObject *module, *from_list, *star = __pyx_n_s__8; CYTHON_UNUSED_VAR(parts_tuple); from_list = PyList_New(1); if (unlikely(!from_list)) return NULL; Py_INCREF(star); PyList_SET_ITEM(from_list, 0, star); module = __Pyx_Import(name, from_list, 0); Py_DECREF(from_list); return module; #else PyObject *imported_module; PyObject *module = __Pyx_Import(name, NULL, 0); if (!parts_tuple || unlikely(!module)) return module; imported_module = __Pyx__ImportDottedModule_Lookup(name); if (likely(imported_module)) { Py_DECREF(module); return imported_module; } PyErr_Clear(); return __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple); #endif } static PyObject *__Pyx_ImportDottedModule(PyObject *name, PyObject *parts_tuple) { #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030400B1 PyObject *module = __Pyx__ImportDottedModule_Lookup(name); if (likely(module)) { PyObject *spec = __Pyx_PyObject_GetAttrStrNoError(module, __pyx_n_s_spec); if (likely(spec)) { PyObject *unsafe = __Pyx_PyObject_GetAttrStrNoError(spec, __pyx_n_s_initializing); if (likely(!unsafe || !__Pyx_PyObject_IsTrue(unsafe))) { Py_DECREF(spec); spec = NULL; } Py_XDECREF(unsafe); } if (likely(!spec)) { PyErr_Clear(); return module; } Py_DECREF(spec); Py_DECREF(module); } else if (PyErr_Occurred()) { PyErr_Clear(); } #endif return __Pyx__ImportDottedModule(name, parts_tuple); } /* ImportDottedModuleRelFirst */ static PyObject *__Pyx_ImportDottedModuleRelFirst(PyObject *name, PyObject *parts_tuple) { PyObject *module; PyObject *from_list = NULL; #if PY_MAJOR_VERSION < 3 PyObject *star = __pyx_n_s__8; from_list = PyList_New(1); if (unlikely(!from_list)) return NULL; Py_INCREF(star); PyList_SET_ITEM(from_list, 0, star); #endif module = __Pyx_Import(name, from_list, -1); Py_XDECREF(from_list); if (module) { #if PY_MAJOR_VERSION >= 3 if (parts_tuple) { module = __Pyx_ImportDottedModule_WalkParts(module, name, parts_tuple); } #endif return module; } if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError))) return NULL; PyErr_Clear(); return __Pyx_ImportDottedModule(name, parts_tuple); } /* ImportFrom */ static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { const char* module_name_str = 0; PyObject* module_name = 0; PyObject* module_dot = 0; PyObject* full_name = 0; PyErr_Clear(); module_name_str = PyModule_GetName(module); if (unlikely(!module_name_str)) { goto modbad; } module_name = PyUnicode_FromString(module_name_str); if (unlikely(!module_name)) { goto modbad; } module_dot = PyUnicode_Concat(module_name, __pyx_kp_u__9); if (unlikely(!module_dot)) { goto modbad; } full_name = PyUnicode_Concat(module_dot, name); if (unlikely(!full_name)) { goto modbad; } #if PY_VERSION_HEX < 0x030700A1 || (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) goto modbad; value = PyObject_GetItem(modules, full_name); } #else value = PyImport_GetModule(full_name); #endif modbad: Py_XDECREF(full_name); Py_XDECREF(module_dot); Py_XDECREF(module_name); } if (unlikely(!value)) { PyErr_Format(PyExc_ImportError, #if PY_MAJOR_VERSION < 3 "cannot import name %.230s", PyString_AS_STRING(name)); #else "cannot import name %S", name); #endif } return value; } /* FetchSharedCythonModule */ static PyObject *__Pyx_FetchSharedCythonABIModule(void) { return __Pyx_PyImport_AddModuleRef((char*) __PYX_ABI_MODULE_NAME); } /* FetchCommonType */ static int __Pyx_VerifyCachedType(PyObject *cached_type, const char *name, Py_ssize_t basicsize, Py_ssize_t expected_basicsize) { if (!PyType_Check(cached_type)) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s is not a type object", name); return -1; } if (basicsize != expected_basicsize) { PyErr_Format(PyExc_TypeError, "Shared Cython type %.200s has the wrong size, try recompiling", name); return -1; } return 0; } #if !CYTHON_USE_TYPE_SPECS static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* abi_module; const char* object_name; PyTypeObject *cached_type = NULL; abi_module = __Pyx_FetchSharedCythonABIModule(); if (!abi_module) return NULL; object_name = strrchr(type->tp_name, '.'); object_name = object_name ? object_name+1 : type->tp_name; cached_type = (PyTypeObject*) PyObject_GetAttrString(abi_module, object_name); if (cached_type) { if (__Pyx_VerifyCachedType( (PyObject *)cached_type, object_name, cached_type->tp_basicsize, type->tp_basicsize) < 0) { goto bad; } goto done; } if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); if (PyType_Ready(type) < 0) goto bad; if (PyObject_SetAttrString(abi_module, object_name, (PyObject *)type) < 0) goto bad; Py_INCREF(type); cached_type = type; done: Py_DECREF(abi_module); return cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } #else static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) { PyObject *abi_module, *cached_type = NULL; const char* object_name = strrchr(spec->name, '.'); object_name = object_name ? object_name+1 : spec->name; abi_module = __Pyx_FetchSharedCythonABIModule(); if (!abi_module) return NULL; cached_type = PyObject_GetAttrString(abi_module, object_name); if (cached_type) { Py_ssize_t basicsize; #if CYTHON_COMPILING_IN_LIMITED_API PyObject *py_basicsize; py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__"); if (unlikely(!py_basicsize)) goto bad; basicsize = PyLong_AsSsize_t(py_basicsize); Py_DECREF(py_basicsize); py_basicsize = 0; if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; #else basicsize = likely(PyType_Check(cached_type)) ? ((PyTypeObject*) cached_type)->tp_basicsize : -1; #endif if (__Pyx_VerifyCachedType( cached_type, object_name, basicsize, spec->basicsize) < 0) { goto bad; } goto done; } if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad; PyErr_Clear(); CYTHON_UNUSED_VAR(module); cached_type = __Pyx_PyType_FromModuleAndSpec(abi_module, spec, bases); if (unlikely(!cached_type)) goto bad; if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad; if (PyObject_SetAttrString(abi_module, object_name, cached_type) < 0) goto bad; done: Py_DECREF(abi_module); assert(cached_type == NULL || PyType_Check(cached_type)); return (PyTypeObject *) cached_type; bad: Py_XDECREF(cached_type); cached_type = NULL; goto done; } #endif /* PyVectorcallFastCallDict */ #if CYTHON_METH_FASTCALL static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { PyObject *res = NULL; PyObject *kwnames; PyObject **newargs; PyObject **kwvalues; Py_ssize_t i, pos; size_t j; PyObject *key, *value; unsigned long keys_are_strings; Py_ssize_t nkw = PyDict_GET_SIZE(kw); newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0])); if (unlikely(newargs == NULL)) { PyErr_NoMemory(); return NULL; } for (j = 0; j < nargs; j++) newargs[j] = args[j]; kwnames = PyTuple_New(nkw); if (unlikely(kwnames == NULL)) { PyMem_Free(newargs); return NULL; } kwvalues = newargs + nargs; pos = i = 0; keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS; while (PyDict_Next(kw, &pos, &key, &value)) { keys_are_strings &= Py_TYPE(key)->tp_flags; Py_INCREF(key); Py_INCREF(value); PyTuple_SET_ITEM(kwnames, i, key); kwvalues[i] = value; i++; } if (unlikely(!keys_are_strings)) { PyErr_SetString(PyExc_TypeError, "keywords must be strings"); goto cleanup; } res = vc(func, newargs, nargs, kwnames); cleanup: Py_DECREF(kwnames); for (i = 0; i < nkw; i++) Py_DECREF(kwvalues[i]); PyMem_Free(newargs); return res; } static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw) { if (likely(kw == NULL) || PyDict_GET_SIZE(kw) == 0) { return vc(func, args, nargs, NULL); } return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw); } #endif /* CythonFunctionShared */ #if CYTHON_COMPILING_IN_LIMITED_API static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) { if (__Pyx_CyFunction_Check(func)) { return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc; } else if (PyCFunction_Check(func)) { return PyCFunction_GetFunction(func) == (PyCFunction) cfunc; } return 0; } #else static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void *cfunc) { return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc; } #endif static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) { #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API __Pyx_Py_XDECREF_SET( __Pyx_CyFunction_GetClassObj(f), ((classobj) ? __Pyx_NewRef(classobj) : NULL)); #else __Pyx_Py_XDECREF_SET( ((PyCMethodObject *) (f))->mm_class, (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL)); #endif } static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) { CYTHON_UNUSED_VAR(closure); if (unlikely(op->func_doc == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_doc = PyObject_GetAttrString(op->func, "__doc__"); if (unlikely(!op->func_doc)) return NULL; #else if (((PyCFunctionObject*)op)->m_ml->ml_doc) { #if PY_MAJOR_VERSION >= 3 op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); #else op->func_doc = PyString_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc); #endif if (unlikely(op->func_doc == NULL)) return NULL; } else { Py_INCREF(Py_None); return Py_None; } #endif } Py_INCREF(op->func_doc); return op->func_doc; } static int __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (value == NULL) { value = Py_None; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->func_doc, value); return 0; } static PyObject * __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_name == NULL)) { #if CYTHON_COMPILING_IN_LIMITED_API op->func_name = PyObject_GetAttrString(op->func, "__name__"); #elif PY_MAJOR_VERSION >= 3 op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #else op->func_name = PyString_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name); #endif if (unlikely(op->func_name == NULL)) return NULL; } Py_INCREF(op->func_name); return op->func_name; } static int __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->func_name, value); return 0; } static PyObject * __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); Py_INCREF(op->func_qualname); return op->func_qualname; } static int __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->func_qualname, value); return 0; } static PyObject * __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(op->func_dict == NULL)) { op->func_dict = PyDict_New(); if (unlikely(op->func_dict == NULL)) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; } static int __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); if (unlikely(value == NULL)) { PyErr_SetString(PyExc_TypeError, "function's dictionary may not be deleted"); return -1; } if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "setting function's dictionary to a non-dict"); return -1; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->func_dict, value); return 0; } static PyObject * __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); Py_INCREF(op->func_globals); return op->func_globals; } static PyObject * __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(op); CYTHON_UNUSED_VAR(context); Py_INCREF(Py_None); return Py_None; } static PyObject * __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context) { PyObject* result = (op->func_code) ? op->func_code : Py_None; CYTHON_UNUSED_VAR(context); Py_INCREF(result); return result; } static int __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { int result = 0; PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); Py_INCREF(op->defaults_kwdict); #else op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0); if (unlikely(!op->defaults_tuple)) result = -1; else { op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1); if (unlikely(!op->defaults_kwdict)) result = -1; } #endif Py_DECREF(res); return result; } static int __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyTuple_Check(value))) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->defaults_tuple, value); return 0; } static PyObject * __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result = op->defaults_tuple; CYTHON_UNUSED_VAR(context); if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_tuple; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value) { value = Py_None; } else if (unlikely(value != Py_None && !PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__kwdefaults__ must be set to a dict object"); return -1; } PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not " "currently affect the values used in function calls", 1); Py_INCREF(value); __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value); return 0; } static PyObject * __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) { PyObject* result = op->defaults_kwdict; CYTHON_UNUSED_VAR(context); if (unlikely(!result)) { if (op->defaults_getter) { if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL; result = op->defaults_kwdict; } else { result = Py_None; } } Py_INCREF(result); return result; } static int __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); if (!value || value == Py_None) { value = NULL; } else if (unlikely(!PyDict_Check(value))) { PyErr_SetString(PyExc_TypeError, "__annotations__ must be set to a dict object"); return -1; } Py_XINCREF(value); __Pyx_Py_XDECREF_SET(op->func_annotations, value); return 0; } static PyObject * __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) { PyObject* result = op->func_annotations; CYTHON_UNUSED_VAR(context); if (unlikely(!result)) { result = PyDict_New(); if (unlikely(!result)) return NULL; op->func_annotations = result; } Py_INCREF(result); return result; } static PyObject * __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) { int is_coroutine; CYTHON_UNUSED_VAR(context); if (op->func_is_coroutine) { return __Pyx_NewRef(op->func_is_coroutine); } is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE; #if PY_VERSION_HEX >= 0x03050000 if (is_coroutine) { PyObject *module, *fromlist, *marker = __pyx_n_s_is_coroutine; fromlist = PyList_New(1); if (unlikely(!fromlist)) return NULL; Py_INCREF(marker); #if CYTHON_ASSUME_SAFE_MACROS PyList_SET_ITEM(fromlist, 0, marker); #else if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) { Py_DECREF(marker); Py_DECREF(fromlist); return NULL; } #endif module = PyImport_ImportModuleLevelObject(__pyx_n_s_asyncio_coroutines, NULL, NULL, fromlist, 0); Py_DECREF(fromlist); if (unlikely(!module)) goto ignore; op->func_is_coroutine = __Pyx_PyObject_GetAttrStr(module, marker); Py_DECREF(module); if (likely(op->func_is_coroutine)) { return __Pyx_NewRef(op->func_is_coroutine); } ignore: PyErr_Clear(); } #endif op->func_is_coroutine = __Pyx_PyBool_FromLong(is_coroutine); return __Pyx_NewRef(op->func_is_coroutine); } #if CYTHON_COMPILING_IN_LIMITED_API static PyObject * __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_GetAttrString(op->func, "__module__"); } static int __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) { CYTHON_UNUSED_VAR(context); return PyObject_SetAttrString(op->func, "__module__", value); } #endif static PyGetSetDef __pyx_CyFunction_getsets[] = { {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0}, {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0}, {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0}, {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0}, {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0}, {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0}, {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0}, {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0}, {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0}, {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0}, {(char *) "_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0}, #if CYTHON_COMPILING_IN_LIMITED_API {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0}, #endif {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { #if !CYTHON_COMPILING_IN_LIMITED_API {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0}, #endif #if CYTHON_USE_TYPE_SPECS {(char *) "__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0}, #if CYTHON_METH_FASTCALL #if CYTHON_BACKPORT_VECTORCALL {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0}, #else #if !CYTHON_COMPILING_IN_LIMITED_API {(char *) "__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0}, #endif #endif #endif #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0}, #else {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0}, #endif #endif {0, 0, 0, 0, 0} }; static PyObject * __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args) { CYTHON_UNUSED_VAR(args); #if PY_MAJOR_VERSION >= 3 Py_INCREF(m->func_qualname); return m->func_qualname; #else return PyString_FromString(((PyCFunctionObject*)m)->m_ml->ml_name); #endif } static PyMethodDef __pyx_CyFunction_methods[] = { {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0}, {0, 0, 0, 0} }; #if PY_VERSION_HEX < 0x030500A0 || CYTHON_COMPILING_IN_LIMITED_API #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist) #else #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist) #endif static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { #if !CYTHON_COMPILING_IN_LIMITED_API PyCFunctionObject *cf = (PyCFunctionObject*) op; #endif if (unlikely(op == NULL)) return NULL; #if CYTHON_COMPILING_IN_LIMITED_API op->func = PyCFunction_NewEx(ml, (PyObject*)op, module); if (unlikely(!op->func)) return NULL; #endif op->flags = flags; __Pyx_CyFunction_weakreflist(op) = NULL; #if !CYTHON_COMPILING_IN_LIMITED_API cf->m_ml = ml; cf->m_self = (PyObject *) op; #endif Py_XINCREF(closure); op->func_closure = closure; #if !CYTHON_COMPILING_IN_LIMITED_API Py_XINCREF(module); cf->m_module = module; #endif op->func_dict = NULL; op->func_name = NULL; Py_INCREF(qualname); op->func_qualname = qualname; op->func_doc = NULL; #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API op->func_classobj = NULL; #else ((PyCMethodObject*)op)->mm_class = NULL; #endif op->func_globals = globals; Py_INCREF(op->func_globals); Py_XINCREF(code); op->func_code = code; op->defaults_pyobjects = 0; op->defaults_size = 0; op->defaults = NULL; op->defaults_tuple = NULL; op->defaults_kwdict = NULL; op->defaults_getter = NULL; op->func_annotations = NULL; op->func_is_coroutine = NULL; #if CYTHON_METH_FASTCALL switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) { case METH_NOARGS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS; break; case METH_O: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O; break; case METH_METHOD | METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD; break; case METH_FASTCALL | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS; break; case METH_VARARGS | METH_KEYWORDS: __Pyx_CyFunction_func_vectorcall(op) = NULL; break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); Py_DECREF(op); return NULL; } #endif return (PyObject *) op; } static int __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) { Py_CLEAR(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_CLEAR(m->func); #else Py_CLEAR(((PyCFunctionObject*)m)->m_module); #endif Py_CLEAR(m->func_dict); Py_CLEAR(m->func_name); Py_CLEAR(m->func_qualname); Py_CLEAR(m->func_doc); Py_CLEAR(m->func_globals); Py_CLEAR(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API #if PY_VERSION_HEX < 0x030900B1 Py_CLEAR(__Pyx_CyFunction_GetClassObj(m)); #else { PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class; ((PyCMethodObject *) (m))->mm_class = NULL; Py_XDECREF(cls); } #endif #endif Py_CLEAR(m->defaults_tuple); Py_CLEAR(m->defaults_kwdict); Py_CLEAR(m->func_annotations); Py_CLEAR(m->func_is_coroutine); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_XDECREF(pydefaults[i]); PyObject_Free(m->defaults); m->defaults = NULL; } return 0; } static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); __Pyx_PyHeapTypeObject_GC_Del(m); } static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) { PyObject_GC_UnTrack(m); __Pyx__CyFunction_dealloc(m); } static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func_closure); #if CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(m->func); #else Py_VISIT(((PyCFunctionObject*)m)->m_module); #endif Py_VISIT(m->func_dict); Py_VISIT(m->func_name); Py_VISIT(m->func_qualname); Py_VISIT(m->func_doc); Py_VISIT(m->func_globals); Py_VISIT(m->func_code); #if !CYTHON_COMPILING_IN_LIMITED_API Py_VISIT(__Pyx_CyFunction_GetClassObj(m)); #endif Py_VISIT(m->defaults_tuple); Py_VISIT(m->defaults_kwdict); Py_VISIT(m->func_is_coroutine); if (m->defaults) { PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m); int i; for (i = 0; i < m->defaults_pyobjects; i++) Py_VISIT(pydefaults[i]); } return 0; } static PyObject* __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("", op->func_qualname, (void *)op); #else return PyString_FromFormat("", PyString_AsString(op->func_qualname), (void *)op); #endif } static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { #if CYTHON_COMPILING_IN_LIMITED_API PyObject *f = ((__pyx_CyFunctionObject*)func)->func; PyObject *py_name = NULL; PyCFunction meth; int flags; meth = PyCFunction_GetFunction(f); if (unlikely(!meth)) return NULL; flags = PyCFunction_GetFlags(f); if (unlikely(flags < 0)) return NULL; #else PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; int flags = f->m_ml->ml_flags; #endif Py_ssize_t size; switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) return (*meth)(self, arg); break; case METH_VARARGS | METH_KEYWORDS: return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw); case METH_NOARGS: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_MACROS size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 0)) return (*meth)(self, NULL); #if CYTHON_COMPILING_IN_LIMITED_API py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); if (!py_name) return NULL; PyErr_Format(PyExc_TypeError, "%.200S() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", py_name, size); Py_DECREF(py_name); #else PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); #endif return NULL; } break; case METH_O: if (likely(kw == NULL || PyDict_Size(kw) == 0)) { #if CYTHON_ASSUME_SAFE_MACROS size = PyTuple_GET_SIZE(arg); #else size = PyTuple_Size(arg); if (unlikely(size < 0)) return NULL; #endif if (likely(size == 1)) { PyObject *result, *arg0; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS arg0 = PyTuple_GET_ITEM(arg, 0); #else arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; #endif result = (*meth)(self, arg0); #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); #endif return result; } #if CYTHON_COMPILING_IN_LIMITED_API py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); if (!py_name) return NULL; PyErr_Format(PyExc_TypeError, "%.200S() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", py_name, size); Py_DECREF(py_name); #else PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", f->m_ml->ml_name, size); #endif return NULL; } break; default: PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction"); return NULL; } #if CYTHON_COMPILING_IN_LIMITED_API py_name = __Pyx_CyFunction_get_name((__pyx_CyFunctionObject*)func, NULL); if (!py_name) return NULL; PyErr_Format(PyExc_TypeError, "%.200S() takes no keyword arguments", py_name); Py_DECREF(py_name); #else PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); #endif return NULL; } static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *self, *result; #if CYTHON_COMPILING_IN_LIMITED_API self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func); if (unlikely(!self) && PyErr_Occurred()) return NULL; #else self = ((PyCFunctionObject*)func)->m_self; #endif result = __Pyx_CyFunction_CallMethod(func, self, arg, kw); return result; } static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { PyObject *result; __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; #if CYTHON_METH_FASTCALL __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc); if (vc) { #if CYTHON_ASSUME_SAFE_MACROS return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw); #else (void) &__Pyx_PyVectorcall_FastCallDict; return PyVectorcall_Call(func, args, kw); #endif } #endif if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { Py_ssize_t argc; PyObject *new_args; PyObject *self; #if CYTHON_ASSUME_SAFE_MACROS argc = PyTuple_GET_SIZE(args); #else argc = PyTuple_Size(args); if (unlikely(!argc) < 0) return NULL; #endif new_args = PyTuple_GetSlice(args, 1, argc); if (unlikely(!new_args)) return NULL; self = PyTuple_GetItem(args, 0); if (unlikely(!self)) { Py_DECREF(new_args); #if PY_MAJOR_VERSION > 2 PyErr_Format(PyExc_TypeError, "unbound method %.200S() needs an argument", cyfunc->func_qualname); #else PyErr_SetString(PyExc_TypeError, "unbound method needs an argument"); #endif return NULL; } result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); Py_DECREF(new_args); } else { result = __Pyx_CyFunction_Call(func, args, kw); } return result; } #if CYTHON_METH_FASTCALL static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames) { int ret = 0; if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { if (unlikely(nargs < 1)) { PyErr_Format(PyExc_TypeError, "%.200s() needs an argument", ((PyCFunctionObject*)cyfunc)->m_ml->ml_name); return -1; } ret = 1; } if (unlikely(kwnames) && unlikely(PyTuple_GET_SIZE(kwnames))) { PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", ((PyCFunctionObject*)cyfunc)->m_ml->ml_name); return -1; } return ret; } static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; #if CYTHON_BACKPORT_VECTORCALL Py_ssize_t nargs = (Py_ssize_t)nargsf; #else Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); #endif PyObject *self; switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: self = ((PyCFunctionObject*)cyfunc)->m_self; break; default: return NULL; } if (unlikely(nargs != 0)) { PyErr_Format(PyExc_TypeError, "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)", def->ml_name, nargs); return NULL; } return def->ml_meth(self, NULL); } static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; #if CYTHON_BACKPORT_VECTORCALL Py_ssize_t nargs = (Py_ssize_t)nargsf; #else Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); #endif PyObject *self; switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: self = ((PyCFunctionObject*)cyfunc)->m_self; break; default: return NULL; } if (unlikely(nargs != 1)) { PyErr_Format(PyExc_TypeError, "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)", def->ml_name, nargs); return NULL; } return def->ml_meth(self, args[0]); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; #if CYTHON_BACKPORT_VECTORCALL Py_ssize_t nargs = (Py_ssize_t)nargsf; #else Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); #endif PyObject *self; switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: self = ((PyCFunctionObject*)cyfunc)->m_self; break; default: return NULL; } return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))def->ml_meth)(self, args, nargs, kwnames); } static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames) { __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func; PyMethodDef* def = ((PyCFunctionObject*)cyfunc)->m_ml; PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc); #if CYTHON_BACKPORT_VECTORCALL Py_ssize_t nargs = (Py_ssize_t)nargsf; #else Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); #endif PyObject *self; switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) { case 1: self = args[0]; args += 1; nargs -= 1; break; case 0: self = ((PyCFunctionObject*)cyfunc)->m_self; break; default: return NULL; } return ((__Pyx_PyCMethod)(void(*)(void))def->ml_meth)(self, cls, args, (size_t)nargs, kwnames); } #endif #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_CyFunctionType_slots[] = { {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc}, {Py_tp_repr, (void *)__Pyx_CyFunction_repr}, {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod}, {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse}, {Py_tp_clear, (void *)__Pyx_CyFunction_clear}, {Py_tp_methods, (void *)__pyx_CyFunction_methods}, {Py_tp_members, (void *)__pyx_CyFunction_members}, {Py_tp_getset, (void *)__pyx_CyFunction_getsets}, {Py_tp_descr_get, (void *)__Pyx_PyMethod_New}, {0, 0}, }; static PyType_Spec __pyx_CyFunctionType_spec = { __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif #if (defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL) _Py_TPFLAGS_HAVE_VECTORCALL | #endif Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, __pyx_CyFunctionType_slots }; #else static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) __PYX_TYPE_MODULE_PREFIX "cython_function_or_method", sizeof(__pyx_CyFunctionObject), 0, (destructor) __Pyx_CyFunction_dealloc, #if !CYTHON_METH_FASTCALL 0, #elif CYTHON_BACKPORT_VECTORCALL (printfunc)offsetof(__pyx_CyFunctionObject, func_vectorcall), #else offsetof(PyCFunctionObject, vectorcall), #endif 0, 0, #if PY_MAJOR_VERSION < 3 0, #else 0, #endif (reprfunc) __Pyx_CyFunction_repr, 0, 0, 0, 0, __Pyx_CyFunction_CallAsMethod, 0, 0, 0, 0, #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR Py_TPFLAGS_METHOD_DESCRIPTOR | #endif #if defined(_Py_TPFLAGS_HAVE_VECTORCALL) && CYTHON_METH_FASTCALL _Py_TPFLAGS_HAVE_VECTORCALL | #endif Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, 0, (traverseproc) __Pyx_CyFunction_traverse, (inquiry) __Pyx_CyFunction_clear, 0, #if PY_VERSION_HEX < 0x030500A0 offsetof(__pyx_CyFunctionObject, func_weakreflist), #else offsetof(PyCFunctionObject, m_weakreflist), #endif 0, 0, __pyx_CyFunction_methods, __pyx_CyFunction_members, __pyx_CyFunction_getsets, 0, 0, __Pyx_PyMethod_New, 0, offsetof(__pyx_CyFunctionObject, func_dict), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if PY_VERSION_HEX >= 0x030400a1 0, #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, #endif #if __PYX_NEED_TP_PRINT_SLOT 0, #endif #if PY_VERSION_HEX >= 0x030C0000 0, #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, #endif }; #endif static int __pyx_CyFunction_init(PyObject *module) { #if CYTHON_USE_TYPE_SPECS __pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_CyFunctionType_spec, NULL); #else CYTHON_UNUSED_VAR(module); __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); #endif if (unlikely(__pyx_CyFunctionType == NULL)) { return -1; } return 0; } static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_Malloc(size); if (unlikely(!m->defaults)) return PyErr_NoMemory(); memset(m->defaults, 0, size); m->defaults_pyobjects = pyobjects; m->defaults_size = size; return m->defaults; } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_tuple = tuple; Py_INCREF(tuple); } static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults_kwdict = dict; Py_INCREF(dict); } static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->func_annotations = dict; Py_INCREF(dict); } /* CythonFunction */ static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname, PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) { PyObject *op = __Pyx_CyFunction_Init( PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType), ml, flags, qualname, closure, module, globals, code ); if (likely(op)) { PyObject_GC_Track(op); } return op; } /* CLineInTraceback */ #ifndef CYTHON_CLINE_IN_TRACEBACK static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) { PyObject *use_cline; PyObject *ptype, *pvalue, *ptraceback; #if CYTHON_COMPILING_IN_CPYTHON PyObject **cython_runtime_dict; #endif CYTHON_MAYBE_UNUSED_VAR(tstate); if (unlikely(!__pyx_cython_runtime)) { return c_line; } __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); #if CYTHON_COMPILING_IN_CPYTHON cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); if (likely(cython_runtime_dict)) { __PYX_PY_DICT_LOOKUP_IF_MODIFIED( use_cline, *cython_runtime_dict, __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) } else #endif { PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStrNoError(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); if (use_cline_obj) { use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; Py_DECREF(use_cline_obj); } else { PyErr_Clear(); use_cline = NULL; } } if (!use_cline) { c_line = 0; (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); } else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { c_line = 0; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); return c_line; } #endif /* CodeObjectCache */ #if !CYTHON_COMPILING_IN_LIMITED_API static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; } while (start < end) { mid = start + (end - start) / 2; if (code_line < entries[mid].code_line) { end = mid; } else if (code_line > entries[mid].code_line) { start = mid + 1; } else { return mid; } } if (code_line <= entries[mid].code_line) { return mid; } else { return mid + 1; } } static PyCodeObject *__pyx_find_code_object(int code_line) { PyCodeObject* code_object; int pos; if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { return NULL; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { return NULL; } code_object = __pyx_code_cache.entries[pos].code_object; Py_INCREF(code_object); return code_object; } static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { int pos, i; __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; if (unlikely(!code_line)) { return; } if (unlikely(!entries)) { entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); if (likely(entries)) { __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = 64; __pyx_code_cache.count = 1; entries[0].code_line = code_line; entries[0].code_object = code_object; Py_INCREF(code_object); } return; } pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { PyCodeObject* tmp = entries[pos].code_object; entries[pos].code_object = code_object; Py_DECREF(tmp); return; } if (__pyx_code_cache.count == __pyx_code_cache.max_count) { int new_max = __pyx_code_cache.max_count + 64; entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); if (unlikely(!entries)) { return; } __pyx_code_cache.entries = entries; __pyx_code_cache.max_count = new_max; } for (i=__pyx_code_cache.count; i>pos; i--) { entries[i] = entries[i-1]; } entries[pos].code_line = code_line; entries[pos].code_object = code_object; __pyx_code_cache.count++; Py_INCREF(code_object); } #endif /* AddTraceback */ #include "compile.h" #include "frameobject.h" #include "traceback.h" #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #if CYTHON_COMPILING_IN_LIMITED_API static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict, PyObject *firstlineno, PyObject *name) { PyObject *replace = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL; replace = PyObject_GetAttrString(code, "replace"); if (likely(replace)) { PyObject *result; result = PyObject_Call(replace, __pyx_empty_tuple, scratch_dict); Py_DECREF(replace); return result; } PyErr_Clear(); #if __PYX_LIMITED_VERSION_HEX < 0x030780000 { PyObject *compiled = NULL, *result = NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "code", code))) return NULL; if (unlikely(PyDict_SetItemString(scratch_dict, "type", (PyObject*)(&PyType_Type)))) return NULL; compiled = Py_CompileString( "out = type(code)(\n" " code.co_argcount, code.co_kwonlyargcount, code.co_nlocals, code.co_stacksize,\n" " code.co_flags, code.co_code, code.co_consts, code.co_names,\n" " code.co_varnames, code.co_filename, co_name, co_firstlineno,\n" " code.co_lnotab)\n", "", Py_file_input); if (!compiled) return NULL; result = PyEval_EvalCode(compiled, scratch_dict, scratch_dict); Py_DECREF(compiled); if (!result) PyErr_Print(); Py_DECREF(result); result = PyDict_GetItemString(scratch_dict, "out"); if (result) Py_INCREF(result); return result; } #else return NULL; #endif } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL; PyObject *replace = NULL, *getframe = NULL, *frame = NULL; PyObject *exc_type, *exc_value, *exc_traceback; int success = 0; if (c_line) { (void) __pyx_cfilenm; (void) __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line); } PyErr_Fetch(&exc_type, &exc_value, &exc_traceback); code_object = Py_CompileString("_getframe()", filename, Py_eval_input); if (unlikely(!code_object)) goto bad; py_py_line = PyLong_FromLong(py_line); if (unlikely(!py_py_line)) goto bad; py_funcname = PyUnicode_FromString(funcname); if (unlikely(!py_funcname)) goto bad; dict = PyDict_New(); if (unlikely(!dict)) goto bad; { PyObject *old_code_object = code_object; code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname); Py_DECREF(old_code_object); } if (unlikely(!code_object)) goto bad; getframe = PySys_GetObject("_getframe"); if (unlikely(!getframe)) goto bad; if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad; frame = PyEval_EvalCode(code_object, dict, dict); if (unlikely(!frame) || frame == Py_None) goto bad; success = 1; bad: PyErr_Restore(exc_type, exc_value, exc_traceback); Py_XDECREF(code_object); Py_XDECREF(py_py_line); Py_XDECREF(py_funcname); Py_XDECREF(dict); Py_XDECREF(replace); if (success) { PyTraceBack_Here( (struct _frame*)frame); } Py_XDECREF(frame); } #else static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = NULL; PyObject *py_funcname = NULL; #if PY_MAJOR_VERSION < 3 PyObject *py_srcfile = NULL; py_srcfile = PyString_FromString(filename); if (!py_srcfile) goto bad; #endif if (c_line) { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; #else py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); if (!py_funcname) goto bad; funcname = PyUnicode_AsUTF8(py_funcname); if (!funcname) goto bad; #endif } else { #if PY_MAJOR_VERSION < 3 py_funcname = PyString_FromString(funcname); if (!py_funcname) goto bad; #endif } #if PY_MAJOR_VERSION < 3 py_code = __Pyx_PyCode_New( 0, 0, 0, 0, 0, 0, __pyx_empty_bytes, /*PyObject *code,*/ __pyx_empty_tuple, /*PyObject *consts,*/ __pyx_empty_tuple, /*PyObject *names,*/ __pyx_empty_tuple, /*PyObject *varnames,*/ __pyx_empty_tuple, /*PyObject *freevars,*/ __pyx_empty_tuple, /*PyObject *cellvars,*/ py_srcfile, /*PyObject *filename,*/ py_funcname, /*PyObject *name,*/ py_line, __pyx_empty_bytes /*PyObject *lnotab*/ ); Py_DECREF(py_srcfile); #else py_code = PyCode_NewEmpty(filename, funcname, py_line); #endif Py_XDECREF(py_funcname); return py_code; bad: Py_XDECREF(py_funcname); #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_srcfile); #endif return NULL; } static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject *ptype, *pvalue, *ptraceback; if (c_line) { c_line = __Pyx_CLineForTraceback(tstate, c_line); } py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) { /* If the code object creation fails, then we should clear the fetched exception references and propagate the new exception */ Py_XDECREF(ptype); Py_XDECREF(pvalue); Py_XDECREF(ptraceback); goto bad; } __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( tstate, /*PyThreadState *tstate,*/ py_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); Py_XDECREF(py_frame); } #endif /* CIntFromPyVerify */ #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ {\ func_type value = func_value;\ if (sizeof(target_type) < sizeof(func_type)) {\ if (unlikely(value != (func_type) (target_type) value)) {\ func_type zero = 0;\ if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ return (target_type) -1;\ if (is_unsigned && unlikely(value < zero))\ goto raise_neg_overflow;\ else\ goto raise_overflow;\ }\ }\ return (target_type) value;\ } /* CIntFromPy */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(int) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (int) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) { return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) { return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) { return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(int) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) { return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; } } #endif if ((sizeof(int) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { int val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int ret = -1; #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; long idigit; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (unlikely(!PyLong_CheckExact(v))) { PyObject *tmp = v; v = PyNumber_Long(v); assert(PyLong_CheckExact(v)); Py_DECREF(tmp); if (unlikely(!v)) return (int) -1; } #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(x) == 0) return (int) 0; is_negative = Py_SIZE(x) < 0; #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (int) -1; is_negative = result == 1; } #endif if (is_unsigned && unlikely(is_negative)) { goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); if (unlikely(!stepval)) return (int) -1; } else { stepval = __Pyx_NewRef(v); } val = (int) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; val |= ((int) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(stepval) == 0) goto unpacking_done; #endif } idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((int) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 unpacking_done: #endif if (!is_unsigned) { if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif Py_DECREF(v); if (likely(!ret)) return val; } return (int) -1; } } else { int val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (int) -1; val = __Pyx_PyInt_As_int(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to int"); return (int) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to int"); return (int) -1; } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const int neg_one = (int) -1, const_zero = (int) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(int) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(int) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(int) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(int), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* CIntToPy */ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; if (is_unsigned) { if (sizeof(long) < sizeof(long)) { return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); #endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); #ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); #endif } } { int one = 1; int little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&value; #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000 return _PyLong_FromByteArray(bytes, sizeof(long), little, !is_unsigned); #else PyObject *from_bytes, *result = NULL; PyObject *py_bytes = NULL, *arg_tuple = NULL, *kwds = NULL, *order_str = NULL; from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes"); if (!from_bytes) return NULL; py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long)); if (!py_bytes) goto limited_bad; order_str = PyUnicode_FromString(little ? "little" : "big"); if (!order_str) goto limited_bad; arg_tuple = PyTuple_Pack(2, py_bytes, order_str); if (!arg_tuple) goto limited_bad; if (!is_unsigned) { kwds = PyDict_New(); if (!kwds) goto limited_bad; if (PyDict_SetItemString(kwds, "signed", __Pyx_NewRef(Py_True))) goto limited_bad; } result = PyObject_Call(from_bytes, arg_tuple, kwds); limited_bad: Py_XDECREF(kwds); Py_XDECREF(arg_tuple); Py_XDECREF(order_str); Py_XDECREF(py_bytes); Py_XDECREF(from_bytes); return result; #endif } } /* FormatTypeName */ #if CYTHON_COMPILING_IN_LIMITED_API static __Pyx_TypeName __Pyx_PyType_GetName(PyTypeObject* tp) { PyObject *name = __Pyx_PyObject_GetAttrStr((PyObject *)tp, __pyx_n_s_name); if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) { PyErr_Clear(); Py_XDECREF(name); name = __Pyx_NewRef(__pyx_n_s__37); } return name; } #endif /* CIntFromPy */ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wconversion" #endif const long neg_one = (long) -1, const_zero = (long) 0; #ifdef __Pyx_HAS_GCC_DIAGNOSTIC #pragma GCC diagnostic pop #endif const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x))) { if ((sizeof(long) < sizeof(long))) { __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) } else { long val = PyInt_AS_LONG(x); if (is_unsigned && unlikely(val < 0)) { goto raise_neg_overflow; } return (long) val; } } else #endif if (likely(PyLong_Check(x))) { if (is_unsigned) { #if CYTHON_USE_PYLONG_INTERNALS if (unlikely(__Pyx_PyLong_IsNeg(x))) { goto raise_neg_overflow; } else if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_DigitCount(x)) { case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) { return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) { return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) { return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; } } #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7 if (unlikely(Py_SIZE(x) < 0)) { goto raise_neg_overflow; } #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; if (unlikely(result == 1)) goto raise_neg_overflow; } #endif if ((sizeof(long) <= sizeof(unsigned long))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) #endif } } else { #if CYTHON_USE_PYLONG_INTERNALS if (__Pyx_PyLong_IsCompact(x)) { __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x)) } else { const digit* digits = __Pyx_PyLong_Digits(x); assert(__Pyx_PyLong_DigitCount(x) > 1); switch (__Pyx_PyLong_SignedDigitCount(x)) { case -2: if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) { if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) { __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) { return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; } } #endif if ((sizeof(long) <= sizeof(long))) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) #ifdef HAVE_LONG_LONG } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) #endif } } { long val; PyObject *v = __Pyx_PyNumber_IntOrLong(x); #if PY_MAJOR_VERSION < 3 if (likely(v) && !PyLong_Check(v)) { PyObject *tmp = v; v = PyNumber_Long(tmp); Py_DECREF(tmp); } #endif if (likely(v)) { int ret = -1; #if PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray) int one = 1; int is_little = (int)*(unsigned char *)&one; unsigned char *bytes = (unsigned char *)&val; ret = _PyLong_AsByteArray((PyLongObject *)v, bytes, sizeof(val), is_little, !is_unsigned); #else PyObject *stepval = NULL, *mask = NULL, *shift = NULL; int bits, remaining_bits, is_negative = 0; long idigit; int chunk_size = (sizeof(long) < 8) ? 30 : 62; if (unlikely(!PyLong_CheckExact(v))) { PyObject *tmp = v; v = PyNumber_Long(v); assert(PyLong_CheckExact(v)); Py_DECREF(tmp); if (unlikely(!v)) return (long) -1; } #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(x) == 0) return (long) 0; is_negative = Py_SIZE(x) < 0; #else { int result = PyObject_RichCompareBool(x, Py_False, Py_LT); if (unlikely(result < 0)) return (long) -1; is_negative = result == 1; } #endif if (is_unsigned && unlikely(is_negative)) { goto raise_neg_overflow; } else if (is_negative) { stepval = PyNumber_Invert(v); if (unlikely(!stepval)) return (long) -1; } else { stepval = __Pyx_NewRef(v); } val = (long) 0; mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done; shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done; for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) { PyObject *tmp, *digit; digit = PyNumber_And(stepval, mask); if (unlikely(!digit)) goto done; idigit = PyLong_AsLong(digit); Py_DECREF(digit); if (unlikely(idigit < 0)) goto done; tmp = PyNumber_Rshift(stepval, shift); if (unlikely(!tmp)) goto done; Py_DECREF(stepval); stepval = tmp; val |= ((long) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 if (Py_SIZE(stepval) == 0) goto unpacking_done; #endif } idigit = PyLong_AsLong(stepval); if (unlikely(idigit < 0)) goto done; remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1); if (unlikely(idigit >= (1L << remaining_bits))) goto raise_overflow; val |= ((long) idigit) << bits; #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030B0000 unpacking_done: #endif if (!is_unsigned) { if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1)))) goto raise_overflow; if (is_negative) val = ~val; } ret = 0; done: Py_XDECREF(shift); Py_XDECREF(mask); Py_XDECREF(stepval); #endif Py_DECREF(v); if (likely(!ret)) return val; } return (long) -1; } } else { long val; PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); if (!tmp) return (long) -1; val = __Pyx_PyInt_As_long(tmp); Py_DECREF(tmp); return val; } raise_overflow: PyErr_SetString(PyExc_OverflowError, "value too large to convert to long"); return (long) -1; raise_neg_overflow: PyErr_SetString(PyExc_OverflowError, "can't convert negative value to long"); return (long) -1; } /* FastTypeChecks */ #if CYTHON_COMPILING_IN_CPYTHON static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { while (a) { a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*); if (a == b) return 1; } return b == &PyBaseObject_Type; } static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (a == b) return 1; mro = a->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(a, b); } static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) { PyObject *mro; if (cls == a || cls == b) return 1; mro = cls->tp_mro; if (likely(mro)) { Py_ssize_t i, n; n = PyTuple_GET_SIZE(mro); for (i = 0; i < n; i++) { PyObject *base = PyTuple_GET_ITEM(mro, i); if (base == (PyObject *)a || base == (PyObject *)b) return 1; } return 0; } return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b); } #if PY_MAJOR_VERSION == 2 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { PyObject *exception, *value, *tb; int res; __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __Pyx_ErrFetch(&exception, &value, &tb); res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } if (!res) { res = PyObject_IsSubclass(err, exc_type2); if (unlikely(res == -1)) { PyErr_WriteUnraisable(err); res = 0; } } __Pyx_ErrRestore(exception, value, tb); return res; } #else static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { if (exc_type1) { return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2); } else { return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); } } #endif static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { Py_ssize_t i, n; assert(PyExceptionClass_Check(exc_type)); n = PyTuple_GET_SIZE(tuple); #if PY_MAJOR_VERSION >= 3 for (i=0; i= 0x030C00A2) static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) { PyObject *result = __Pyx_PyObject_CallOneArg(method, arg); Py_DECREF(method); return result; } #endif static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) { #if CYTHON_VECTORCALL && __PYX_LIMITED_VERSION_HEX >= 0x030C00A2 PyObject *args[2] = {obj, arg}; (void) __Pyx_PyObject_GetMethod; (void) __Pyx_PyObject_CallOneArg; (void) __Pyx_PyObject_Call2Args; return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL); #else PyObject *method = NULL, *result; int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method); if (likely(is_method)) { result = __Pyx_PyObject_Call2Args(method, obj, arg); Py_DECREF(method); return result; } if (unlikely(!method)) return NULL; return __Pyx__PyObject_CallMethod1(method, arg); #endif } /* CoroutineBase */ #include #if PY_VERSION_HEX >= 0x030b00a6 #ifndef Py_BUILD_CORE #define Py_BUILD_CORE 1 #endif #include "internal/pycore_frame.h" #endif #define __Pyx_Coroutine_Undelegate(gen) Py_CLEAR((gen)->yieldfrom) static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *__pyx_tstate, PyObject **pvalue) { PyObject *et, *ev, *tb; PyObject *value = NULL; CYTHON_UNUSED_VAR(__pyx_tstate); __Pyx_ErrFetch(&et, &ev, &tb); if (!et) { Py_XDECREF(tb); Py_XDECREF(ev); Py_INCREF(Py_None); *pvalue = Py_None; return 0; } if (likely(et == PyExc_StopIteration)) { if (!ev) { Py_INCREF(Py_None); value = Py_None; } #if PY_VERSION_HEX >= 0x030300A0 else if (likely(__Pyx_IS_TYPE(ev, (PyTypeObject*)PyExc_StopIteration))) { value = ((PyStopIterationObject *)ev)->value; Py_INCREF(value); Py_DECREF(ev); } #endif else if (unlikely(PyTuple_Check(ev))) { if (PyTuple_GET_SIZE(ev) >= 1) { #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS value = PyTuple_GET_ITEM(ev, 0); Py_INCREF(value); #else value = PySequence_ITEM(ev, 0); #endif } else { Py_INCREF(Py_None); value = Py_None; } Py_DECREF(ev); } else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) { value = ev; } if (likely(value)) { Py_XDECREF(tb); Py_DECREF(et); *pvalue = value; return 0; } } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) { __Pyx_ErrRestore(et, ev, tb); return -1; } PyErr_NormalizeException(&et, &ev, &tb); if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) { __Pyx_ErrRestore(et, ev, tb); return -1; } Py_XDECREF(tb); Py_DECREF(et); #if PY_VERSION_HEX >= 0x030300A0 value = ((PyStopIterationObject *)ev)->value; Py_INCREF(value); Py_DECREF(ev); #else { PyObject* args = __Pyx_PyObject_GetAttrStr(ev, __pyx_n_s_args); Py_DECREF(ev); if (likely(args)) { value = PySequence_GetItem(args, 0); Py_DECREF(args); } if (unlikely(!value)) { __Pyx_ErrRestore(NULL, NULL, NULL); Py_INCREF(Py_None); value = Py_None; } } #endif *pvalue = value; return 0; } static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) { #if PY_VERSION_HEX >= 0x030B00a4 Py_CLEAR(exc_state->exc_value); #else PyObject *t, *v, *tb; t = exc_state->exc_type; v = exc_state->exc_value; tb = exc_state->exc_traceback; exc_state->exc_type = NULL; exc_state->exc_value = NULL; exc_state->exc_traceback = NULL; Py_XDECREF(t); Py_XDECREF(v); Py_XDECREF(tb); #endif } #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL) static void __Pyx__Coroutine_AlreadyRunningError(__pyx_CoroutineObject *gen) { const char *msg; CYTHON_MAYBE_UNUSED_VAR(gen); if ((0)) { #ifdef __Pyx_Coroutine_USED } else if (__Pyx_Coroutine_Check((PyObject*)gen)) { msg = "coroutine already executing"; #endif #ifdef __Pyx_AsyncGen_USED } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) { msg = "async generator already executing"; #endif } else { msg = "generator already executing"; } PyErr_SetString(PyExc_ValueError, msg); } #define __Pyx_Coroutine_NotStartedError(gen) (__Pyx__Coroutine_NotStartedError(gen), (PyObject*)NULL) static void __Pyx__Coroutine_NotStartedError(PyObject *gen) { const char *msg; CYTHON_MAYBE_UNUSED_VAR(gen); if ((0)) { #ifdef __Pyx_Coroutine_USED } else if (__Pyx_Coroutine_Check(gen)) { msg = "can't send non-None value to a just-started coroutine"; #endif #ifdef __Pyx_AsyncGen_USED } else if (__Pyx_AsyncGen_CheckExact(gen)) { msg = "can't send non-None value to a just-started async generator"; #endif } else { msg = "can't send non-None value to a just-started generator"; } PyErr_SetString(PyExc_TypeError, msg); } #define __Pyx_Coroutine_AlreadyTerminatedError(gen, value, closing) (__Pyx__Coroutine_AlreadyTerminatedError(gen, value, closing), (PyObject*)NULL) static void __Pyx__Coroutine_AlreadyTerminatedError(PyObject *gen, PyObject *value, int closing) { CYTHON_MAYBE_UNUSED_VAR(gen); CYTHON_MAYBE_UNUSED_VAR(closing); #ifdef __Pyx_Coroutine_USED if (!closing && __Pyx_Coroutine_Check(gen)) { PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine"); } else #endif if (value) { #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(gen)) PyErr_SetNone(__Pyx_PyExc_StopAsyncIteration); else #endif PyErr_SetNone(PyExc_StopIteration); } } static PyObject *__Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, int closing) { __Pyx_PyThreadState_declare PyThreadState *tstate; __Pyx_ExcInfoStruct *exc_state; PyObject *retval; assert(!self->is_running); if (unlikely(self->resume_label == 0)) { if (unlikely(value && value != Py_None)) { return __Pyx_Coroutine_NotStartedError((PyObject*)self); } } if (unlikely(self->resume_label == -1)) { return __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing); } #if CYTHON_FAST_THREAD_STATE __Pyx_PyThreadState_assign tstate = __pyx_tstate; #else tstate = __Pyx_PyThreadState_Current; #endif exc_state = &self->gi_exc_state; if (exc_state->exc_value) { #if CYTHON_COMPILING_IN_PYPY #else PyObject *exc_tb; #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON exc_tb = PyException_GetTraceback(exc_state->exc_value); #elif PY_VERSION_HEX >= 0x030B00a4 exc_tb = ((PyBaseExceptionObject*) exc_state->exc_value)->traceback; #else exc_tb = exc_state->exc_traceback; #endif if (exc_tb) { PyTracebackObject *tb = (PyTracebackObject *) exc_tb; PyFrameObject *f = tb->tb_frame; assert(f->f_back == NULL); #if PY_VERSION_HEX >= 0x030B00A1 f->f_back = PyThreadState_GetFrame(tstate); #else Py_XINCREF(tstate->frame); f->f_back = tstate->frame; #endif #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON Py_DECREF(exc_tb); #endif } #endif } #if CYTHON_USE_EXC_INFO_STACK exc_state->previous_item = tstate->exc_info; tstate->exc_info = exc_state; #else if (exc_state->exc_type) { __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); } else { __Pyx_Coroutine_ExceptionClear(exc_state); __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback); } #endif self->is_running = 1; retval = self->body(self, tstate, value); self->is_running = 0; #if CYTHON_USE_EXC_INFO_STACK exc_state = &self->gi_exc_state; tstate->exc_info = exc_state->previous_item; exc_state->previous_item = NULL; __Pyx_Coroutine_ResetFrameBackpointer(exc_state); #endif return retval; } static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) { #if CYTHON_COMPILING_IN_PYPY CYTHON_UNUSED_VAR(exc_state); #else PyObject *exc_tb; #if PY_VERSION_HEX >= 0x030B00a4 if (!exc_state->exc_value) return; exc_tb = PyException_GetTraceback(exc_state->exc_value); #else exc_tb = exc_state->exc_traceback; #endif if (likely(exc_tb)) { PyTracebackObject *tb = (PyTracebackObject *) exc_tb; PyFrameObject *f = tb->tb_frame; Py_CLEAR(f->f_back); #if PY_VERSION_HEX >= 0x030B00a4 Py_DECREF(exc_tb); #endif } #endif } static CYTHON_INLINE PyObject *__Pyx_Coroutine_MethodReturn(PyObject* gen, PyObject *retval) { CYTHON_MAYBE_UNUSED_VAR(gen); if (unlikely(!retval)) { __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign if (!__Pyx_PyErr_Occurred()) { PyObject *exc = PyExc_StopIteration; #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(gen)) exc = __Pyx_PyExc_StopAsyncIteration; #endif __Pyx_PyErr_SetNone(exc); } } return retval; } #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) static CYTHON_INLINE PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) { #if PY_VERSION_HEX <= 0x030A00A1 return _PyGen_Send(gen, arg); #else PyObject *result; if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) { if (PyAsyncGen_CheckExact(gen)) { assert(result == Py_None); PyErr_SetNone(PyExc_StopAsyncIteration); } else if (result == Py_None) { PyErr_SetNone(PyExc_StopIteration); } else { #if PY_VERSION_HEX < 0x030d00A1 _PyGen_SetStopIterationValue(result); #else if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) { PyErr_SetObject(PyExc_StopIteration, result); } else { PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result); if (likely(exc != NULL)) { PyErr_SetObject(PyExc_StopIteration, exc); Py_DECREF(exc); } } #endif } Py_DECREF(result); result = NULL; } return result; #endif } #endif static CYTHON_INLINE PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) { PyObject *ret; PyObject *val = NULL; __Pyx_Coroutine_Undelegate(gen); __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val); ret = __Pyx_Coroutine_SendEx(gen, val, 0); Py_XDECREF(val); return ret; } static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) { PyObject *retval; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; PyObject *yf = gen->yieldfrom; if (unlikely(gen->is_running)) return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; gen->is_running = 1; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { ret = __Pyx_Coroutine_Send(yf, value); } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_Check(yf)) { ret = __Pyx_Coroutine_Send(yf, value); } else #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_PyAsyncGenASend_CheckExact(yf)) { ret = __Pyx_async_gen_asend_send(yf, value); } else #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) if (PyGen_CheckExact(yf)) { ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); } else #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03050000 && defined(PyCoro_CheckExact) && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) if (PyCoro_CheckExact(yf)) { ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value); } else #endif { if (value == Py_None) ret = __Pyx_PyObject_GetIterNextFunc(yf)(yf); else ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value); } gen->is_running = 0; if (likely(ret)) { return ret; } retval = __Pyx_Coroutine_FinishDelegation(gen); } else { retval = __Pyx_Coroutine_SendEx(gen, value, 0); } return __Pyx_Coroutine_MethodReturn(self, retval); } static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) { PyObject *retval = NULL; int err = 0; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { retval = __Pyx_Coroutine_Close(yf); if (!retval) return -1; } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_Check(yf)) { retval = __Pyx_Coroutine_Close(yf); if (!retval) return -1; } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { retval = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf, NULL); if (!retval) return -1; } else #endif #ifdef __Pyx_AsyncGen_USED if (__pyx_PyAsyncGenASend_CheckExact(yf)) { retval = __Pyx_async_gen_asend_close(yf, NULL); } else if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) { retval = __Pyx_async_gen_athrow_close(yf, NULL); } else #endif { PyObject *meth; gen->is_running = 1; meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_n_s_close); if (unlikely(!meth)) { if (unlikely(PyErr_Occurred())) { PyErr_WriteUnraisable(yf); } } else { retval = __Pyx_PyObject_CallNoArg(meth); Py_DECREF(meth); if (unlikely(!retval)) err = -1; } gen->is_running = 0; } Py_XDECREF(retval); return err; } static PyObject *__Pyx_Generator_Next(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self; PyObject *yf = gen->yieldfrom; if (unlikely(gen->is_running)) return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; gen->is_running = 1; #ifdef __Pyx_Generator_USED if (__Pyx_Generator_CheckExact(yf)) { ret = __Pyx_Generator_Next(yf); } else #endif #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03030000 && (defined(__linux__) || PY_VERSION_HEX >= 0x030600B3) if (PyGen_CheckExact(yf)) { ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL); } else #endif #ifdef __Pyx_Coroutine_USED if (__Pyx_Coroutine_Check(yf)) { ret = __Pyx_Coroutine_Send(yf, Py_None); } else #endif ret = __Pyx_PyObject_GetIterNextFunc(yf)(yf); gen->is_running = 0; if (likely(ret)) { return ret; } return __Pyx_Coroutine_FinishDelegation(gen); } return __Pyx_Coroutine_SendEx(gen, Py_None, 0); } static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, PyObject *arg) { CYTHON_UNUSED_VAR(arg); return __Pyx_Coroutine_Close(self); } static PyObject *__Pyx_Coroutine_Close(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject *retval, *raised_exception; PyObject *yf = gen->yieldfrom; int err = 0; if (unlikely(gen->is_running)) return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { Py_INCREF(yf); err = __Pyx_Coroutine_CloseIter(gen, yf); __Pyx_Coroutine_Undelegate(gen); Py_DECREF(yf); } if (err == 0) PyErr_SetNone(PyExc_GeneratorExit); retval = __Pyx_Coroutine_SendEx(gen, NULL, 1); if (unlikely(retval)) { const char *msg; Py_DECREF(retval); if ((0)) { #ifdef __Pyx_Coroutine_USED } else if (__Pyx_Coroutine_Check(self)) { msg = "coroutine ignored GeneratorExit"; #endif #ifdef __Pyx_AsyncGen_USED } else if (__Pyx_AsyncGen_CheckExact(self)) { #if PY_VERSION_HEX < 0x03060000 msg = "async generator ignored GeneratorExit - might require Python 3.6+ finalisation (PEP 525)"; #else msg = "async generator ignored GeneratorExit"; #endif #endif } else { msg = "generator ignored GeneratorExit"; } PyErr_SetString(PyExc_RuntimeError, msg); return NULL; } raised_exception = PyErr_Occurred(); if (likely(!raised_exception || __Pyx_PyErr_GivenExceptionMatches2(raised_exception, PyExc_GeneratorExit, PyExc_StopIteration))) { if (raised_exception) PyErr_Clear(); Py_INCREF(Py_None); return Py_None; } return NULL; } static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb, PyObject *args, int close_on_genexit) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject *yf = gen->yieldfrom; if (unlikely(gen->is_running)) return __Pyx_Coroutine_AlreadyRunningError(gen); if (yf) { PyObject *ret; Py_INCREF(yf); if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) { int err = __Pyx_Coroutine_CloseIter(gen, yf); Py_DECREF(yf); __Pyx_Coroutine_Undelegate(gen); if (err < 0) return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); goto throw_here; } gen->is_running = 1; if (0 #ifdef __Pyx_Generator_USED || __Pyx_Generator_CheckExact(yf) #endif #ifdef __Pyx_Coroutine_USED || __Pyx_Coroutine_Check(yf) #endif ) { ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit); #ifdef __Pyx_Coroutine_USED } else if (__Pyx_CoroutineAwait_CheckExact(yf)) { ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit); #endif } else { PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_n_s_throw); if (unlikely(!meth)) { Py_DECREF(yf); if (unlikely(PyErr_Occurred())) { gen->is_running = 0; return NULL; } __Pyx_Coroutine_Undelegate(gen); gen->is_running = 0; goto throw_here; } if (likely(args)) { ret = __Pyx_PyObject_Call(meth, args, NULL); } else { PyObject *cargs[4] = {NULL, typ, val, tb}; ret = __Pyx_PyObject_FastCall(meth, cargs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET); } Py_DECREF(meth); } gen->is_running = 0; Py_DECREF(yf); if (!ret) { ret = __Pyx_Coroutine_FinishDelegation(gen); } return __Pyx_Coroutine_MethodReturn(self, ret); } throw_here: __Pyx_Raise(typ, val, tb, NULL); return __Pyx_Coroutine_MethodReturn(self, __Pyx_Coroutine_SendEx(gen, NULL, 0)); } static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) { PyObject *typ; PyObject *val = NULL; PyObject *tb = NULL; if (unlikely(!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))) return NULL; return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1); } static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) { #if PY_VERSION_HEX >= 0x030B00a4 Py_VISIT(exc_state->exc_value); #else Py_VISIT(exc_state->exc_type); Py_VISIT(exc_state->exc_value); Py_VISIT(exc_state->exc_traceback); #endif return 0; } static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) { Py_VISIT(gen->closure); Py_VISIT(gen->classobj); Py_VISIT(gen->yieldfrom); return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg); } static int __Pyx_Coroutine_clear(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; Py_CLEAR(gen->closure); Py_CLEAR(gen->classobj); Py_CLEAR(gen->yieldfrom); __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state); #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(self)) { Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer); } #endif Py_CLEAR(gen->gi_code); Py_CLEAR(gen->gi_frame); Py_CLEAR(gen->gi_name); Py_CLEAR(gen->gi_qualname); Py_CLEAR(gen->gi_modulename); return 0; } static void __Pyx_Coroutine_dealloc(PyObject *self) { __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; PyObject_GC_UnTrack(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); if (gen->resume_label >= 0) { PyObject_GC_Track(self); #if PY_VERSION_HEX >= 0x030400a1 && CYTHON_USE_TP_FINALIZE if (unlikely(PyObject_CallFinalizerFromDealloc(self))) #else Py_TYPE(gen)->tp_del(self); if (unlikely(Py_REFCNT(self) > 0)) #endif { return; } PyObject_GC_UnTrack(self); } #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(self)) { /* We have to handle this case for asynchronous generators right here, because this code has to be between UNTRACK and GC_Del. */ Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer); } #endif __Pyx_Coroutine_clear(self); __Pyx_PyHeapTypeObject_GC_Del(gen); } static void __Pyx_Coroutine_del(PyObject *self) { PyObject *error_type, *error_value, *error_traceback; __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self; __Pyx_PyThreadState_declare if (gen->resume_label < 0) { return; } #if !CYTHON_USE_TP_FINALIZE assert(self->ob_refcnt == 0); __Pyx_SET_REFCNT(self, 1); #endif __Pyx_PyThreadState_assign __Pyx_ErrFetch(&error_type, &error_value, &error_traceback); #ifdef __Pyx_AsyncGen_USED if (__Pyx_AsyncGen_CheckExact(self)) { __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self; PyObject *finalizer = agen->ag_finalizer; if (finalizer && !agen->ag_closed) { PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self); if (unlikely(!res)) { PyErr_WriteUnraisable(self); } else { Py_DECREF(res); } __Pyx_ErrRestore(error_type, error_value, error_traceback); return; } } #endif if (unlikely(gen->resume_label == 0 && !error_value)) { #ifdef __Pyx_Coroutine_USED #ifdef __Pyx_Generator_USED if (!__Pyx_Generator_CheckExact(self)) #endif { PyObject_GC_UnTrack(self); #if PY_MAJOR_VERSION >= 3 || defined(PyErr_WarnFormat) if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0)) PyErr_WriteUnraisable(self); #else {PyObject *msg; char *cmsg; #if CYTHON_COMPILING_IN_PYPY msg = NULL; cmsg = (char*) "coroutine was never awaited"; #else char *cname; PyObject *qualname; qualname = gen->gi_qualname; cname = PyString_AS_STRING(qualname); msg = PyString_FromFormat("coroutine '%.50s' was never awaited", cname); if (unlikely(!msg)) { PyErr_Clear(); cmsg = (char*) "coroutine was never awaited"; } else { cmsg = PyString_AS_STRING(msg); } #endif if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, cmsg, 1) < 0)) PyErr_WriteUnraisable(self); Py_XDECREF(msg);} #endif PyObject_GC_Track(self); } #endif } else { PyObject *res = __Pyx_Coroutine_Close(self); if (unlikely(!res)) { if (PyErr_Occurred()) PyErr_WriteUnraisable(self); } else { Py_DECREF(res); } } __Pyx_ErrRestore(error_type, error_value, error_traceback); #if !CYTHON_USE_TP_FINALIZE assert(Py_REFCNT(self) > 0); if (likely(--self->ob_refcnt == 0)) { return; } { Py_ssize_t refcnt = Py_REFCNT(self); _Py_NewReference(self); __Pyx_SET_REFCNT(self, refcnt); } #if CYTHON_COMPILING_IN_CPYTHON assert(PyType_IS_GC(Py_TYPE(self)) && _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); _Py_DEC_REFTOTAL; #endif #ifdef COUNT_ALLOCS --Py_TYPE(self)->tp_frees; --Py_TYPE(self)->tp_allocs; #endif #endif } static PyObject * __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, void *context) { PyObject *name = self->gi_name; CYTHON_UNUSED_VAR(context); if (unlikely(!name)) name = Py_None; Py_INCREF(name); return name; } static int __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(self->gi_name, value); return 0; } static PyObject * __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, void *context) { PyObject *name = self->gi_qualname; CYTHON_UNUSED_VAR(context); if (unlikely(!name)) name = Py_None; Py_INCREF(name); return name; } static int __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, void *context) { CYTHON_UNUSED_VAR(context); #if PY_MAJOR_VERSION >= 3 if (unlikely(value == NULL || !PyUnicode_Check(value))) #else if (unlikely(value == NULL || !PyString_Check(value))) #endif { PyErr_SetString(PyExc_TypeError, "__qualname__ must be set to a string object"); return -1; } Py_INCREF(value); __Pyx_Py_XDECREF_SET(self->gi_qualname, value); return 0; } static PyObject * __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, void *context) { PyObject *frame = self->gi_frame; CYTHON_UNUSED_VAR(context); if (!frame) { if (unlikely(!self->gi_code)) { Py_RETURN_NONE; } frame = (PyObject *) PyFrame_New( PyThreadState_Get(), /*PyThreadState *tstate,*/ (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/ __pyx_d, /*PyObject *globals,*/ 0 /*PyObject *locals*/ ); if (unlikely(!frame)) return NULL; self->gi_frame = frame; } Py_INCREF(frame); return frame; } static __pyx_CoroutineObject *__Pyx__Coroutine_New( PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name) { __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type); if (unlikely(!gen)) return NULL; return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name); } static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit( __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure, PyObject *name, PyObject *qualname, PyObject *module_name) { gen->body = body; gen->closure = closure; Py_XINCREF(closure); gen->is_running = 0; gen->resume_label = 0; gen->classobj = NULL; gen->yieldfrom = NULL; #if PY_VERSION_HEX >= 0x030B00a4 gen->gi_exc_state.exc_value = NULL; #else gen->gi_exc_state.exc_type = NULL; gen->gi_exc_state.exc_value = NULL; gen->gi_exc_state.exc_traceback = NULL; #endif #if CYTHON_USE_EXC_INFO_STACK gen->gi_exc_state.previous_item = NULL; #endif gen->gi_weakreflist = NULL; Py_XINCREF(qualname); gen->gi_qualname = qualname; Py_XINCREF(name); gen->gi_name = name; Py_XINCREF(module_name); gen->gi_modulename = module_name; Py_XINCREF(code); gen->gi_code = code; gen->gi_frame = NULL; PyObject_GC_Track(gen); return gen; } /* PatchModuleWithCoroutine */ static PyObject* __Pyx_Coroutine_patch_module(PyObject* module, const char* py_code) { #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) int result; PyObject *globals, *result_obj; globals = PyDict_New(); if (unlikely(!globals)) goto ignore; result = PyDict_SetItemString(globals, "_cython_coroutine_type", #ifdef __Pyx_Coroutine_USED (PyObject*)__pyx_CoroutineType); #else Py_None); #endif if (unlikely(result < 0)) goto ignore; result = PyDict_SetItemString(globals, "_cython_generator_type", #ifdef __Pyx_Generator_USED (PyObject*)__pyx_GeneratorType); #else Py_None); #endif if (unlikely(result < 0)) goto ignore; if (unlikely(PyDict_SetItemString(globals, "_module", module) < 0)) goto ignore; if (unlikely(PyDict_SetItemString(globals, "__builtins__", __pyx_b) < 0)) goto ignore; result_obj = PyRun_String(py_code, Py_file_input, globals, globals); if (unlikely(!result_obj)) goto ignore; Py_DECREF(result_obj); Py_DECREF(globals); return module; ignore: Py_XDECREF(globals); PyErr_WriteUnraisable(module); if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, "Cython module failed to patch module with custom type", 1) < 0)) { Py_DECREF(module); module = NULL; } #else py_code++; #endif return module; } /* PatchGeneratorABC */ #ifndef CYTHON_REGISTER_ABCS #define CYTHON_REGISTER_ABCS 1 #endif #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) static PyObject* __Pyx_patch_abc_module(PyObject *module); static PyObject* __Pyx_patch_abc_module(PyObject *module) { module = __Pyx_Coroutine_patch_module( module, "" "if _cython_generator_type is not None:\n" " try: Generator = _module.Generator\n" " except AttributeError: pass\n" " else: Generator.register(_cython_generator_type)\n" "if _cython_coroutine_type is not None:\n" " try: Coroutine = _module.Coroutine\n" " except AttributeError: pass\n" " else: Coroutine.register(_cython_coroutine_type)\n" ); return module; } #endif static int __Pyx_patch_abc(void) { #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) static int abc_patched = 0; if (CYTHON_REGISTER_ABCS && !abc_patched) { PyObject *module; module = PyImport_ImportModule((PY_MAJOR_VERSION >= 3) ? "collections.abc" : "collections"); if (unlikely(!module)) { PyErr_WriteUnraisable(NULL); if (unlikely(PyErr_WarnEx(PyExc_RuntimeWarning, ((PY_MAJOR_VERSION >= 3) ? "Cython module failed to register with collections.abc module" : "Cython module failed to register with collections module"), 1) < 0)) { return -1; } } else { module = __Pyx_patch_abc_module(module); abc_patched = 1; if (unlikely(!module)) return -1; Py_DECREF(module); } module = PyImport_ImportModule("backports_abc"); if (module) { module = __Pyx_patch_abc_module(module); Py_XDECREF(module); } if (!module) { PyErr_Clear(); } } #else if ((0)) __Pyx_Coroutine_patch_module(NULL, NULL); #endif return 0; } /* Generator */ static PyMethodDef __pyx_Generator_methods[] = { {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O, (char*) PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")}, {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS, (char*) PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")}, {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, (char*) PyDoc_STR("close() -> raise GeneratorExit inside generator.")}, {0, 0, 0, 0} }; static PyMemberDef __pyx_Generator_memberlist[] = { {(char *) "gi_running", T_BOOL, offsetof(__pyx_CoroutineObject, is_running), READONLY, NULL}, {(char*) "gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY, (char*) PyDoc_STR("object being iterated by 'yield from', or None")}, {(char*) "gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL}, {(char *) "__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0}, #if CYTHON_USE_TYPE_SPECS {(char *) "__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0}, #endif {0, 0, 0, 0, 0} }; static PyGetSetDef __pyx_Generator_getsets[] = { {(char *) "__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name, (char*) PyDoc_STR("name of the generator"), 0}, {(char *) "__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname, (char*) PyDoc_STR("qualified name of the generator"), 0}, {(char *) "gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL, (char*) PyDoc_STR("Frame of the generator"), 0}, {0, 0, 0, 0, 0} }; #if CYTHON_USE_TYPE_SPECS static PyType_Slot __pyx_GeneratorType_slots[] = { {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc}, {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse}, {Py_tp_iter, (void *)PyObject_SelfIter}, {Py_tp_iternext, (void *)__Pyx_Generator_Next}, {Py_tp_methods, (void *)__pyx_Generator_methods}, {Py_tp_members, (void *)__pyx_Generator_memberlist}, {Py_tp_getset, (void *)__pyx_Generator_getsets}, {Py_tp_getattro, (void *) __Pyx_PyObject_GenericGetAttrNoDict}, #if CYTHON_USE_TP_FINALIZE {Py_tp_finalize, (void *)__Pyx_Coroutine_del}, #endif {0, 0}, }; static PyType_Spec __pyx_GeneratorType_spec = { __PYX_TYPE_MODULE_PREFIX "generator", sizeof(__pyx_CoroutineObject), 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, __pyx_GeneratorType_slots }; #else static PyTypeObject __pyx_GeneratorType_type = { PyVarObject_HEAD_INIT(0, 0) __PYX_TYPE_MODULE_PREFIX "generator", sizeof(__pyx_CoroutineObject), 0, (destructor) __Pyx_Coroutine_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, 0, (traverseproc) __Pyx_Coroutine_traverse, 0, 0, offsetof(__pyx_CoroutineObject, gi_weakreflist), 0, (iternextfunc) __Pyx_Generator_Next, __pyx_Generator_methods, __pyx_Generator_memberlist, __pyx_Generator_getsets, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, #if CYTHON_USE_TP_FINALIZE 0, #else __Pyx_Coroutine_del, #endif 0, #if CYTHON_USE_TP_FINALIZE __Pyx_Coroutine_del, #elif PY_VERSION_HEX >= 0x030400a1 0, #endif #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) 0, #endif #if __PYX_NEED_TP_PRINT_SLOT 0, #endif #if PY_VERSION_HEX >= 0x030C0000 0, #endif #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000 0, #endif }; #endif static int __pyx_Generator_init(PyObject *module) { #if CYTHON_USE_TYPE_SPECS __pyx_GeneratorType = __Pyx_FetchCommonTypeFromSpec(module, &__pyx_GeneratorType_spec, NULL); #else CYTHON_UNUSED_VAR(module); __pyx_GeneratorType_type.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter; __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type); #endif if (unlikely(!__pyx_GeneratorType)) { return -1; } return 0; } /* CheckBinaryVersion */ static unsigned long __Pyx_get_runtime_version(void) { #if __PYX_LIMITED_VERSION_HEX >= 0x030B00A4 return Py_Version & ~0xFFUL; #else const char* rt_version = Py_GetVersion(); unsigned long version = 0; unsigned long factor = 0x01000000UL; unsigned int digit = 0; int i = 0; while (factor) { while ('0' <= rt_version[i] && rt_version[i] <= '9') { digit = digit * 10 + (unsigned int) (rt_version[i] - '0'); ++i; } version += factor * digit; if (rt_version[i] != '.') break; digit = 0; factor >>= 8; ++i; } return version; #endif } static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) { const unsigned long MAJOR_MINOR = 0xFFFF0000UL; if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR)) return 0; if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR))) return 1; { char message[200]; PyOS_snprintf(message, sizeof(message), "compile time Python version %d.%d " "of module '%.100s' " "%s " "runtime version %d.%d", (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF), __Pyx_MODULE_NAME, (allow_newer) ? "was newer than" : "does not match", (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF) ); return PyErr_WarnEx(NULL, message, 1); } } /* VoidPtrImport */ #ifndef __PYX_HAVE_RT_ImportVoidPtr_3_0_9 #define __PYX_HAVE_RT_ImportVoidPtr_3_0_9 static int __Pyx_ImportVoidPtr_3_0_9(PyObject *module, const char *name, void **p, const char *sig) { PyObject *d = 0; PyObject *cobj = 0; d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); if (!d) goto bad; cobj = PyDict_GetItemString(d, name); if (!cobj) { PyErr_Format(PyExc_ImportError, "%.200s does not export expected C variable %.200s", PyModule_GetName(module), name); goto bad; } if (!PyCapsule_IsValid(cobj, sig)) { PyErr_Format(PyExc_TypeError, "C variable %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj)); goto bad; } *p = PyCapsule_GetPointer(cobj, sig); if (!(*p)) goto bad; Py_DECREF(d); return 0; bad: Py_XDECREF(d); return -1; } #endif /* FunctionImport */ #ifndef __PYX_HAVE_RT_ImportFunction_3_0_9 #define __PYX_HAVE_RT_ImportFunction_3_0_9 static int __Pyx_ImportFunction_3_0_9(PyObject *module, const char *funcname, void (**f)(void), const char *sig) { PyObject *d = 0; PyObject *cobj = 0; union { void (*fp)(void); void *p; } tmp; d = PyObject_GetAttrString(module, (char *)"__pyx_capi__"); if (!d) goto bad; cobj = PyDict_GetItemString(d, funcname); if (!cobj) { PyErr_Format(PyExc_ImportError, "%.200s does not export expected C function %.200s", PyModule_GetName(module), funcname); goto bad; } if (!PyCapsule_IsValid(cobj, sig)) { PyErr_Format(PyExc_TypeError, "C function %.200s.%.200s has wrong signature (expected %.500s, got %.500s)", PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj)); goto bad; } tmp.p = PyCapsule_GetPointer(cobj, sig); *f = tmp.fp; if (!(*f)) goto bad; Py_DECREF(d); return 0; bad: Py_XDECREF(d); return -1; } #endif /* InitStrings */ #if PY_MAJOR_VERSION >= 3 static int __Pyx_InitString(__Pyx_StringTabEntry t, PyObject **str) { if (t.is_unicode | t.is_str) { if (t.intern) { *str = PyUnicode_InternFromString(t.s); } else if (t.encoding) { *str = PyUnicode_Decode(t.s, t.n - 1, t.encoding, NULL); } else { *str = PyUnicode_FromStringAndSize(t.s, t.n - 1); } } else { *str = PyBytes_FromStringAndSize(t.s, t.n - 1); } if (!*str) return -1; if (PyObject_Hash(*str) == -1) return -1; return 0; } #endif static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION >= 3 __Pyx_InitString(*t, t->p); #else if (t->is_unicode) { *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); } else if (t->intern) { *t->p = PyString_InternFromString(t->s); } else { *t->p = PyString_FromStringAndSize(t->s, t->n - 1); } if (!*t->p) return -1; if (PyObject_Hash(*t->p) == -1) return -1; #endif ++t; } return 0; } #include static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) { size_t len = strlen(s); if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) { PyErr_SetString(PyExc_OverflowError, "byte string is too long"); return -1; } return (Py_ssize_t) len; } static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return __Pyx_PyUnicode_FromStringAndSize(c_str, len); } static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) { Py_ssize_t len = __Pyx_ssize_strlen(c_str); if (unlikely(len < 0)) return NULL; return PyByteArray_FromStringAndSize(c_str, len); } static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT #if !CYTHON_PEP393_ENABLED static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { char* defenc_c; PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); if (!defenc) return NULL; defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII { char* end = defenc_c + PyBytes_GET_SIZE(defenc); char* c; for (c = defenc_c; c < end; c++) { if ((unsigned char) (*c) >= 128) { PyUnicode_AsASCIIString(o); return NULL; } } } #endif *length = PyBytes_GET_SIZE(defenc); return defenc_c; } #else static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII if (likely(PyUnicode_IS_ASCII(o))) { *length = PyUnicode_GET_LENGTH(o); return PyUnicode_AsUTF8(o); } else { PyUnicode_AsASCIIString(o); return NULL; } #else return PyUnicode_AsUTF8AndSize(o, length); #endif } #endif #endif static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT if ( #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII __Pyx_sys_getdefaultencoding_not_ascii && #endif PyUnicode_Check(o)) { return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_LIMITED_API) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) if (PyByteArray_Check(o)) { *length = PyByteArray_GET_SIZE(o); return PyByteArray_AS_STRING(o); } else #endif { char* result; int r = PyBytes_AsStringAndSize(o, &result, length); if (unlikely(r < 0)) { return NULL; } else { return result; } } } static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { int is_true = x == Py_True; if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { int retval; if (unlikely(!x)) return -1; retval = __Pyx_PyObject_IsTrue(x); Py_DECREF(x); return retval; } static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { __Pyx_TypeName result_type_name = __Pyx_PyType_GetName(Py_TYPE(result)); #if PY_MAJOR_VERSION >= 3 if (PyLong_Check(result)) { if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). " "The ability to return an instance of a strict subclass of int is deprecated, " "and may be removed in a future version of Python.", result_type_name)) { __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } __Pyx_DECREF_TypeName(result_type_name); return result; } #endif PyErr_Format(PyExc_TypeError, "__%.4s__ returned non-%.4s (type " __Pyx_FMT_TYPENAME ")", type_name, type_name, result_type_name); __Pyx_DECREF_TypeName(result_type_name); Py_DECREF(result); return NULL; } static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { #if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; #endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_Check(x) || PyLong_Check(x))) #else if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); #if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; res = m->nb_long(x); } #else if (likely(m && m->nb_int)) { name = "int"; res = m->nb_int(x); } #endif #else if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { res = PyNumber_Int(x); } #endif if (likely(res)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else if (unlikely(!PyLong_CheckExact(res))) { #endif return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "an integer is required"); } return res; } static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_ssize_t ival; PyObject *x; #if PY_MAJOR_VERSION < 3 if (likely(PyInt_CheckExact(b))) { if (sizeof(Py_ssize_t) >= sizeof(long)) return PyInt_AS_LONG(b); else return PyInt_AsSsize_t(b); } #endif if (likely(PyLong_CheckExact(b))) { #if CYTHON_USE_PYLONG_INTERNALS if (likely(__Pyx_PyLong_IsCompact(b))) { return __Pyx_PyLong_CompactValue(b); } else { const digit* digits = __Pyx_PyLong_Digits(b); const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b); switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } } #endif return PyLong_AsSsize_t(b); } x = PyNumber_Index(b); if (!x) return -1; ival = PyInt_AsSsize_t(x); Py_DECREF(x); return ival; } static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); #if PY_MAJOR_VERSION < 3 } else if (likely(PyInt_CheckExact(o))) { return PyInt_AS_LONG(o); #endif } else { Py_ssize_t ival; PyObject *x; x = PyNumber_Index(o); if (!x) return -1; ival = PyInt_AsLong(x); Py_DECREF(x); return ival; } } static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); } static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } /* #### Code section: utility_code_pragmas_end ### */ #ifdef _MSC_VER #pragma warning( pop ) #endif /* #### Code section: end ### */ #endif /* Py_PYTHON_H */ ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/pyreadstat/pyreadstat.pxd0000644023477200000240000000145714574360757020711 0ustar00fajardoostaffs# cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710411211.0 pyreadstat-1.2.7/pyreadstat/pyreadstat.pyx0000644023477200000240000013675314574546713020744 0ustar00fajardoostaffs# cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# # TODO: ## if want to profile: # cython: profile=True import multiprocessing as mp import pandas as pd import numpy as np #from readstat_api cimport readstat_parse_sas7bdat, readstat_parse_dta, readstat_parse_sav #from readstat_api cimport readstat_parse_por, readstat_parse_xport #from readstat_api cimport readstat_parse_sas7bcat #from readstat_api cimport readstat_begin_writing_dta, readstat_begin_writing_por, readstat_begin_writing_sav from _readstat_parser cimport py_file_format, py_file_extension, run_conversion from _readstat_parser import PyreadstatError from _readstat_writer cimport run_write cimport _readstat_parser, _readstat_writer from worker import worker from pyfunctions import set_value_labels, set_catalog_to_sas # Public interface # Parsing functions def read_sas7bdat(filename_path, metadataonly=False, dates_as_pandas_datetime=False, catalog_file=None, formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): r""" Read a SAS sas7bdat file. It accepts the path to a sas7bcat. Parameters ---------- filename_path : str, bytes or Path-like object path to the file. In python 2.7 the string is assumed to be utf-8 encoded. metadataonly : bool, optional by default False. IF true, no data will be read but only metadata, so that you can get all elements in the metadata object. The data frame will be set with the correct column names but no data. dates_as_pandas_datetime : bool, optional by default False. If true dates will be transformed to pandas datetime64 instead of date. catalog_file : str, optional path to a sas7bcat file. By default is None. If not None, will parse the catalog file and replace the values by the formats in the catalog, if any appropiate is found. If this is not the behavior you are looking for, Use read_sas7bcat to parse the catalog independently of the sas7bdat and set_catalog_to_sas to apply the resulting format into sas7bdat files. formats_as_category : bool, optional Will take effect only if the catalog_file was specified. If True the variables whose values were replaced by the formats will be transformed into pandas categories. formats_as_ordered_category : bool, optional defaults to False. If True the variables having formats will be transformed into pandas ordered categories. it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of the value of formats_as_category. encoding : str, optional Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an iconv-compatible name usecols : list, optional a list with column names to read from the file. Only those columns will be imported. Case sensitive! user_missing : bool, optional by default False, in this case user defined missing values are delivered as nan. If true, the missing values will be deliver as is, and an extra piece of information will be set in the metadata (missing_user_values) to be able to interpret those values as missing. disable_datetime_conversion : bool, optional if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns will remain as numbers. In order to convert them later to an appropiate python object, the user can use the information about the original variable format stored in the metadata object in original_variable_types. Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates beyond that will rise an Overflow error in pyreadstat). row_limit : int, optional maximum number of rows to read. The default is 0 meaning unlimited. row_offset : int, optional start reading rows after this offset. By default 0, meaning start with the first row not skipping anything. output_format : str, optional one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas dataframe is avoided. extra_datetime_formats: list of str, optional formats to be parsed as python datetime objects extra_date_formats: list of str, optional formats to be parsed as python date objects Returns ------- data_frame : pandas dataframe a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly. metadata object with metadata. The members variables_value_labels will be empty unless a valid catalog file is supplied. Look at the documentation for more information. """ cdef bint metaonly = 0 if metadataonly: metaonly = 1 cdef bint dates_as_pandas = 0 if dates_as_pandas_datetime: dates_as_pandas = 1 cdef bint usernan = 0 if user_missing: usernan = 1 cdef bint no_datetime_conversion = 0 if disable_datetime_conversion: no_datetime_conversion = 1 cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAS7BDAT data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, output_format, extra_datetime_formats, extra_date_formats) metadata.file_format = "sas7bdat" if catalog_file: _ , catalog = read_sas7bcat(catalog_file, encoding=encoding) data_frame, metadata = set_catalog_to_sas(data_frame, metadata, catalog, formats_as_category=formats_as_category, formats_as_ordered_category=formats_as_ordered_category) return data_frame, metadata def read_xport(filename_path, metadataonly=False, dates_as_pandas_datetime=False, str encoding=None, list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): r""" Read a SAS xport file. Parameters ---------- filename_path : str, bytes or Path-like object path to the file. In python 2.7 the string is assumed to be utf-8 encoded metadataonly : bool, optional by default False. IF true, no data will be read but only metadata, so that you can get all elements in the metadata object. The data frame will be set with the correct column names but no data. Notice that number_rows will be None as xport files do not have the number of rows recorded in the file metadata. dates_as_pandas_datetime : bool, optional by default False. If true dates will be transformed to pandas datetime64 instead of date. encoding : str, optional Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an iconv-compatible name usecols : list, optional a list with column names to read from the file. Only those columns will be imported. Case sensitive! disable_datetime_conversion : bool, optional if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns will remain as numbers. In order to convert them later to an appropiate python object, the user can use the information about the original variable format stored in the metadata object in original_variable_types. Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates beyond that will rise an Overflow error in pyreadstat). row_limit : int, optional maximum number of rows to read. The default is 0 meaning unlimited. row_offset : int, optional start reading rows after this offset. By default 0, meaning start with the first row not skipping anything. output_format : str, optional one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas dataframe is avoided. extra_datetime_formats: list of str, optional formats to be parsed as python datetime objects extra_date_formats: list of str, optional formats to be parsed as python date objects Returns ------- data_frame : pandas dataframe a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly. metadata : object with metadata. Look at the documentation for more information. """ cdef bint metaonly = 0 if metadataonly: metaonly = 1 cdef bint dates_as_pandas = 0 if dates_as_pandas_datetime: dates_as_pandas = 1 cdef bint usernan = 0 cdef bint no_datetime_conversion = 0 if disable_datetime_conversion: no_datetime_conversion = 1 cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_XPORT data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, output_format, extra_datetime_formats, extra_date_formats) metadata.file_format = "xport" return data_frame, metadata def read_dta(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): r""" Read a STATA dta file Parameters ---------- filename_path : str, bytes or Path-like object path to the file. In Python 2.7 the string is assumed to be utf-8 encoded metadataonly : bool, optional by default False. IF true, no data will be read but only metadata, so that you can get all elements in the metadata object. The data frame will be set with the correct column names but no data. dates_as_pandas_datetime : bool, optional by default False. If true dates will be transformed to pandas datetime64 instead of date. apply_value_formats : bool, optional by default False. If true it will change values in the dataframe for they value labels in the metadata, if any appropiate are found. formats_as_category : bool, optional by default True. Takes effect only if apply_value_formats is True. If True, variables with values changed for their formatted version will be transformed into pandas categories. formats_as_ordered_category : bool, optional defaults to False. If True the variables having formats will be transformed into pandas ordered categories. it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of the value of formats_as_category. encoding : str, optional Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an iconv-compatible name usecols : list, optional a list with column names to read from the file. Only those columns will be imported. Case sensitive! user_missing : bool, optional by default False, in this case user defined missing values are delivered as nan. If true, the missing values will be deliver as is, and an extra piece of information will be set in the metadata (missing_user_values) to be able to interpret those values as missing. disable_datetime_conversion : bool, optional if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns will remain as numbers. In order to convert them later to an appropiate python object, the user can use the information about the original variable format stored in the metadata object in original_variable_types. Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates beyond that will rise an Overflow error in pyreadstat). row_limit : int, optional maximum number of rows to read. The default is 0 meaning unlimited. row_offset : int, optional start reading rows after this offset. By default 0, meaning start with the first row not skipping anything. output_format : str, optional one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas dataframe is avoided. extra_datetime_formats: list of str, optional formats to be parsed as python datetime objects extra_date_formats: list of str, optional formats to be parsed as python date objects Returns ------- data_frame : pandas dataframe a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly. metadata : object with metadata. Look at the documentation for more information. """ cdef bint metaonly = 0 if metadataonly: metaonly = 1 cdef bint dates_as_pandas = 0 if dates_as_pandas_datetime: dates_as_pandas = 1 cdef bint usernan = 0 if user_missing: usernan = 1 cdef bint no_datetime_conversion = 0 if disable_datetime_conversion: no_datetime_conversion = 1 cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_STATA cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_DTA data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, output_format, extra_datetime_formats, extra_date_formats) metadata.file_format = "dta" if apply_value_formats: data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, formats_as_ordered_category=formats_as_ordered_category) return data_frame, metadata def read_sav(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, formats_as_category=True, formats_as_ordered_category=False, str encoding=None, list usecols=None, user_missing=False, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): r""" Read a SPSS sav or zsav (compressed) files Parameters ---------- filename_path : str, bytes or Path-like object path to the file. In Python 2.7 the string is assumed to be utf-8 encoded metadataonly : bool, optional by default False. IF true, no data will be read but only metadata, so that you can get all elements in the metadata object. The data frame will be set with the correct column names but no data. dates_as_pandas_datetime : bool, optional by default False. If true dates will be transformed to pandas datetime64 instead of date. apply_value_formats : bool, optional by default False. If true it will change values in the dataframe for they value labels in the metadata, if any appropiate are found. formats_as_category : bool, optional by default True. Takes effect only if apply_value_formats is True. If True, variables with values changed for their formatted version will be transformed into pandas categories. formats_as_ordered_category : bool, optional defaults to False. If True the variables having formats will be transformed into pandas ordered categories. it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of the value of formats_as_category. encoding : str, optional Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an iconv-compatible name usecols : list, optional a list with column names to read from the file. Only those columns will be imported. Case sensitive! user_missing : bool, optional by default False, in this case user defined missing values are delivered as nan. If true, the missing values will be deliver as is, and an extra piece of information will be set in the metadata (missing_ranges) to be able to interpret those values as missing. disable_datetime_conversion : bool, optional if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns will remain as numbers. In order to convert them later to an appropiate python object, the user can use the information about the original variable format stored in the metadata object in original_variable_types. Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates beyond that will rise an Overflow error in pyreadstat). row_limit : int, optional maximum number of rows to read. The default is 0 meaning unlimited. row_offset : int, optional start reading rows after this offset. By default 0, meaning start with the first row not skipping anything. output_format : str, optional one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas dataframe is avoided. extra_datetime_formats: list of str, optional formats to be parsed as python datetime objects extra_date_formats: list of str, optional formats to be parsed as python date objects Returns ------- data_frame : pandas dataframe a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly. metadata : object with metadata. Look at the documentation for more information. """ cdef bint metaonly = 0 if metadataonly: metaonly = 1 cdef bint dates_as_pandas = 0 if dates_as_pandas_datetime: dates_as_pandas = 1 cdef bint usernan = 0 if user_missing: usernan = 1 cdef bint no_datetime_conversion = 0 if disable_datetime_conversion: no_datetime_conversion = 1 cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAV data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, output_format, extra_datetime_formats, extra_date_formats) metadata.file_format = "sav/zsav" if apply_value_formats: data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category, formats_as_ordered_category=formats_as_ordered_category) return data_frame, metadata def read_por(filename_path, metadataonly=False, dates_as_pandas_datetime=False, apply_value_formats=False, formats_as_category=True, formats_as_ordered_category=False, list usecols=None, disable_datetime_conversion=False, int row_limit=0, int row_offset=0, str output_format=None, list extra_datetime_formats=None, list extra_date_formats=None): r""" Read a SPSS por file. Files are assumed to be UTF-8 encoded, the encoding cannot be set to other. Parameters ---------- filename_path : str, bytes or Path-like object path to the file. In Python 2.7 the string is assumed to be utf-8 encoded metadataonly : bool, optional by default False. IF true, no data will be read but only metadata, so that you can get all elements in the metadata object. The data frame will be set with the correct column names but no data. Notice that number_rows will be None as por files do not have the number of rows recorded in the file metadata. dates_as_pandas_datetime : bool, optional by default False. If true dates will be transformed to pandas datetime64 instead of date. apply_value_formats : bool, optional by default False. If true it will change values in the dataframe for they value labels in the metadata, if any appropiate are found. formats_as_category : bool, optional by default True. Takes effect only if apply_value_formats is True. If True, variables with values changed for their formatted version will be transformed into pandas categories. formats_as_ordered_category : bool, optional defaults to False. If True the variables having formats will be transformed into pandas ordered categories. it has precedence over formats_as_category, meaning if this is True, it will take effect irrespective of the value of formats_as_category. usecols : list, optional a list with column names to read from the file. Only those columns will be imported. Case sensitive! disable_datetime_conversion : bool, optional if True pyreadstat will not attempt to convert dates, datetimes and times to python objects but those columns will remain as numbers. In order to convert them later to an appropiate python object, the user can use the information about the original variable format stored in the metadata object in original_variable_types. Disabling datetime conversion speeds up reading files. In addition it helps to overcome situations where there are datetimes that are beyond the limits of python datetime (which is limited to year 10,000, dates beyond that will rise an Overflow error in pyreadstat). row_limit : int, optional maximum number of rows to read. The default is 0 meaning unlimited. row_offset : int, optional start reading rows after this offset. By default 0, meaning start with the first row not skipping anything. output_format : str, optional one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned, the user can then convert it to her preferred data format. Using dict is faster as the other types as the conversion to a pandas dataframe is avoided. extra_datetime_formats: list of str, optional formats to be parsed as python datetime objects extra_date_formats: list of str, optional formats to be parsed as python date objects Returns ------- data_frame : pandas dataframe a pandas data frame with the data. If the output_format is other than 'pandas' the object type will change accordingly. metadata : object with metadata. Look at the documentation for more information. """ cdef bint metaonly = 0 if metadataonly: metaonly = 1 cdef bint dates_as_pandas = 0 if dates_as_pandas_datetime: dates_as_pandas = 1 cdef bint usernan = 0 cdef bint no_datetime_conversion = 0 if disable_datetime_conversion: no_datetime_conversion = 1 cdef str encoding = None cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SPSS cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_POR data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, output_format, extra_datetime_formats, extra_date_formats) metadata.file_format = "por" if apply_value_formats: data_frame = set_value_labels(data_frame, metadata, formats_as_category=formats_as_category) return data_frame, metadata def read_sas7bcat(filename_path, str encoding=None, str output_format=None): r""" Read a SAS sas7bcat file. The returning dataframe will be empty. The metadata object will contain a dictionary value_labels that contains the formats. When parsing the sas7bdat file, in the metadata, the dictionary variable_to_label contains a map from variable name to the formats. In order to apply the catalog to the sas7bdat file use set_catalog_to_sas or pass the catalog file as an argument to read_sas7bdat directly. SAS catalog files are difficult ones, some of them can be read only in specific SAS version, may contain strange encodings etc. Therefore it may be that many catalog files are not readable from this application. Parameters ---------- filename_path : str, bytes or Path-like object path to the file. The string is assumed to be utf-8 encoded encoding : str, optional Defaults to None. If set, the system will use the defined encoding instead of guessing it. It has to be an iconv-compatible name output_format : str, optional one of 'pandas' (default) or 'dict'. If 'dict' a dictionary with numpy arrays as values will be returned. Notice that for this function the resulting object is always empty, this is done for consistency with other functions but has no impact on performance. Returns ------- data_frame : pandas dataframe a pandas data frame with the data (no data in this case, so will be empty). If the output_parameter is other than 'pandas' then the object type will change accordingly altough the object will always be empty metadata : object with metadata. The member value_labels is the one that contains the formats. Look at the documentation for more information. """ cdef bint metaonly = 1 cdef bint dates_as_pandas = 0 cdef list usecols = None cdef bint usernan = 0 cdef bint no_datetime_conversion = 0 cdef long row_limit=0 cdef long row_offset=0 cdef list extra_datetime_formats=None cdef list extra_date_formats=None cdef py_file_format file_format = _readstat_parser.FILE_FORMAT_SAS cdef py_file_extension file_extension = _readstat_parser.FILE_EXT_SAS7BCAT data_frame, metadata = run_conversion(filename_path, file_format, file_extension, encoding, metaonly, dates_as_pandas, usecols, usernan, no_datetime_conversion, row_limit, row_offset, output_format, extra_datetime_formats, extra_date_formats) metadata.file_format = "sas7bcat" return data_frame, metadata # convenience functions to read in chunks def read_file_in_chunks(read_function, file_path, chunksize=100000, offset=0, limit=0, multiprocess=False, num_processes=4, num_rows=None, **kwargs): """ Returns a generator that will allow to read a file in chunks. If using multiprocessing, for Xport, Por and some defective sav files where the number of rows in the dataset canot be obtained from the metadata, the parameter num_rows must be set to a number equal or larger than the number of rows in the dataset. That information must be obtained by the user before running this function. Parameters ---------- read_function : pyreadstat function a pyreadstat reading function file_path : string path to the file to be read chunksize : integer, optional size of the chunks to read offset : integer, optional start reading the file after certain number of rows limit : integer, optional stop reading the file after certain number of rows, will be added to offset multiprocess: bool, optional use multiprocessing to read each chunk? num_processes: integer, optional in case multiprocess is true, how many workers/processes to spawn? num_rows: integer, optional number of rows in the dataset. If using multiprocessing it is obligatory for files where the number of rows cannot be obtained from the medatata, such as xport, por and some defective sav files. The user must obtain this value by reading the file without multiprocessing first or any other means. A number larger than the actual number of rows will work as well. Discarded if the number of rows can be obtained from the metadata or not using multiprocessing. kwargs : dict, optional any other keyword argument to pass to the read_function. row_limit and row_offset will be discarded if present. Yields ------- data_frame : pandas dataframe a pandas data frame with the data metadata : object with metadata. Look at the documentation for more information. it : generator A generator that reads the file in chunks. """ if read_function == read_sas7bcat: raise Exception("read_sas7bcat not supported") if "row_offset" in kwargs: _ = kwargs.pop("row_offset") if "row_limit" in kwargs: _ = kwargs.pop("row_limit") if "num_processes" in kwargs: _ = kwargs.pop("num_processes") _, meta = read_function(file_path, metadataonly=True) numrows = meta.number_rows if numrows: if not limit: limit = numrows else: limit = min(offset+limit, numrows) else: if limit: limit = offset + limit df = [0] while len(df): if limit and (offset >= limit): break if multiprocess: df, meta = read_file_multiprocessing(read_function, file_path, num_processes=num_processes, row_offset=offset, row_limit=chunksize, num_rows=num_rows, **kwargs) else: df, meta = read_function(file_path, row_offset=offset, row_limit=chunksize, **kwargs) if len(df): yield df, meta offset += chunksize def read_file_multiprocessing(read_function, file_path, num_processes=None, num_rows=None, **kwargs): """ Reads a file in parallel using multiprocessing. For Xport, Por and some defective sav files where the number of rows in the dataset canot be obtained from the metadata, the parameter num_rows must be set to a number equal or larger than the number of rows in the dataset. That information must be obtained by the user before running this function. Parameters ---------- read_function : pyreadstat function a pyreadstat reading function file_path : string path to the file to be read num_processes : integer, optional number of processes to spawn, by default the min 4 and the max cores on the computer num_rows: integer, optional number of rows in the dataset. Obligatory for files where the number of rows cannot be obtained from the medatata, such as xport, por and some defective sav files. The user must obtain this value by reading the file without multiprocessing first or any other means. A number larger than the actual number of rows will work as well. Discarded if the number of rows can be obtained from the metadata. kwargs : dict, optional any other keyword argument to pass to the read_function. Returns ------- data_frame : pandas dataframe a pandas data frame with the data metadata : object with metadata. Look at the documentation for more information. """ if read_function in (read_sas7bcat,): raise Exception("read_sas7bcat is not supported") if read_function in (read_xport, read_por) and num_rows is None: raise Exception("num_rows must be specified for read_xport and read_por to be a number equal or larger than the number of rows in the dataset.") if not num_processes: # let's be conservative with the number of workers num_processes = min(mp.cpu_count(), 4) _ = kwargs.pop('metadataonly', None) row_offset = kwargs.pop("row_offset", 0) row_limit = kwargs.pop("row_limit", float('inf')) _, meta = read_function(file_path, metadataonly=True, **kwargs) numrows = meta.number_rows if numrows is None: if num_rows is None: raise Exception("The number of rows of the file cannot be determined from the file's metadata. If you still want to proceed, please set num_rows to a number equal or larger than the number of rows of your data") numrows = num_rows elif numrows == 0: final, meta = read_function(file_path, **kwargs) numrows = min(max(numrows - row_offset, 0), row_limit) divs = [numrows // num_processes + (1 if x < numrows % num_processes else 0) for x in range (num_processes)] offsets = list() prev_offset = row_offset prev_div = 0 for indx, div in enumerate(divs): offset = prev_offset + prev_div prev_offset = offset prev_div = div offsets.append((offset, div)) jobs = [(read_function, file_path, offset, chunksize, kwargs) for offset, chunksize in offsets] pool = mp.Pool(processes=num_processes) try: chunks = pool.map(worker, jobs) except: raise finally: pool.close() output_format = kwargs.get("output_format") if output_format == 'dict': keys = chunks[0].keys() final = dict() for key in keys: final[key] = np.concatenate([chunk[key] for chunk in chunks]) else: final = pd.concat(chunks, axis=0, ignore_index=True) return final, meta # Write API def write_sav(df, dst_path, str file_label="", object column_labels=None, compress=False, row_compress=False, str note=None, dict variable_value_labels=None, dict missing_ranges=None, dict variable_display_width=None, dict variable_measure=None, dict variable_format=None): """ Writes a pandas data frame to a SPSS sav or zsav file. Parameters ---------- df : pandas data frame pandas data frame to write to sav or zsav dst_path : str or pathlib.Path full path to the result sav or zsav file file_label : str, optional a label for the file column_labels : list or dict, optional labels for columns (variables), if list must be the same length as the number of columns. Variables with no labels must be represented by None. If dict values must be variable names and values variable labels. In such case there is no need to include all variables; labels for non existent variables will be ignored with no warning or error. compress : boolean, optional if true a zsav will be written, by default False, a sav is written row_compress : boolean, optional if true it applies row compression, by default False, compress and row_compress cannot be both true at the same time note : str, optional a note to add to the file variable_value_labels : dict, optional value labels, a dictionary with key variable name and value a dictionary with key values and values labels. Variable names must match variable names in the dataframe otherwise will be ignored. Value types must match the type of the column in the dataframe. missing_ranges : dict, optional user defined missing values. Must be a dictionary with keys as variable names matching variable names in the dataframe. The values must be a list. Each element in that list can either be either a discrete numeric or string value (max 3 per variable) or a dictionary with keys 'hi' and 'lo' to indicate the upper and lower range for numeric values (max 1 range value + 1 discrete value per variable). hi and lo may also be the same value in which case it will be interpreted as a discrete missing value. For this to be effective, values in the dataframe must be the same as reported here and not NaN. variable_display_width : dict, optional set the display width for variables. Must be a dictonary with keys being variable names and values being integers. variable_measure: dict, optional sets the measure type for a variable. Must be a dictionary with keys being variable names and values being strings one of "nominal", "ordinal", "scale" or "unknown" (default). variable_format: dict, optional sets the format of a variable. Must be a dictionary with keys being the variable names and values being strings defining the format. See README, setting variable formats section, for more information. """ cdef int file_format_version = 2 cdef str var_width cdef bint row_compression = 0 if compress and row_compress: raise PyreadstatError("compress and row_compress cannot be both True") if compress: file_format_version = 3 if row_compress: row_compression = 1 cdef table_name = "" cdef dict missing_user_values = None cdef dict variable_alignment = None # formats formats_presets = {'restricted_integer':'N{var_width}', 'integer':'F{var_width}.0'} if variable_format: for col_name, col_format in variable_format.items(): if col_format in formats_presets.keys() and col_name in df.columns: var_width = str(len(str(max(df[col_name])))) variable_format[col_name] = formats_presets[col_format].format(var_width=var_width) run_write(df, dst_path, _readstat_writer.FILE_FORMAT_SAV, file_label, column_labels, file_format_version, note, table_name, variable_value_labels, missing_ranges, missing_user_values, variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) def write_dta(df, dst_path, str file_label="", object column_labels=None, int version=15, dict variable_value_labels=None, dict missing_user_values=None, dict variable_format=None): """ Writes a pandas data frame to a STATA dta file Parameters ---------- df : pandas data frame pandas data frame to write to sav or zsav dst_path : str or pathlib.Path full path to the result dta file file_label : str, optional a label for the file column_labels : list or dict, optional labels for columns (variables), if list must be the same length as the number of columns. Variables with no labels must be represented by None. If dict values must be variable names and values variable labels. In such case there is no need to include all variables; labels for non existent variables will be ignored with no warning or error. version : int, optional dta file version, supported from 8 to 15, default is 15 variable_value_labels : dict, optional value labels, a dictionary with key variable name and value a dictionary with key values and values labels. Variable names must match variable names in the dataframe otherwise will be ignored. Value types must match the type of the column in the dataframe. missing_user_values : dict, optional user defined missing values for numeric variables. Must be a dictionary with keys being variable names and values being a list of missing values. Missing values must be a single character between a and z. variable_format: dict, optional sets the format of a variable. Must be a dictionary with keys being the variable names and values being strings defining the format. See README, setting variable formats section, for more information. """ if version == 15: file_format_version = 119 elif version == 14: file_format_version = 118 elif version == 13: file_format_version = 117 elif version == 12: file_format_version = 115 elif version in {10, 11}: file_format_version = 114 elif version in {8, 9}: file_format_version = 113 else: raise Exception("Version not supported") cdef str note = "" cdef str table_name = "" cdef dict missing_ranges = None cdef dict variable_alignment = None cdef dict variable_display_width = None cdef dict variable_measure = None #cdef dict variable_format = None cdef bint row_compression = 0 run_write(df, dst_path, _readstat_writer.FILE_FORMAT_DTA, file_label, column_labels, file_format_version, note, table_name, variable_value_labels, missing_ranges, missing_user_values, variable_alignment, variable_display_width, variable_measure, variable_format, row_compression) def write_xport(df, dst_path, str file_label="", object column_labels=None, str table_name=None, int file_format_version = 8, dict variable_format=None): """ Writes a pandas data frame to a SAS Xport (xpt) file. If no table_name is specified the dataset has by default the name DATASET (take it into account if reading the file from SAS.) Versions 5 and 8 are supported, default is 8. Parameters ---------- df : pandas data frame pandas data frame to write to xport dst_path : str or pathlib.Path full path to the result xport file file_label : str, optional a label for the file column_labels : list or dict, optional labels for columns (variables), if list must be the same length as the number of columns. Variables with no labels must be represented by None. If dict values must be variable names and values variable labels. In such case there is no need to include all variables; labels for non existent variables will be ignored with no warning or error. table_name : str, optional name of the dataset, by default DATASET file_format_version : int, optional XPORT file version, either 8 or 5, default is 8 variable_format: dict, optional sets the format of a variable. Must be a dictionary with keys being the variable names and values being strings defining the format. See README, setting variable formats section, for more information. """ cdef dict variable_value_labels = None cdef str note = "" cdef dict missing_ranges = None cdef dict missing_user_values = None cdef dict variable_alignment = None cdef dict variable_display_width = None cdef dict variable_measure = None #cdef dict variable_format = None cdef bint row_compression = 0 run_write(df, dst_path, _readstat_writer.FILE_FORMAT_XPORT, file_label, column_labels, file_format_version, note, table_name, variable_value_labels, missing_ranges,missing_user_values, variable_alignment,variable_display_width, variable_measure, variable_format, row_compression) def write_por(df, dst_path, str file_label="", object column_labels=None, dict variable_format=None): """ Writes a pandas data frame to a SPSS POR file. Parameters ---------- df : pandas data frame pandas data frame to write to por dst_path : str or pathlib.Path full path to the result por file file_label : str, optional a label for the file column_labels : list or dict, optional labels for columns (variables), if list must be the same length as the number of columns. Variables with no labels must be represented by None. If dict values must be variable names and values variable labels. In such case there is no need to include all variables; labels for non existent variables will be ignored with no warning or error. variable_format: dict, optional sets the format of a variable. Must be a dictionary with keys being the variable names and values being strings defining the format. See README, setting variable formats section, for more information. """ # atm version 5 and 8 are supported by readstat but only 5 can be later be read by SAS cdef str note=None cdef int file_format_version = 0 cdef dict variable_value_labels=None cdef dict missing_ranges = None cdef dict missing_user_values = None cdef dict variable_alignment = None cdef dict variable_display_width = None cdef dict variable_measure = None cdef str table_name = "" #cdef dict variable_format = None cdef bint row_compression = 0 run_write(df, dst_path, _readstat_writer.FILE_FORMAT_POR, file_label, column_labels, file_format_version, note, table_name, variable_value_labels, missing_ranges,missing_user_values, variable_alignment,variable_display_width, variable_measure, variable_format, row_compression) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/pyreadstat/readstat_api.pxd0000644023477200000240000003461614574360757021174 0ustar00fajardoostaffs# cython: c_string_type=unicode, c_string_encoding=utf8, language_level=2 # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# """ These are C definitions coming from the readstat API (readstat.h) plus some dependecies of that to the C standard library """ cdef extern from "": ctypedef long off_t cdef extern from "" nogil: # 7.18.1 Integer types # 7.18.1.1 Exact-width integer types ctypedef signed char int8_t ctypedef signed short int16_t ctypedef signed int int32_t ctypedef signed long int64_t ctypedef unsigned char uint8_t #cdef extern from "conditional_includes.h": # int close(int fd) # ssize_t write(int fd, const void *buf, size_t nbyte) cdef extern from "readstat.h": ctypedef enum: READSTAT_HANDLER_OK, READSTAT_HANDLER_ABORT, READSTAT_HANDLER_SKIP_VARIABLE ctypedef struct readstat_variable_t: int index ctypedef struct readstat_label_set_t: pass ctypedef struct readstat_metadata_t: pass ctypedef enum readstat_io_flags_t: pass ctypedef enum readstat_error_t: READSTAT_OK, READSTAT_ERROR_OPEN = 1, READSTAT_ERROR_READ, READSTAT_ERROR_MALLOC, READSTAT_ERROR_USER_ABORT, READSTAT_ERROR_PARSE, READSTAT_ERROR_UNSUPPORTED_COMPRESSION, READSTAT_ERROR_UNSUPPORTED_CHARSET, READSTAT_ERROR_COLUMN_COUNT_MISMATCH, READSTAT_ERROR_ROW_COUNT_MISMATCH, READSTAT_ERROR_ROW_WIDTH_MISMATCH, READSTAT_ERROR_BAD_FORMAT_STRING, READSTAT_ERROR_VALUE_TYPE_MISMATCH, READSTAT_ERROR_WRITE, READSTAT_ERROR_WRITER_NOT_INITIALIZED, READSTAT_ERROR_SEEK, READSTAT_ERROR_CONVERT, READSTAT_ERROR_CONVERT_BAD_STRING, READSTAT_ERROR_CONVERT_SHORT_STRING, READSTAT_ERROR_CONVERT_LONG_STRING, READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE, READSTAT_ERROR_TAGGED_VALUE_IS_OUT_OF_RANGE, READSTAT_ERROR_STRING_VALUE_IS_TOO_LONG, READSTAT_ERROR_TAGGED_VALUES_NOT_SUPPORTED, READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION, READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER, READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER, READSTAT_ERROR_NAME_IS_RESERVED_WORD, READSTAT_ERROR_NAME_IS_TOO_LONG, READSTAT_ERROR_BAD_TIMESTAMP, READSTAT_ERROR_BAD_FREQUENCY_WEIGHT, READSTAT_ERROR_TOO_MANY_MISSING_VALUE_DEFINITIONS, READSTAT_ERROR_NOTE_IS_TOO_LONG, READSTAT_ERROR_STRING_REFS_NOT_SUPPORTED, READSTAT_ERROR_STRING_REF_IS_REQUIRED, READSTAT_ERROR_ROW_IS_TOO_WIDE_FOR_PAGE ctypedef enum readstat_type_t: READSTAT_TYPE_STRING, READSTAT_TYPE_INT8, READSTAT_TYPE_INT16, READSTAT_TYPE_INT32, READSTAT_TYPE_FLOAT, READSTAT_TYPE_DOUBLE, READSTAT_TYPE_STRING_REF ctypedef struct readstat_value_t: pass ctypedef struct readstat_parser_t: pass ctypedef enum readstat_measure_t: READSTAT_MEASURE_UNKNOWN, READSTAT_MEASURE_NOMINAL = 1, READSTAT_MEASURE_ORDINAL, READSTAT_MEASURE_SCALE ctypedef enum readstat_alignment_t: READSTAT_ALIGNMENT_UNKNOWN, READSTAT_ALIGNMENT_LEFT = 1, READSTAT_ALIGNMENT_CENTER, READSTAT_ALIGNMENT_RIGHT ctypedef enum readstat_compress_t: READSTAT_COMPRESS_NONE, READSTAT_COMPRESS_ROWS, READSTAT_COMPRESS_BINARY ctypedef off_t readstat_off_t cdef readstat_parser_t *readstat_parser_init() cdef void readstat_parser_free(readstat_parser_t *parser) ctypedef int (*readstat_open_handler)(const char *path, void *io_ctx); ctypedef readstat_off_t (*readstat_seek_handler)(readstat_off_t offset, readstat_io_flags_t whence, void *io_ctx); ctypedef int (*readstat_metadata_handler)(readstat_metadata_t *metadata, void *ctx); ctypedef int (*readstat_variable_handler)(int index, readstat_variable_t *variable, char *val_labels, void *ctx); ctypedef int (*readstat_value_handler)(int obs_index, readstat_variable_t *variable, readstat_value_t value, void *ctx); ctypedef int (*readstat_value_label_handler)(const char *val_labels, readstat_value_t value, const char *label, void *ctx); ctypedef int (*readstat_note_handler)(int note_index, const char *note, void *ctx); cdef readstat_error_t readstat_set_open_handler(readstat_parser_t *parser, readstat_open_handler open_handler); cdef readstat_error_t readstat_set_seek_handler(readstat_parser_t *parser, readstat_seek_handler seek_handler); cdef readstat_error_t readstat_set_metadata_handler(readstat_parser_t *parser, readstat_metadata_handler metadata_handler); cdef readstat_error_t readstat_set_note_handler(readstat_parser_t *parser, readstat_note_handler note_handler); cdef readstat_error_t readstat_set_variable_handler(readstat_parser_t *parser, readstat_variable_handler variable_handler) cdef readstat_error_t readstat_set_value_handler(readstat_parser_t *parser, readstat_value_handler value_handler); cdef readstat_error_t readstat_set_value_label_handler(readstat_parser_t *parser, readstat_value_label_handler value_label_handler); cdef readstat_error_t readstat_set_file_character_encoding(readstat_parser_t *parser, const char *encoding); cdef int readstat_get_row_count(readstat_metadata_t *metadata); cdef int readstat_get_var_count(readstat_metadata_t *metadata); cdef char *readstat_get_file_label(readstat_metadata_t *metadata); cdef char *readstat_get_file_encoding(readstat_metadata_t *metadata); cdef char *readstat_get_table_name(readstat_metadata_t *metadata); cdef int readstat_get_creation_time(readstat_metadata_t *metadata); cdef int readstat_get_modified_time(readstat_metadata_t *metadata); cdef int readstat_variable_get_index_after_skipping(readstat_variable_t *variable) cdef char *readstat_variable_get_name(readstat_variable_t *variable) cdef char *readstat_variable_get_label(readstat_variable_t *variable) cdef char *readstat_variable_get_format(readstat_variable_t *variable) cdef readstat_type_t readstat_variable_get_type(const readstat_variable_t *variable); cdef readstat_measure_t readstat_variable_get_measure(const readstat_variable_t *variable); cdef readstat_alignment_t readstat_variable_get_alignment(const readstat_variable_t *variable) cdef int readstat_variable_get_display_width(const readstat_variable_t *variable); cdef size_t readstat_variable_get_storage_width(const readstat_variable_t *variable) cdef int readstat_value_is_missing(readstat_value_t value, readstat_variable_t *variable); cdef int readstat_value_is_system_missing(readstat_value_t value); cdef int readstat_value_is_tagged_missing(readstat_value_t value); cdef int readstat_value_is_defined_missing(readstat_value_t value, readstat_variable_t *variable); cdef char readstat_value_tag(readstat_value_t value); cdef int readstat_variable_get_missing_ranges_count(const readstat_variable_t *variable); cdef readstat_value_t readstat_variable_get_missing_range_lo(const readstat_variable_t *variable, int i); cdef readstat_value_t readstat_variable_get_missing_range_hi(const readstat_variable_t *variable, int i); cdef readstat_type_t readstat_value_type(readstat_value_t value); cdef readstat_error_t readstat_set_row_limit(readstat_parser_t *parser, long row_limit); cdef readstat_error_t readstat_set_row_offset(readstat_parser_t *parser, long row_offset); cdef readstat_error_t readstat_parse_dta(readstat_parser_t *parser, const char *path, void *user_ctx); cdef readstat_error_t readstat_parse_sav(readstat_parser_t *parser, const char *path, void *user_ctx); cdef readstat_error_t readstat_parse_por(readstat_parser_t *parser, const char *path, void *user_ctx); cdef readstat_error_t readstat_parse_sas7bdat(readstat_parser_t *parser, const char *path, void *user_ctx); cdef readstat_error_t readstat_parse_sas7bcat(readstat_parser_t *parser, const char *path, void *user_ctx); cdef readstat_error_t readstat_parse_xport(readstat_parser_t *parser, const char *path, void *user_ctx); char *readstat_string_value(readstat_value_t value); char readstat_int8_value(readstat_value_t value); int16_t readstat_int16_value(readstat_value_t value); int32_t readstat_int32_value(readstat_value_t value); float readstat_float_value(readstat_value_t value); double readstat_double_value(readstat_value_t value); char *readstat_error_message(readstat_error_t error_code); # Write API ctypedef struct readstat_writer_t ctypedef ssize_t (*readstat_data_writer)(const void *data, size_t len, void *ctx) ctypedef struct readstat_string_ref_t cdef readstat_writer_t *readstat_writer_init() cdef readstat_error_t readstat_set_data_writer(readstat_writer_t *writer, readstat_data_writer data_writer) cdef readstat_label_set_t *readstat_add_label_set(readstat_writer_t *writer, readstat_type_t type, const char *name); cdef void readstat_label_double_value(readstat_label_set_t *label_set, double value, const char *label); cdef void readstat_label_int32_value(readstat_label_set_t *label_set, int32_t value, const char *label); cdef void readstat_label_string_value(readstat_label_set_t *label_set, const char *value, const char *label); cdef void readstat_label_tagged_value(readstat_label_set_t *label_set, char tag, const char *label); cdef readstat_error_t readstat_writer_set_file_label(readstat_writer_t *writer, const char *file_label); cdef readstat_error_t readstat_writer_set_file_format_version(readstat_writer_t *writer, uint8_t file_format_version) cdef readstat_error_t readstat_writer_set_compression(readstat_writer_t *writer, readstat_compress_t compression) cdef void readstat_add_note(readstat_writer_t *writer, const char *note); cdef readstat_variable_t *readstat_add_variable(readstat_writer_t *writer, const char *name, readstat_type_t type, size_t storage_width) cdef void readstat_variable_set_label(readstat_variable_t *variable, const char *label) cdef void readstat_variable_set_format(readstat_variable_t *variable, const char *format); cdef void readstat_variable_set_label_set(readstat_variable_t *variable, readstat_label_set_t *label_set); cdef void readstat_variable_set_measure(readstat_variable_t *variable, readstat_measure_t measure); cdef void readstat_variable_set_alignment(readstat_variable_t *variable, readstat_alignment_t alignment); cdef void readstat_variable_set_display_width(readstat_variable_t *variable, int display_width); cdef readstat_error_t readstat_variable_add_missing_double_value(readstat_variable_t *variable, double value); cdef readstat_error_t readstat_variable_add_missing_double_range(readstat_variable_t *variable, double lo, double hi); cdef readstat_error_t readstat_variable_add_missing_string_value(readstat_variable_t *variable, const char *value); cdef readstat_error_t readstat_variable_add_missing_string_range(readstat_variable_t *variable, const char *lo, const char *hi); cdef readstat_error_t readstat_writer_set_table_name(readstat_writer_t *writer, const char *table_name) cdef readstat_variable_t *readstat_get_variable(readstat_writer_t *writer, int index) cdef readstat_error_t readstat_begin_writing_dta(readstat_writer_t *writer, void *user_ctx, long row_count); cdef readstat_error_t readstat_begin_writing_por(readstat_writer_t *writer, void *user_ctx, long row_count); cdef readstat_error_t readstat_begin_writing_sas7bcat(readstat_writer_t *writer, void *user_ctx); cdef readstat_error_t readstat_begin_writing_sas7bdat(readstat_writer_t *writer, void *user_ctx, long row_count); cdef readstat_error_t readstat_begin_writing_sav(readstat_writer_t *writer, void *user_ctx, long row_count); cdef readstat_error_t readstat_begin_writing_xport(readstat_writer_t *writer, void *user_ctx, long row_count); cdef readstat_error_t readstat_validate_metadata(readstat_writer_t *writer) cdef readstat_error_t readstat_validate_variable(readstat_writer_t *writer, const readstat_variable_t *variable) cdef readstat_error_t readstat_begin_row(readstat_writer_t *writer); cdef readstat_error_t readstat_insert_int8_value(readstat_writer_t *writer, const readstat_variable_t *variable, int8_t value); cdef readstat_error_t readstat_insert_int16_value(readstat_writer_t *writer, const readstat_variable_t *variable, int16_t value); cdef readstat_error_t readstat_insert_int32_value(readstat_writer_t *writer, const readstat_variable_t *variable, int32_t value); cdef readstat_error_t readstat_insert_float_value(readstat_writer_t *writer, const readstat_variable_t *variable, float value); cdef readstat_error_t readstat_insert_double_value(readstat_writer_t *writer, const readstat_variable_t *variable, double value); cdef readstat_error_t readstat_insert_string_value(readstat_writer_t *writer, const readstat_variable_t *variable, const char *value); cdef readstat_error_t readstat_insert_string_ref(readstat_writer_t *writer, const readstat_variable_t *variable, readstat_string_ref_t *ref); cdef readstat_error_t readstat_insert_missing_value(readstat_writer_t *writer, const readstat_variable_t *variable); cdef readstat_error_t readstat_insert_tagged_missing_value(readstat_writer_t *writer, const readstat_variable_t *variable, char tag); cdef readstat_error_t readstat_end_row(readstat_writer_t *writer); cdef readstat_error_t readstat_end_writing(readstat_writer_t *writer); cdef void readstat_writer_free(readstat_writer_t *writer); cdef extern from "readstat_io_unistd.h": cdef struct unistd_io_ctx_t "unistd_io_ctx_s": int fd././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/pyreadstat/worker.py0000644023477200000240000000171414574360757017673 0ustar00fajardoostaffs # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# """ Functions to work with multiprocessing """ def worker(inpt): read_function, path, row_offset, row_limit, kwargs = inpt df, meta = read_function(path, row_offset=row_offset, row_limit=row_limit, **kwargs) return df ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/pyreadstat.egg-info/0000755023477200000240000000000014574564663017501 5ustar00fajardoostaffs././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418354.0 pyreadstat-1.2.7/pyreadstat.egg-info/PKG-INFO0000644023477200000240000000177314574564662020605 0ustar00fajardoostaffsMetadata-Version: 2.1 Name: pyreadstat Version: 1.2.7 Summary: Reads and Writes SAS, SPSS and Stata files into/from pandas data frames. Home-page: https://github.com/Roche/pyreadstat Download-URL: https://github.com/Roche/pyreadstat/dist Author: Otto Fajardo Author-email: pleasecontactviagithub@notvalid.com License: Apache License Version 2.0 Classifier: Programming Language :: Python Classifier: Programming Language :: Cython Classifier: Programming Language :: C Classifier: License :: OSI Approved :: Apache Software License Classifier: Intended Audience :: Science/Research Classifier: Topic :: Scientific/Engineering Classifier: Environment :: Console Description-Content-Type: text/markdown License-File: LICENSE A Python package to read and write SAS (sas7bdat, sas7bcat, xport/xpt), SPSS (sav, zsav, por) and Stata (dta) files into/from pandas data frames. It is a wrapper around the C library readstat.
Please visit out project home page for more information:
https://github.com/Roche/pyreadstat ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418354.0 pyreadstat-1.2.7/pyreadstat.egg-info/SOURCES.txt0000644023477200000240000000504714574564662021372 0ustar00fajardoostaffsLICENSE MANIFEST.in README.md pyproject.toml setup.py ./src/CKHashTable.c ./src/readstat_bits.c ./src/readstat_convert.c ./src/readstat_error.c ./src/readstat_io_unistd.c ./src/readstat_malloc.c ./src/readstat_metadata.c ./src/readstat_parser.c ./src/readstat_value.c ./src/readstat_variable.c ./src/readstat_writer.c ./src/sas/ieee.c ./src/sas/readstat_sas.c ./src/sas/readstat_sas7bcat_read.c ./src/sas/readstat_sas7bcat_write.c ./src/sas/readstat_sas7bdat_read.c ./src/sas/readstat_sas7bdat_write.c ./src/sas/readstat_sas_rle.c ./src/sas/readstat_xport.c ./src/sas/readstat_xport_parse_format.c ./src/sas/readstat_xport_read.c ./src/sas/readstat_xport_write.c ./src/spss/readstat_por.c ./src/spss/readstat_por_parse.c ./src/spss/readstat_por_read.c ./src/spss/readstat_por_write.c ./src/spss/readstat_sav.c ./src/spss/readstat_sav_compress.c ./src/spss/readstat_sav_parse.c ./src/spss/readstat_sav_parse_timestamp.c ./src/spss/readstat_sav_read.c ./src/spss/readstat_sav_write.c ./src/spss/readstat_spss.c ./src/spss/readstat_spss_parse.c ./src/spss/readstat_zsav_compress.c ./src/spss/readstat_zsav_read.c ./src/spss/readstat_zsav_write.c ./src/stata/readstat_dta.c ./src/stata/readstat_dta_parse_timestamp.c ./src/stata/readstat_dta_read.c ./src/stata/readstat_dta_write.c pyreadstat/__init__.py pyreadstat/_readstat_parser.c pyreadstat/_readstat_parser.pxd pyreadstat/_readstat_parser.pyx pyreadstat/_readstat_writer.c pyreadstat/_readstat_writer.pxd pyreadstat/_readstat_writer.pyx pyreadstat/conditional_includes.h pyreadstat/pyfunctions.py pyreadstat/pyreadstat.c pyreadstat/pyreadstat.pxd pyreadstat/pyreadstat.pyx pyreadstat/readstat_api.pxd pyreadstat/worker.py pyreadstat.egg-info/PKG-INFO pyreadstat.egg-info/SOURCES.txt pyreadstat.egg-info/dependency_links.txt pyreadstat.egg-info/requires.txt pyreadstat.egg-info/top_level.txt src/CKHashTable.h src/readstat.h src/readstat_bits.h src/readstat_convert.h src/readstat_iconv.h src/readstat_io_unistd.h src/readstat_malloc.h src/readstat_strings.h src/readstat_writer.h src/sas/ieee.h src/sas/readstat_sas.h src/sas/readstat_sas_rle.h src/sas/readstat_xport.h src/sas/readstat_xport_parse_format.h src/spss/readstat_por.h src/spss/readstat_por_parse.h src/spss/readstat_sav.h src/spss/readstat_sav_compress.h src/spss/readstat_sav_parse.h src/spss/readstat_sav_parse_timestamp.h src/spss/readstat_spss.h src/spss/readstat_spss_parse.h src/spss/readstat_zsav_compress.h src/spss/readstat_zsav_read.h src/spss/readstat_zsav_write.h src/stata/readstat_dta.h src/stata/readstat_dta_parse_timestamp.h tests/test_basic.py tests/test_version.py././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418354.0 pyreadstat-1.2.7/pyreadstat.egg-info/dependency_links.txt0000644023477200000240000000000114574564662023546 0ustar00fajardoostaffs ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418354.0 pyreadstat-1.2.7/pyreadstat.egg-info/requires.txt0000644023477200000240000000001614574564662022075 0ustar00fajardoostaffspandas>=1.2.0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418354.0 pyreadstat-1.2.7/pyreadstat.egg-info/top_level.txt0000644023477200000240000000001314574564662022224 0ustar00fajardoostaffspyreadstat ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/setup.cfg0000644023477200000240000000004614574564663015450 0ustar00fajardoostaffs[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350845.0 pyreadstat-1.2.7/setup.py0000644023477200000240000001371614574360775015347 0ustar00fajardoostaffs# ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# import setuptools from distutils.core import setup, Extension import os import sys import Cython from Cython.Build import cythonize PY_MAJOR_VERSION = sys.version_info[0] if PY_MAJOR_VERSION < 3 and os.name == 'nt': raise Exception("Python 2 is not supported on Windows.") cyver = int(Cython.__version__.split(".")[0]) if cyver < 3: msg = "Cython version 3 or newer required" raise Exception(msg) ext = '.pyx' dir_path = os.path.dirname(os.path.realpath(__file__)) source_dir_root = "src" python_dir = sys.exec_prefix # Get a list of C source files and C source directories but omitting certain things omitted_sources = [ "mod_xlsx.c", "mod_csv_reader.c", "readstat.c"] omitted_source_dirs = ["src/test", "src/bin", "src/fuzz"] sources = list() for dirname, _ , filenames in os.walk(source_dir_root): if dirname not in omitted_source_dirs: for filename in filenames: if filename.endswith("c") and filename not in omitted_sources: cursource = os.path.join(".", dirname, filename) sources.append(cursource) source_dirs = [dirname for dirname, _, _ in os.walk(source_dir_root) if dirname not in omitted_source_dirs] data_files = [] libraries = [] include_dirs = [source_dir_root] + source_dirs + ["pyreadstat", "."] library_dirs = [] # Windows # On Windows we have two possible setups: the user has included the static libraries in win_libs/64bit # Or the user is going to use the Conda forge versions of those. See the windows compilation document # for more details if os.name == 'nt': is64bit = sys.maxsize > 2 ** 32 # The user included the compiled static libraries if os.path.isfile("win_libs/64bit/libiconv-static.lib") and os.path.isfile("win_libs/64bit/libz-static.lib"): libraries.extend(["libiconv-static", "libz-static"]) include_dirs.append("win_libs/64bit") library_dirs.append("win_libs/64bit") # conda forge libraries else: libraries.extend(["iconv", "zlib"]) include_dirs.append(os.path.join(python_dir, "Library", "include")) library_dirs.append(os.path.join(python_dir, "Library", "bin")) library_dirs.append(os.path.join(python_dir, "Library", "lib")) else: libraries.extend(["m", "z"]) _platform = sys.platform # Mac: iconv needs to be linked statically if _platform.lower().startswith("darwin"): libraries.append("iconv") # Extensions sources.sort() extensions = [Extension("pyreadstat.pyreadstat", sources=["pyreadstat/pyreadstat" + ext] + sources, # this dot here is important for cython to find the pxd files include_dirs =include_dirs, libraries=libraries, library_dirs=library_dirs, extra_compile_args=["-Ireadstat", "-DHAVE_ZLIB=1"] ), Extension("pyreadstat._readstat_parser", sources=["pyreadstat/_readstat_parser" + ext] + sources, include_dirs = include_dirs, library_dirs=library_dirs, libraries=libraries, extra_compile_args=["-Ireadstat", "-DHAVE_ZLIB=1"]), Extension("pyreadstat._readstat_writer", sources=["pyreadstat/_readstat_writer" + ext] + sources, include_dirs=include_dirs,# + [numpy.get_include()], library_dirs=library_dirs, libraries=libraries, extra_compile_args=["-Ireadstat", "-DHAVE_ZLIB=1"]) ] # By setting this compiler directive, cython will # embed signature information in docstrings. Sphinx then knows how to extract # and use those signatures. for e in extensions: e.cython_directives = {"embedsignature": True} # let's use cython with force so that it always recompiles in case # somebody is switching between python 2 and 3 extensions = cythonize(extensions, compile_time_env={'PY_MAJOR_VERSION':PY_MAJOR_VERSION}, force=True) long_description = """ A Python package to read and write SAS (sas7bdat, sas7bcat, xport/xpt), SPSS (sav, zsav, por) and Stata (dta) files into/from pandas data frames. It is a wrapper around the C library readstat.
Please visit out project home page for more information:
https://github.com/Roche/pyreadstat""" short_description = "Reads and Writes SAS, SPSS and Stata files into/from pandas data frames." setup( name='pyreadstat', version='1.2.7', description=short_description, author="Otto Fajardo", author_email="pleasecontactviagithub@notvalid.com", url="https://github.com/Roche/pyreadstat", download_url="https://github.com/Roche/pyreadstat/dist", long_description=long_description, long_description_content_type="text/markdown", classifiers=[ "Programming Language :: Python", "Programming Language :: Cython", "Programming Language :: C", "License :: OSI Approved :: Apache Software License", "Intended Audience :: Science/Research", "Topic :: Scientific/Engineering", "Environment :: Console", ], ext_modules=extensions, packages=["pyreadstat"], data_files=data_files, install_requires=['pandas>=1.2.0'], license="Apache License Version 2.0", ) ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/src/0000755023477200000240000000000014574564663014416 5ustar00fajardoostaffs././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/CKHashTable.c0000644023477200000240000002132214574360757016631 0ustar00fajardoostaffs// CKHashTable - A simple hash table // Copyright 2010-2020 Evan Miller (see LICENSE) #include "CKHashTable.h" /* SipHash reference C implementation Copyright (c) 2012 Jean-Philippe Aumasson Copyright (c) 2012 Daniel J. Bernstein To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see . */ #include #include #include typedef uint64_t u64; typedef uint32_t u32; typedef uint8_t u8; #define ROTL(x,b) (u64)( ((x) << (b)) | ( (x) >> (64 - (b))) ) #define U32TO8_LE(p, v) \ (p)[0] = (u8)((v) ); (p)[1] = (u8)((v) >> 8); \ (p)[2] = (u8)((v) >> 16); (p)[3] = (u8)((v) >> 24); #define U64TO8_LE(p, v) \ U32TO8_LE((p), (u32)((v) )); \ U32TO8_LE((p) + 4, (u32)((v) >> 32)); #define U8TO64_LE(p) \ (((u64)((p)[0]) ) | \ ((u64)((p)[1]) << 8) | \ ((u64)((p)[2]) << 16) | \ ((u64)((p)[3]) << 24) | \ ((u64)((p)[4]) << 32) | \ ((u64)((p)[5]) << 40) | \ ((u64)((p)[6]) << 48) | \ ((u64)((p)[7]) << 56)) #define SIPROUND \ do { \ v0 += v1; v1=ROTL(v1,13); v1 ^= v0; v0=ROTL(v0,32); \ v2 += v3; v3=ROTL(v3,16); v3 ^= v2; \ v0 += v3; v3=ROTL(v3,21); v3 ^= v0; \ v2 += v1; v1=ROTL(v1,17); v1 ^= v2; v2=ROTL(v2,32); \ } while(0) /* SipHash-1-2 */ static int siphash( unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *k ) { /* "somepseudorandomlygeneratedbytes" */ u64 v0 = 0x736f6d6570736575ULL; u64 v1 = 0x646f72616e646f6dULL; u64 v2 = 0x6c7967656e657261ULL; u64 v3 = 0x7465646279746573ULL; u64 b; u64 k0 = U8TO64_LE( k ); u64 k1 = U8TO64_LE( k + 8 ); u64 m; const u8 *end = in + inlen - ( inlen % sizeof( u64 ) ); const int left = inlen & 7; b = ( ( u64 )inlen ) << 56; v3 ^= k1; v2 ^= k0; v1 ^= k1; v0 ^= k0; for ( ; in != end; in += 8 ) { m = U8TO64_LE( in ); v3 ^= m; SIPROUND; v0 ^= m; } switch( left ) { case 7: b |= ( ( u64 )in[ 6] ) << 48; case 6: b |= ( ( u64 )in[ 5] ) << 40; case 5: b |= ( ( u64 )in[ 4] ) << 32; case 4: b |= ( ( u64 )in[ 3] ) << 24; case 3: b |= ( ( u64 )in[ 2] ) << 16; case 2: b |= ( ( u64 )in[ 1] ) << 8; case 1: b |= ( ( u64 )in[ 0] ); break; case 0: break; } v3 ^= b; SIPROUND; v0 ^= b; v2 ^= 0xff; SIPROUND; SIPROUND; b = v0 ^ v1 ^ v2 ^ v3; U64TO8_LE( out, b ); return 0; } static uint64_t ck_hash_str(const char *str, size_t keylen) { uint64_t hash; unsigned char k[16] = { 0 }; siphash((unsigned char *)&hash, (const unsigned char *)str, keylen, k); return hash; } const void *ck_float_hash_lookup(float key, ck_hash_table_t *table) { return ck_str_n_hash_lookup((const char *)&key, sizeof(float), table); } int ck_float_hash_insert(float key, const void *value, ck_hash_table_t *table) { return ck_str_n_hash_insert((const char *)&key, sizeof(float), value, table); } const void *ck_double_hash_lookup(double key, ck_hash_table_t *table) { return ck_str_n_hash_lookup((const char *)&key, sizeof(double), table); } int ck_double_hash_insert(double key, const void *value, ck_hash_table_t *table) { return ck_str_n_hash_insert((const char *)&key, sizeof(double), value, table); } const void *ck_str_hash_lookup(const char *key, ck_hash_table_t *table) { size_t keylen = strlen(key); return ck_str_n_hash_lookup(key, keylen, table); } const void *ck_str_n_hash_lookup(const char *key, size_t keylen, ck_hash_table_t *table) { if (table->count == 0) return NULL; if (keylen == 0) return NULL; uint64_t hash_key = ck_hash_str(key, keylen); hash_key %= table->capacity; uint64_t end = hash_key; do { char *this_key = &table->keys[table->entries[hash_key].key_offset]; size_t this_keylen = table->entries[hash_key].key_length; if (this_keylen == 0) return NULL; if (this_keylen == keylen && memcmp(this_key, key, keylen) == 0) { return table->entries[hash_key].value; } hash_key++; hash_key %= table->capacity; } while (hash_key != end); return NULL; } int ck_str_hash_insert(const char *key, const void *value, ck_hash_table_t *table) { size_t keylen = strlen(key); return ck_str_n_hash_insert(key, keylen, value, table); } static int ck_hash_insert_nocopy(off_t key_offset, size_t keylen, uint64_t hash_key, const void *value, ck_hash_table_t *table) { if (table->capacity == 0) return 0; hash_key %= table->capacity; uint64_t end = (hash_key + table->capacity - 1) % table->capacity; while (hash_key != end) { ck_hash_entry_t *entry = &table->entries[hash_key]; if (table->entries[hash_key].key_length == 0) { table->count++; entry->key_offset = key_offset; entry->key_length = keylen; entry->value = value; return 1; } else if (entry->key_length == keylen && entry->key_offset == key_offset) { entry->value = value; return 1; } hash_key++; hash_key %= table->capacity; } return 0; } int ck_str_n_hash_insert(const char *key, size_t keylen, const void *value, ck_hash_table_t *table) { if (table->capacity == 0) return 0; if (keylen == 0) return 0; if (table->count >= 0.75 * table->capacity) { if (ck_hash_table_grow(table) == -1) { return 0; } } uint64_t hash_key = ck_hash_str(key, keylen); hash_key %= table->capacity; uint64_t end = hash_key; do { ck_hash_entry_t *entry = &table->entries[hash_key]; char *this_key = &table->keys[entry->key_offset]; if (entry->key_length == 0) { table->count++; while (table->keys_used + keylen > table->keys_capacity) { table->keys_capacity *= 2; table->keys = realloc(table->keys, table->keys_capacity); } memcpy(table->keys + table->keys_used, key, keylen); entry->key_offset = table->keys_used; entry->key_length = keylen; table->keys_used += keylen; entry->value = value; return 1; } else if (entry->key_length == keylen && memcmp(this_key, key, keylen) == 0) { table->entries[hash_key].value = value; return 1; } hash_key++; hash_key %= table->capacity; } while (hash_key != end); return 0; } ck_hash_table_t *ck_hash_table_init(size_t num_entries, size_t mean_key_length) { ck_hash_table_t *table; if ((table = malloc(sizeof(ck_hash_table_t))) == NULL) return NULL; if ((table->keys = malloc(num_entries * mean_key_length)) == NULL) { free(table); return NULL; } table->keys_capacity = num_entries * mean_key_length; num_entries *= 2; if ((table->entries = malloc(num_entries * sizeof(ck_hash_entry_t))) == NULL) { free(table->keys); free(table); return NULL; } table->capacity = num_entries; ck_hash_table_wipe(table); return table; } void ck_hash_table_free(ck_hash_table_t *table) { free(table->entries); if (table->keys) free(table->keys); free(table); } void ck_hash_table_wipe(ck_hash_table_t *table) { table->keys_used = 0; table->count = 0; memset(table->entries, 0, table->capacity * sizeof(ck_hash_entry_t)); } int ck_hash_table_grow(ck_hash_table_t *table) { ck_hash_entry_t *old_entries = table->entries; uint64_t old_capacity = table->capacity; uint64_t new_capacity = 2 * table->capacity; if ((table->entries = calloc(new_capacity, sizeof(ck_hash_entry_t))) == NULL) { return -1; } table->capacity = new_capacity; table->count = 0; for (int i=0; ikeys[old_entries[i].key_offset]; uint64_t hash_key = ck_hash_str(this_key, old_entries[i].key_length); if (!ck_hash_insert_nocopy(old_entries[i].key_offset, old_entries[i].key_length, hash_key, old_entries[i].value, table)) return -1; } } free(old_entries); return 0; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/CKHashTable.h0000644023477200000240000000246014574360757016640 0ustar00fajardoostaffs// CKHashTable - A simple hash table // Copyright 2010-2020 Evan Miller (see LICENSE) #include #include typedef struct ck_hash_entry_s { off_t key_offset; size_t key_length; const void *value; } ck_hash_entry_t; typedef struct ck_hash_table_s { size_t capacity; size_t count; ck_hash_entry_t *entries; char *keys; size_t keys_used; size_t keys_capacity; } ck_hash_table_t; int ck_str_hash_insert(const char *key, const void *value, ck_hash_table_t *table); const void *ck_str_hash_lookup(const char *key, ck_hash_table_t *table); int ck_str_n_hash_insert(const char *key, size_t keylen, const void *value, ck_hash_table_t *table); const void *ck_str_n_hash_lookup(const char *key, size_t keylen, ck_hash_table_t *table); int ck_float_hash_insert(float key, const void *value, ck_hash_table_t *table); const void *ck_float_hash_lookup(float key, ck_hash_table_t *table); int ck_double_hash_insert(double key, const void *value, ck_hash_table_t *table); const void *ck_double_hash_lookup(double key, ck_hash_table_t *table); ck_hash_table_t *ck_hash_table_init(size_t num_entries, size_t mean_key_length); void ck_hash_table_wipe(ck_hash_table_t *table); int ck_hash_table_grow(ck_hash_table_t *table); void ck_hash_table_free(ck_hash_table_t *table); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat.h0000644023477200000240000007022714574360757016404 0ustar00fajardoostaffs// // readstat.h - API and internal data structures for ReadStat // // Copyright Evan Miller and ReadStat authors (see LICENSE) // #ifndef INCLUDE_READSTAT_H #define INCLUDE_READSTAT_H #ifdef __cplusplus extern "C" { #endif #include #include #include #include #include enum { READSTAT_HANDLER_OK, READSTAT_HANDLER_ABORT, READSTAT_HANDLER_SKIP_VARIABLE }; typedef enum readstat_type_e { READSTAT_TYPE_STRING, READSTAT_TYPE_INT8, READSTAT_TYPE_INT16, READSTAT_TYPE_INT32, READSTAT_TYPE_FLOAT, READSTAT_TYPE_DOUBLE, READSTAT_TYPE_STRING_REF } readstat_type_t; typedef enum readstat_type_class_e { READSTAT_TYPE_CLASS_STRING, READSTAT_TYPE_CLASS_NUMERIC } readstat_type_class_t; typedef enum readstat_measure_e { READSTAT_MEASURE_UNKNOWN, READSTAT_MEASURE_NOMINAL = 1, READSTAT_MEASURE_ORDINAL, READSTAT_MEASURE_SCALE } readstat_measure_t; typedef enum readstat_alignment_e { READSTAT_ALIGNMENT_UNKNOWN, READSTAT_ALIGNMENT_LEFT = 1, READSTAT_ALIGNMENT_CENTER, READSTAT_ALIGNMENT_RIGHT } readstat_alignment_t; typedef enum readstat_compress_e { READSTAT_COMPRESS_NONE, READSTAT_COMPRESS_ROWS, READSTAT_COMPRESS_BINARY } readstat_compress_t; typedef enum readstat_endian_e { READSTAT_ENDIAN_NONE, READSTAT_ENDIAN_LITTLE, READSTAT_ENDIAN_BIG } readstat_endian_t; typedef enum readstat_error_e { READSTAT_OK, READSTAT_ERROR_OPEN = 1, READSTAT_ERROR_READ, READSTAT_ERROR_MALLOC, READSTAT_ERROR_USER_ABORT, READSTAT_ERROR_PARSE, READSTAT_ERROR_UNSUPPORTED_COMPRESSION, READSTAT_ERROR_UNSUPPORTED_CHARSET, READSTAT_ERROR_COLUMN_COUNT_MISMATCH, READSTAT_ERROR_ROW_COUNT_MISMATCH, READSTAT_ERROR_ROW_WIDTH_MISMATCH, READSTAT_ERROR_BAD_FORMAT_STRING, READSTAT_ERROR_VALUE_TYPE_MISMATCH, READSTAT_ERROR_WRITE, READSTAT_ERROR_WRITER_NOT_INITIALIZED, READSTAT_ERROR_SEEK, READSTAT_ERROR_CONVERT, READSTAT_ERROR_CONVERT_BAD_STRING, READSTAT_ERROR_CONVERT_SHORT_STRING, READSTAT_ERROR_CONVERT_LONG_STRING, READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE, READSTAT_ERROR_TAGGED_VALUE_IS_OUT_OF_RANGE, READSTAT_ERROR_STRING_VALUE_IS_TOO_LONG, READSTAT_ERROR_TAGGED_VALUES_NOT_SUPPORTED, READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION, READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER, READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER, READSTAT_ERROR_NAME_IS_RESERVED_WORD, READSTAT_ERROR_NAME_IS_TOO_LONG, READSTAT_ERROR_BAD_TIMESTAMP_STRING, READSTAT_ERROR_BAD_FREQUENCY_WEIGHT, READSTAT_ERROR_TOO_MANY_MISSING_VALUE_DEFINITIONS, READSTAT_ERROR_NOTE_IS_TOO_LONG, READSTAT_ERROR_STRING_REFS_NOT_SUPPORTED, READSTAT_ERROR_STRING_REF_IS_REQUIRED, READSTAT_ERROR_ROW_IS_TOO_WIDE_FOR_PAGE, READSTAT_ERROR_TOO_FEW_COLUMNS, READSTAT_ERROR_TOO_MANY_COLUMNS, READSTAT_ERROR_NAME_IS_ZERO_LENGTH, READSTAT_ERROR_BAD_TIMESTAMP_VALUE } readstat_error_t; const char *readstat_error_message(readstat_error_t error_code); typedef struct readstat_metadata_s { int64_t row_count; int64_t var_count; time_t creation_time; time_t modified_time; int64_t file_format_version; readstat_compress_t compression; readstat_endian_t endianness; const char *table_name; const char *file_label; const char *file_encoding; unsigned int is64bit:1; } readstat_metadata_t; /* If the row count is unknown (e.g. it's an XPORT or POR file, or an SAV * file created with non-conforming software), then readstat_get_row_count * returns -1. */ int readstat_get_row_count(readstat_metadata_t *metadata); int readstat_get_var_count(readstat_metadata_t *metadata); time_t readstat_get_creation_time(readstat_metadata_t *metadata); time_t readstat_get_modified_time(readstat_metadata_t *metadata); int readstat_get_file_format_version(readstat_metadata_t *metadata); int readstat_get_file_format_is_64bit(readstat_metadata_t *metadata); readstat_compress_t readstat_get_compression(readstat_metadata_t *metadata); readstat_endian_t readstat_get_endianness(readstat_metadata_t *metadata); const char *readstat_get_table_name(readstat_metadata_t *metadata); const char *readstat_get_file_label(readstat_metadata_t *metadata); const char *readstat_get_file_encoding(readstat_metadata_t *metadata); typedef struct readstat_value_s { union { float float_value; double double_value; int8_t i8_value; int16_t i16_value; int32_t i32_value; const char *string_value; } v; readstat_type_t type; char tag; unsigned int is_system_missing:1; unsigned int is_tagged_missing:1; } readstat_value_t; /* Internal data structures */ typedef struct readstat_value_label_s { double double_key; int32_t int32_key; char tag; char *string_key; size_t string_key_len; char *label; size_t label_len; } readstat_value_label_t; typedef struct readstat_label_set_s { readstat_type_t type; char name[256]; readstat_value_label_t *value_labels; long value_labels_count; long value_labels_capacity; void *variables; long variables_count; long variables_capacity; } readstat_label_set_t; typedef struct readstat_missingness_s { readstat_value_t missing_ranges[32]; long missing_ranges_count; } readstat_missingness_t; typedef struct readstat_variable_s { readstat_type_t type; int index; char name[300]; char format[256]; char label[1024]; readstat_label_set_t *label_set; off_t offset; size_t storage_width; size_t user_width; readstat_missingness_t missingness; readstat_measure_t measure; readstat_alignment_t alignment; int display_width; int decimals; int skip; int index_after_skipping; } readstat_variable_t; typedef struct readstat_schema_entry_s { uint32_t row; uint32_t col; uint32_t len; int skip; readstat_variable_t variable; char labelset[32]; char decimal_separator; } readstat_schema_entry_t; typedef struct readstat_schema_s { char filename[255]; uint32_t rows_per_observation; uint32_t cols_per_observation; int first_line; int entry_count; char field_delimiter; readstat_schema_entry_t *entries; } readstat_schema_t; /* Value accessors */ readstat_type_t readstat_value_type(readstat_value_t value); readstat_type_class_t readstat_value_type_class(readstat_value_t value); /* Values can be missing in one of three ways: * 1. "System missing", delivered to value handlers as NaN. Occurs in all file * types. The most common kind of missing value. * 2. Tagged missing, also delivered as NaN, but with a single character tag * accessible via readstat_value_tag(). The tag might be 'a', 'b', etc, * corresponding to Stata's .a, .b, values etc. Occurs only in Stata and * SAS files. * 3. Defined missing. The value is a real number but is to be treated as * missing according to the variable's missingness rules (such as "value < 0 || * value == 999"). Occurs only in SPSS files. access the rules via: * * readstat_variable_get_missing_ranges_count() * readstat_variable_get_missing_range_lo() * readstat_variable_get_missing_range_hi() * * Note that "ranges" include individual values where lo == hi. * * readstat_value_is_missing() is equivalent to: * * (readstat_value_is_system_missing() * || readstat_value_is_tagged_missing() * || readstat_value_is_defined_missing()) */ int readstat_value_is_missing(readstat_value_t value, readstat_variable_t *variable); int readstat_value_is_system_missing(readstat_value_t value); int readstat_value_is_tagged_missing(readstat_value_t value); int readstat_value_is_defined_missing(readstat_value_t value, readstat_variable_t *variable); char readstat_value_tag(readstat_value_t value); char readstat_int8_value(readstat_value_t value); int16_t readstat_int16_value(readstat_value_t value); int32_t readstat_int32_value(readstat_value_t value); float readstat_float_value(readstat_value_t value); double readstat_double_value(readstat_value_t value); const char *readstat_string_value(readstat_value_t value); readstat_type_class_t readstat_type_class(readstat_type_t type); /* Accessor methods for use inside variable handlers */ int readstat_variable_get_index(const readstat_variable_t *variable); int readstat_variable_get_index_after_skipping(const readstat_variable_t *variable); const char *readstat_variable_get_name(const readstat_variable_t *variable); const char *readstat_variable_get_label(const readstat_variable_t *variable); const char *readstat_variable_get_format(const readstat_variable_t *variable); readstat_type_t readstat_variable_get_type(const readstat_variable_t *variable); readstat_type_class_t readstat_variable_get_type_class(const readstat_variable_t *variable); size_t readstat_variable_get_storage_width(const readstat_variable_t *variable); int readstat_variable_get_display_width(const readstat_variable_t *variable); readstat_measure_t readstat_variable_get_measure(const readstat_variable_t *variable); readstat_alignment_t readstat_variable_get_alignment(const readstat_variable_t *variable); int readstat_variable_get_missing_ranges_count(const readstat_variable_t *variable); readstat_value_t readstat_variable_get_missing_range_lo(const readstat_variable_t *variable, int i); readstat_value_t readstat_variable_get_missing_range_hi(const readstat_variable_t *variable, int i); /* Callbacks should return 0 (aka READSTAT_HANDLER_OK) on success and 1 (aka READSTAT_HANDLER_ABORT) to abort. */ /* If the variable handler returns READSTAT_HANDLER_SKIP_VARIABLE, the value handler will not be called on * the associated variable. (Note that subsequent variables will retain their original index values.) */ typedef int (*readstat_metadata_handler)(readstat_metadata_t *metadata, void *ctx); typedef int (*readstat_note_handler)(int note_index, const char *note, void *ctx); typedef int (*readstat_variable_handler)(int index, readstat_variable_t *variable, const char *val_labels, void *ctx); typedef int (*readstat_fweight_handler)(readstat_variable_t *variable, void *ctx); typedef int (*readstat_value_handler)(int obs_index, readstat_variable_t *variable, readstat_value_t value, void *ctx); typedef int (*readstat_value_label_handler)(const char *val_labels, readstat_value_t value, const char *label, void *ctx); typedef void (*readstat_error_handler)(const char *error_message, void *ctx); typedef int (*readstat_progress_handler)(double progress, void *ctx); #if defined(_MSC_VER) #include typedef SSIZE_T ssize_t; typedef __int64 readstat_off_t; #elif defined _WIN32 || defined __CYGWIN__ typedef _off64_t readstat_off_t; #elif defined _AIX typedef off64_t readstat_off_t; #else typedef off_t readstat_off_t; #endif typedef enum readstat_io_flags_e { READSTAT_SEEK_SET, READSTAT_SEEK_CUR, READSTAT_SEEK_END } readstat_io_flags_t; typedef int (*readstat_open_handler)(const char *path, void *io_ctx); typedef int (*readstat_close_handler)(void *io_ctx); typedef readstat_off_t (*readstat_seek_handler)(readstat_off_t offset, readstat_io_flags_t whence, void *io_ctx); typedef ssize_t (*readstat_read_handler)(void *buf, size_t nbyte, void *io_ctx); typedef readstat_error_t (*readstat_update_handler)(long file_size, readstat_progress_handler progress_handler, void *user_ctx, void *io_ctx); typedef struct readstat_io_s { readstat_open_handler open; readstat_close_handler close; readstat_seek_handler seek; readstat_read_handler read; readstat_update_handler update; void *io_ctx; int io_ctx_needs_free; } readstat_io_t; typedef struct readstat_callbacks_s { readstat_metadata_handler metadata; readstat_note_handler note; readstat_variable_handler variable; readstat_fweight_handler fweight; readstat_value_handler value; readstat_value_label_handler value_label; readstat_error_handler error; readstat_progress_handler progress; } readstat_callbacks_t; typedef struct readstat_parser_s { readstat_callbacks_t handlers; readstat_io_t *io; const char *input_encoding; const char *output_encoding; long row_limit; long row_offset; } readstat_parser_t; readstat_parser_t *readstat_parser_init(void); void readstat_parser_free(readstat_parser_t *parser); void readstat_io_free(readstat_io_t *io); readstat_error_t readstat_set_metadata_handler(readstat_parser_t *parser, readstat_metadata_handler metadata_handler); readstat_error_t readstat_set_note_handler(readstat_parser_t *parser, readstat_note_handler note_handler); readstat_error_t readstat_set_variable_handler(readstat_parser_t *parser, readstat_variable_handler variable_handler); readstat_error_t readstat_set_fweight_handler(readstat_parser_t *parser, readstat_fweight_handler fweight_handler); readstat_error_t readstat_set_value_handler(readstat_parser_t *parser, readstat_value_handler value_handler); readstat_error_t readstat_set_value_label_handler(readstat_parser_t *parser, readstat_value_label_handler value_label_handler); readstat_error_t readstat_set_error_handler(readstat_parser_t *parser, readstat_error_handler error_handler); readstat_error_t readstat_set_progress_handler(readstat_parser_t *parser, readstat_progress_handler progress_handler); readstat_error_t readstat_set_open_handler(readstat_parser_t *parser, readstat_open_handler open_handler); readstat_error_t readstat_set_close_handler(readstat_parser_t *parser, readstat_close_handler close_handler); readstat_error_t readstat_set_seek_handler(readstat_parser_t *parser, readstat_seek_handler seek_handler); readstat_error_t readstat_set_read_handler(readstat_parser_t *parser, readstat_read_handler read_handler); readstat_error_t readstat_set_update_handler(readstat_parser_t *parser, readstat_update_handler update_handler); readstat_error_t readstat_set_io_ctx(readstat_parser_t *parser, void *io_ctx); // Usually inferred from the file, but sometimes a manual override is desirable. // In particular, pre-14 Stata uses the system encoding, which is usually Win 1252 // but could be anything. `encoding' should be an iconv-compatible name. readstat_error_t readstat_set_file_character_encoding(readstat_parser_t *parser, const char *encoding); // Defaults to UTF-8. Pass in NULL to disable transliteration. readstat_error_t readstat_set_handler_character_encoding(readstat_parser_t *parser, const char *encoding); readstat_error_t readstat_set_row_limit(readstat_parser_t *parser, long row_limit); readstat_error_t readstat_set_row_offset(readstat_parser_t *parser, long row_offset); /* Parse binary / portable files */ readstat_error_t readstat_parse_dta(readstat_parser_t *parser, const char *path, void *user_ctx); readstat_error_t readstat_parse_sav(readstat_parser_t *parser, const char *path, void *user_ctx); readstat_error_t readstat_parse_por(readstat_parser_t *parser, const char *path, void *user_ctx); readstat_error_t readstat_parse_sas7bdat(readstat_parser_t *parser, const char *path, void *user_ctx); readstat_error_t readstat_parse_sas7bcat(readstat_parser_t *parser, const char *path, void *user_ctx); readstat_error_t readstat_parse_xport(readstat_parser_t *parser, const char *path, void *user_ctx); /* Parse a schema file... */ readstat_schema_t *readstat_parse_sas_commands(readstat_parser_t *parser, const char *filepath, void *user_ctx, readstat_error_t *outError); readstat_schema_t *readstat_parse_spss_commands(readstat_parser_t *parser, const char *filepath, void *user_ctx, readstat_error_t *outError); readstat_schema_t *readstat_parse_stata_dictionary(readstat_parser_t *parser, const char *filepath, void *user_ctx, readstat_error_t *outError); /* ... then pass the schema to the plain-text parser ... */ readstat_error_t readstat_parse_txt(readstat_parser_t *parser, const char *filename, readstat_schema_t *schema, void *user_ctx); /* ... and free the schema structure */ void readstat_schema_free(readstat_schema_t *schema); /* Internal module callbacks */ typedef struct readstat_string_ref_s { int64_t first_v; int64_t first_o; size_t len; char data[1]; // Flexible array; using [1] for C++98 compatibility } readstat_string_ref_t; typedef size_t (*readstat_variable_width_callback)(readstat_type_t type, size_t user_width); typedef readstat_error_t (*readstat_variable_ok_callback)(const readstat_variable_t *variable); typedef readstat_error_t (*readstat_write_int8_callback)(void *row_data, const readstat_variable_t *variable, int8_t value); typedef readstat_error_t (*readstat_write_int16_callback)(void *row_data, const readstat_variable_t *variable, int16_t value); typedef readstat_error_t (*readstat_write_int32_callback)(void *row_data, const readstat_variable_t *variable, int32_t value); typedef readstat_error_t (*readstat_write_float_callback)(void *row_data, const readstat_variable_t *variable, float value); typedef readstat_error_t (*readstat_write_double_callback)(void *row_data, const readstat_variable_t *variable, double value); typedef readstat_error_t (*readstat_write_string_callback)(void *row_data, const readstat_variable_t *variable, const char *value); typedef readstat_error_t (*readstat_write_string_ref_callback)(void *row_data, const readstat_variable_t *variable, readstat_string_ref_t *ref); typedef readstat_error_t (*readstat_write_missing_callback)(void *row_data, const readstat_variable_t *variable); typedef readstat_error_t (*readstat_write_tagged_callback)(void *row_data, const readstat_variable_t *variable, char tag); typedef readstat_error_t (*readstat_begin_data_callback)(void *writer); typedef readstat_error_t (*readstat_write_row_callback)(void *writer, void *row_data, size_t row_len); typedef readstat_error_t (*readstat_end_data_callback)(void *writer); typedef void (*readstat_module_ctx_free_callback)(void *module_ctx); typedef readstat_error_t (*readstat_metadata_ok_callback)(void *writer); typedef struct readstat_writer_callbacks_s { readstat_variable_width_callback variable_width; readstat_variable_ok_callback variable_ok; readstat_write_int8_callback write_int8; readstat_write_int16_callback write_int16; readstat_write_int32_callback write_int32; readstat_write_float_callback write_float; readstat_write_double_callback write_double; readstat_write_string_callback write_string; readstat_write_string_ref_callback write_string_ref; readstat_write_missing_callback write_missing_string; readstat_write_missing_callback write_missing_number; readstat_write_tagged_callback write_missing_tagged; readstat_begin_data_callback begin_data; readstat_write_row_callback write_row; readstat_end_data_callback end_data; readstat_module_ctx_free_callback module_ctx_free; readstat_metadata_ok_callback metadata_ok; } readstat_writer_callbacks_t; /* You'll need to define one of these to get going. Should return # bytes written, * or -1 on error, a la write(2) */ typedef ssize_t (*readstat_data_writer)(const void *data, size_t len, void *ctx); typedef struct readstat_writer_s { readstat_data_writer data_writer; size_t bytes_written; long version; int is_64bit; // SAS only readstat_compress_t compression; time_t timestamp; readstat_variable_t **variables; long variables_count; long variables_capacity; readstat_label_set_t **label_sets; long label_sets_count; long label_sets_capacity; char **notes; long notes_count; long notes_capacity; readstat_string_ref_t **string_refs; long string_refs_count; long string_refs_capacity; unsigned char *row; size_t row_len; int row_count; int current_row; char file_label[257]; char table_name[33]; const readstat_variable_t *fweight_variable; readstat_writer_callbacks_t callbacks; readstat_error_handler error_handler; void *module_ctx; void *user_ctx; int initialized; } readstat_writer_t; /* Writer API */ // First call this... readstat_writer_t *readstat_writer_init(void); // Then specify a function that will handle the output bytes... readstat_error_t readstat_set_data_writer(readstat_writer_t *writer, readstat_data_writer data_writer); // Next define your value labels, if any. Create as many named sets as you'd like. readstat_label_set_t *readstat_add_label_set(readstat_writer_t *writer, readstat_type_t type, const char *name); void readstat_label_double_value(readstat_label_set_t *label_set, double value, const char *label); void readstat_label_int32_value(readstat_label_set_t *label_set, int32_t value, const char *label); void readstat_label_string_value(readstat_label_set_t *label_set, const char *value, const char *label); void readstat_label_tagged_value(readstat_label_set_t *label_set, char tag, const char *label); // Now define your variables. Note that `storage_width' is used for: // * READSTAT_TYPE_STRING variables in all formats // * READSTAT_TYPE_DOUBLE variables, but only in the SAS XPORT format (valid values 3-8, defaults to 8) readstat_variable_t *readstat_add_variable(readstat_writer_t *writer, const char *name, readstat_type_t type, size_t storage_width); void readstat_variable_set_label(readstat_variable_t *variable, const char *label); void readstat_variable_set_format(readstat_variable_t *variable, const char *format); void readstat_variable_set_label_set(readstat_variable_t *variable, readstat_label_set_t *label_set); void readstat_variable_set_measure(readstat_variable_t *variable, readstat_measure_t measure); void readstat_variable_set_alignment(readstat_variable_t *variable, readstat_alignment_t alignment); void readstat_variable_set_display_width(readstat_variable_t *variable, int display_width); readstat_error_t readstat_variable_add_missing_double_value(readstat_variable_t *variable, double value); readstat_error_t readstat_variable_add_missing_double_range(readstat_variable_t *variable, double lo, double hi); readstat_error_t readstat_variable_add_missing_string_value(readstat_variable_t *variable, const char *value); readstat_error_t readstat_variable_add_missing_string_range(readstat_variable_t *variable, const char *lo, const char *hi); readstat_variable_t *readstat_get_variable(readstat_writer_t *writer, int index); // "Notes" appear in the file metadata. In SPSS these are stored as // lines in the Document Record; in Stata these are stored using // the "notes" feature. // // Note that the line length in SPSS is 80 characters; ReadStat will // produce a write error if a note is longer than this limit. void readstat_add_note(readstat_writer_t *writer, const char *note); // String refs are used for creating a READSTAT_TYPE_STRING_REF column, // which is only supported in Stata. String references can be shared // across columns, and inserted with readstat_insert_string_ref(). readstat_string_ref_t *readstat_add_string_ref(readstat_writer_t *writer, const char *string); readstat_string_ref_t *readstat_get_string_ref(readstat_writer_t *writer, int index); // Optional metadata readstat_error_t readstat_writer_set_file_label(readstat_writer_t *writer, const char *file_label); readstat_error_t readstat_writer_set_file_timestamp(readstat_writer_t *writer, time_t timestamp); readstat_error_t readstat_writer_set_fweight_variable(readstat_writer_t *writer, const readstat_variable_t *variable); readstat_error_t readstat_writer_set_file_format_version(readstat_writer_t *writer, uint8_t file_format_version); // e.g. 104-119 for DTA; 5 or 8 for SAS Transport. // SAV files support 2 or 3, where 3 is equivalent to setting // readstat_writer_set_compression(READSTAT_COMPRESS_BINARY) readstat_error_t readstat_writer_set_table_name(readstat_writer_t *writer, const char *table_name); // Only used in XPORT files at the moment (defaults to DATASET) readstat_error_t readstat_writer_set_file_format_is_64bit(readstat_writer_t *writer, int is_64bit); // applies only to SAS files; defaults to 1=true readstat_error_t readstat_writer_set_compression(readstat_writer_t *writer, readstat_compress_t compression); // READSTAT_COMPRESS_BINARY is supported only with SAV files (i.e. ZSAV files) // READSTAT_COMPRESS_ROWS is supported only with sas7bdat and SAV files // Optional error handler readstat_error_t readstat_writer_set_error_handler(readstat_writer_t *writer, readstat_error_handler error_handler); // Call one of these at any time before the first invocation of readstat_begin_row readstat_error_t readstat_begin_writing_dta(readstat_writer_t *writer, void *user_ctx, long row_count); readstat_error_t readstat_begin_writing_por(readstat_writer_t *writer, void *user_ctx, long row_count); readstat_error_t readstat_begin_writing_sas7bcat(readstat_writer_t *writer, void *user_ctx); readstat_error_t readstat_begin_writing_sas7bdat(readstat_writer_t *writer, void *user_ctx, long row_count); readstat_error_t readstat_begin_writing_sav(readstat_writer_t *writer, void *user_ctx, long row_count); readstat_error_t readstat_begin_writing_xport(readstat_writer_t *writer, void *user_ctx, long row_count); // Optional, file-specific validation routines, to be called AFTER readstat_begin_writing_XXX readstat_error_t readstat_validate_metadata(readstat_writer_t *writer); readstat_error_t readstat_validate_variable(readstat_writer_t *writer, const readstat_variable_t *variable); // Start a row of data (that is, a case or observation) readstat_error_t readstat_begin_row(readstat_writer_t *writer); // Then call one of these for each variable readstat_error_t readstat_insert_int8_value(readstat_writer_t *writer, const readstat_variable_t *variable, int8_t value); readstat_error_t readstat_insert_int16_value(readstat_writer_t *writer, const readstat_variable_t *variable, int16_t value); readstat_error_t readstat_insert_int32_value(readstat_writer_t *writer, const readstat_variable_t *variable, int32_t value); readstat_error_t readstat_insert_float_value(readstat_writer_t *writer, const readstat_variable_t *variable, float value); readstat_error_t readstat_insert_double_value(readstat_writer_t *writer, const readstat_variable_t *variable, double value); readstat_error_t readstat_insert_string_value(readstat_writer_t *writer, const readstat_variable_t *variable, const char *value); readstat_error_t readstat_insert_string_ref(readstat_writer_t *writer, const readstat_variable_t *variable, readstat_string_ref_t *ref); readstat_error_t readstat_insert_missing_value(readstat_writer_t *writer, const readstat_variable_t *variable); readstat_error_t readstat_insert_tagged_missing_value(readstat_writer_t *writer, const readstat_variable_t *variable, char tag); // Finally, close out the row readstat_error_t readstat_end_row(readstat_writer_t *writer); // Once you've written all the rows, clean up after yourself readstat_error_t readstat_end_writing(readstat_writer_t *writer); void readstat_writer_free(readstat_writer_t *writer); #ifdef __cplusplus } #endif #endif ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_bits.c0000644023477200000240000000316514574360757017415 0ustar00fajardoostaffs// // readstat_bits.c - Bit-twiddling utility functions // #include #include #include #include "readstat_bits.h" int machine_is_little_endian() { int test_byte_order = 1; return ((char *)&test_byte_order)[0]; } char ones_to_twos_complement1(char num) { return num < 0 ? num+1 : num; } int16_t ones_to_twos_complement2(int16_t num) { return num < 0 ? num+1 : num; } int32_t ones_to_twos_complement4(int32_t num) { return num < 0 ? num+1 : num; } char twos_to_ones_complement1(char num) { return num < 0 ? num-1 : num; } int16_t twos_to_ones_complement2(int16_t num) { return num < 0 ? num-1 : num; } int32_t twos_to_ones_complement4(int32_t num) { return num < 0 ? num-1 : num; } uint16_t byteswap2(uint16_t num) { return ((num & 0xFF00) >> 8) | ((num & 0x00FF) << 8); } uint32_t byteswap4(uint32_t num) { num = ((num & 0xFFFF0000) >> 16) | ((num & 0x0000FFFF) << 16); return ((num & 0xFF00FF00) >> 8) | ((num & 0x00FF00FF) << 8); } uint64_t byteswap8(uint64_t num) { num = ((num & 0xFFFFFFFF00000000) >> 32) | ((num & 0x00000000FFFFFFFF) << 32); num = ((num & 0xFFFF0000FFFF0000) >> 16) | ((num & 0x0000FFFF0000FFFF) << 16); return ((num & 0xFF00FF00FF00FF00) >> 8) | ((num & 0x00FF00FF00FF00FF) << 8); } float byteswap_float(float num) { uint32_t answer = 0; memcpy(&answer, &num, 4); answer = byteswap4(answer); memcpy(&num, &answer, 4); return num; } double byteswap_double(double num) { uint64_t answer = 0; memcpy(&answer, &num, 8); answer = byteswap8(answer); memcpy(&num, &answer, 8); return num; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_bits.h0000644023477200000240000000106414574360757017416 0ustar00fajardoostaffs// // readstat_bit.h - Bit-twiddling utility functions // #define READSTAT_MACHINE_IS_TWOS_COMPLEMENT ((char)0xFF == (char)-1) #undef READSTAT_MACHINE_IS_TWOS_COMPLEMENT #define READSTAT_MACHINE_IS_TWOS_COMPLEMENT 0 int machine_is_little_endian(void); char ones_to_twos_complement1(char num); int16_t ones_to_twos_complement2(int16_t num); int32_t ones_to_twos_complement4(int32_t num); uint16_t byteswap2(uint16_t num); uint32_t byteswap4(uint32_t num); uint64_t byteswap8(uint64_t num); float byteswap_float(float num); double byteswap_double(double num); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_convert.c0000644023477200000240000000251214574360757020127 0ustar00fajardoostaffs #include #include "readstat.h" #include "readstat_iconv.h" #include "readstat_convert.h" readstat_error_t readstat_convert(char *dst, size_t dst_len, const char *src, size_t src_len, iconv_t converter) { /* strip off spaces from the input because the programs use ASCII space * padding even with non-ASCII encoding. */ while (src_len && (src[src_len-1] == ' ' || src[src_len-1] == '\0')) { src_len--; } if (dst_len == 0) { return READSTAT_ERROR_CONVERT_LONG_STRING; } else if (converter) { size_t dst_left = dst_len - 1; char *dst_end = dst; size_t status = iconv(converter, (readstat_iconv_inbuf_t)&src, &src_len, &dst_end, &dst_left); if (status == (size_t)-1) { if (errno == E2BIG) { return READSTAT_ERROR_CONVERT_LONG_STRING; } else if (errno == EILSEQ) { return READSTAT_ERROR_CONVERT_BAD_STRING; } else if (errno != EINVAL) { /* EINVAL indicates improper truncation; accept it */ return READSTAT_ERROR_CONVERT; } } dst[dst_len - dst_left - 1] = '\0'; } else if (src_len + 1 > dst_len) { return READSTAT_ERROR_CONVERT_LONG_STRING; } else { memcpy(dst, src, src_len); dst[src_len] = '\0'; } return READSTAT_OK; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_convert.h0000644023477200000240000000016314574360757020134 0ustar00fajardoostaffs readstat_error_t readstat_convert(char *dst, size_t dst_len, const char *src, size_t src_len, iconv_t converter); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_error.c0000644023477200000240000001216514574360757017605 0ustar00fajardoostaffs #include "readstat.h" const char *readstat_error_message(readstat_error_t error_code) { if (error_code == READSTAT_OK) return NULL; if (error_code == READSTAT_ERROR_OPEN) return "Unable to open file"; if (error_code == READSTAT_ERROR_READ) return "Unable to read from file"; if (error_code == READSTAT_ERROR_MALLOC) return "Unable to allocate memory"; if (error_code == READSTAT_ERROR_USER_ABORT) return "The parsing was aborted (callback returned non-zero value)"; if (error_code == READSTAT_ERROR_PARSE) return "Invalid file, or file has unsupported features"; if (error_code == READSTAT_ERROR_UNSUPPORTED_COMPRESSION) return "File has unsupported compression scheme"; if (error_code == READSTAT_ERROR_UNSUPPORTED_CHARSET) return "File has an unsupported character set"; if (error_code == READSTAT_ERROR_COLUMN_COUNT_MISMATCH) return "File did not contain the expected number of columns"; if (error_code == READSTAT_ERROR_ROW_COUNT_MISMATCH) return "File did not contain the expected number of rows"; if (error_code == READSTAT_ERROR_ROW_WIDTH_MISMATCH) return "A row in the file was not the expected length"; if (error_code == READSTAT_ERROR_BAD_FORMAT_STRING) return "A provided format string could not be understood"; if (error_code == READSTAT_ERROR_VALUE_TYPE_MISMATCH) return "A provided value was incompatible with the variable's declared type"; if (error_code == READSTAT_ERROR_WRITE) return "Unable to write data"; if (error_code == READSTAT_ERROR_WRITER_NOT_INITIALIZED) return "The writer object was not properly initialized (call and check return value of readstat_begin_writing_XXX)"; if (error_code == READSTAT_ERROR_SEEK) return "Unable to seek within file"; if (error_code == READSTAT_ERROR_CONVERT) return "Unable to convert string to the requested encoding"; if (error_code == READSTAT_ERROR_CONVERT_BAD_STRING) return "Unable to convert string to the requested encoding (invalid byte sequence)"; if (error_code == READSTAT_ERROR_CONVERT_SHORT_STRING) return "Unable to convert string to the requested encoding (incomplete byte sequence)"; if (error_code == READSTAT_ERROR_CONVERT_LONG_STRING) return "Unable to convert string to the requested encoding (output buffer too small)"; if (error_code == READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE) return "A provided numeric value was outside the range of representable values in the specified file format"; if (error_code == READSTAT_ERROR_TAGGED_VALUE_IS_OUT_OF_RANGE) return "A provided tag value was outside the range of allowed values in the specified file format"; if (error_code == READSTAT_ERROR_STRING_VALUE_IS_TOO_LONG) return "A provided string value was longer than the available storage size of the specified column"; if (error_code == READSTAT_ERROR_TAGGED_VALUES_NOT_SUPPORTED) return "The file format does not supported character tags for missing values"; if (error_code == READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION) return "This version of the file format is not supported"; if (error_code == READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER) return "A provided name begins with an illegal character"; if (error_code == READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER) return "A provided name contains an illegal character"; if (error_code == READSTAT_ERROR_NAME_IS_RESERVED_WORD) return "A provided name is a reserved word"; if (error_code == READSTAT_ERROR_NAME_IS_TOO_LONG) return "A provided name is too long for the file format"; if (error_code == READSTAT_ERROR_NAME_IS_ZERO_LENGTH) return "A provided name is blank or empty"; if (error_code == READSTAT_ERROR_BAD_TIMESTAMP_STRING) return "The file's timestamp string is invalid"; if (error_code == READSTAT_ERROR_BAD_FREQUENCY_WEIGHT) return "The provided variable can't be used as a frequency weight"; if (error_code == READSTAT_ERROR_TOO_MANY_MISSING_VALUE_DEFINITIONS) return "The number of defined missing values exceeds the format limit"; if (error_code == READSTAT_ERROR_NOTE_IS_TOO_LONG) return "The provided note is too long for the file format"; if (error_code == READSTAT_ERROR_STRING_REFS_NOT_SUPPORTED) return "This version of the file format does not support string references"; if (error_code == READSTAT_ERROR_STRING_REF_IS_REQUIRED) return "The provided value was not a valid string reference"; if (error_code == READSTAT_ERROR_ROW_IS_TOO_WIDE_FOR_PAGE) return "A row of data will not fit into the file format"; if (error_code == READSTAT_ERROR_TOO_FEW_COLUMNS) return "One or more columns must be provided"; if (error_code == READSTAT_ERROR_TOO_MANY_COLUMNS) return "Too many columns for this file format version"; if (error_code == READSTAT_ERROR_BAD_TIMESTAMP_VALUE) return "The provided file timestamp is invalid"; return "Unknown error"; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_iconv.h0000644023477200000240000000061714574360757017576 0ustar00fajardoostaffs#include /* ICONV_CONST defined by autotools during configure according * to the current platform. Some people copy-paste the source code, so * provide some fallback logic */ #ifndef ICONV_CONST #define ICONV_CONST #endif typedef ICONV_CONST char ** readstat_iconv_inbuf_t; typedef struct readstat_charset_entry_s { int code; char name[32]; } readstat_charset_entry_t; ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_io_unistd.c0000644023477200000240000000704414574360757020451 0ustar00fajardoostaffs #include #include #include #if defined _WIN32 # include # include #endif #if !defined(_MSC_VER) # include #else #define open _open #define read _read #define close _close #endif #if defined _WIN32 || defined __CYGWIN__ #define UNISTD_OPEN_OPTIONS O_RDONLY | O_BINARY #elif defined _AIX #define UNISTD_OPEN_OPTIONS O_RDONLY | O_LARGEFILE #else #define UNISTD_OPEN_OPTIONS O_RDONLY #endif #if defined _WIN32 #define lseek _lseeki64 #elif defined _AIX #define lseek lseek64 #endif #include "readstat.h" #include "readstat_io_unistd.h" int open_with_unicode(const char *path, int options) { #if defined _WIN32 const int buffer_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0); if(buffer_size <= 0) return -1; wchar_t* wpath = malloc((buffer_size + 1) * sizeof(wchar_t)); const int res = MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, buffer_size); wpath[buffer_size] = 0; if(res <= 0) { free(wpath); return -1; } int fd = _wopen(wpath, options); free(wpath); return fd; #else return open(path, options); #endif } int unistd_open_handler(const char *path, void *io_ctx) { int fd = open_with_unicode(path, UNISTD_OPEN_OPTIONS); ((unistd_io_ctx_t*) io_ctx)->fd = fd; return fd; } int unistd_close_handler(void *io_ctx) { int fd = ((unistd_io_ctx_t*) io_ctx)->fd; if (fd != -1) return close(fd); else return 0; } readstat_off_t unistd_seek_handler(readstat_off_t offset, readstat_io_flags_t whence, void *io_ctx) { int flag = 0; switch(whence) { case READSTAT_SEEK_SET: flag = SEEK_SET; break; case READSTAT_SEEK_CUR: flag = SEEK_CUR; break; case READSTAT_SEEK_END: flag = SEEK_END; break; default: return -1; } int fd = ((unistd_io_ctx_t*) io_ctx)->fd; return lseek(fd, offset, flag); } ssize_t unistd_read_handler(void *buf, size_t nbyte, void *io_ctx) { int fd = ((unistd_io_ctx_t*) io_ctx)->fd; ssize_t out = read(fd, buf, nbyte); return out; } readstat_error_t unistd_update_handler(long file_size, readstat_progress_handler progress_handler, void *user_ctx, void *io_ctx) { if (!progress_handler) return READSTAT_OK; int fd = ((unistd_io_ctx_t*) io_ctx)->fd; readstat_off_t current_offset = lseek(fd, 0, SEEK_CUR); if (current_offset == -1) return READSTAT_ERROR_SEEK; if (progress_handler(1.0 * current_offset / file_size, user_ctx)) return READSTAT_ERROR_USER_ABORT; return READSTAT_OK; } readstat_error_t unistd_io_init(readstat_parser_t *parser) { readstat_error_t retval = READSTAT_OK; unistd_io_ctx_t *io_ctx = NULL; if ((retval = readstat_set_open_handler(parser, unistd_open_handler)) != READSTAT_OK) return retval; if ((retval = readstat_set_close_handler(parser, unistd_close_handler)) != READSTAT_OK) return retval; if ((retval = readstat_set_seek_handler(parser, unistd_seek_handler)) != READSTAT_OK) return retval; if ((retval = readstat_set_read_handler(parser, unistd_read_handler)) != READSTAT_OK) return retval; if ((readstat_set_update_handler(parser, unistd_update_handler)) != READSTAT_OK) return retval; io_ctx = calloc(1, sizeof(unistd_io_ctx_t)); io_ctx->fd = -1; retval = readstat_set_io_ctx(parser, (void*) io_ctx); parser->io->io_ctx_needs_free = 1; return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_io_unistd.h0000644023477200000240000000103114574360757020444 0ustar00fajardoostaffs typedef struct unistd_io_ctx_s { int fd; } unistd_io_ctx_t; int unistd_open_handler(const char *path, void *io_ctx); int unistd_close_handler(void *io_ctx); readstat_off_t unistd_seek_handler(readstat_off_t offset, readstat_io_flags_t whence, void *io_ctx); ssize_t unistd_read_handler(void *buf, size_t nbytes, void *io_ctx); readstat_error_t unistd_update_handler(long file_size, readstat_progress_handler progress_handler, void *user_ctx, void *io_ctx); readstat_error_t unistd_io_init(readstat_parser_t *parser); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_malloc.c0000644023477200000240000000174514574360757017725 0ustar00fajardoostaffs#include #define MAX_MALLOC_SIZE 0x1000000 /* =16 MiB. Needs to be at least 0x3FF00, i.e. the default ~4MB block size used * in compressed SPSS (ZSAV) files. Some SAS installations use 16MiB page sizes * by default, see https://github.com/tidyverse/haven/issues/697. * The purpose here is to prevent massive allocations in the event of a * malformed file or a bug in the library. */ void *readstat_malloc(size_t len) { if (len > MAX_MALLOC_SIZE || len == 0) { return NULL; } return malloc(len); } void *readstat_calloc(size_t count, size_t size) { if (count > MAX_MALLOC_SIZE || size > MAX_MALLOC_SIZE || count * size > MAX_MALLOC_SIZE) { return NULL; } if (count == 0 || size == 0) { return NULL; } return calloc(count, size); } void *readstat_realloc(void *ptr, size_t len) { if (len > MAX_MALLOC_SIZE || len == 0) { if (ptr) free(ptr); return NULL; } return realloc(ptr, len); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_malloc.h0000644023477200000240000000020614574360757017721 0ustar00fajardoostaffs void *readstat_malloc(size_t size); void *readstat_calloc(size_t count, size_t size); void *readstat_realloc(void *ptr, size_t len); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_metadata.c0000644023477200000240000000224614574360757020233 0ustar00fajardoostaffs#include "readstat.h" int readstat_get_row_count(readstat_metadata_t *metadata) { return metadata->row_count; } int readstat_get_var_count(readstat_metadata_t *metadata) { return metadata->var_count; } time_t readstat_get_creation_time(readstat_metadata_t *metadata) { return metadata->creation_time; } time_t readstat_get_modified_time(readstat_metadata_t *metadata) { return metadata->modified_time; } int readstat_get_file_format_version(readstat_metadata_t *metadata) { return metadata->file_format_version; } int readstat_get_file_format_is_64bit(readstat_metadata_t *metadata) { return metadata->is64bit; } readstat_compress_t readstat_get_compression(readstat_metadata_t *metadata) { return metadata->compression; } readstat_endian_t readstat_get_endianness(readstat_metadata_t *metadata) { return metadata->endianness; } const char *readstat_get_file_label(readstat_metadata_t *metadata) { return metadata->file_label; } const char *readstat_get_file_encoding(readstat_metadata_t *metadata) { return metadata->file_encoding; } const char *readstat_get_table_name(readstat_metadata_t *metadata) { return metadata->table_name; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_parser.c0000644023477200000240000000754114574360757017752 0ustar00fajardoostaffs #include #include "readstat.h" #include "readstat_io_unistd.h" readstat_parser_t *readstat_parser_init() { readstat_parser_t *parser = calloc(1, sizeof(readstat_parser_t)); parser->io = calloc(1, sizeof(readstat_io_t)); if (unistd_io_init(parser) != READSTAT_OK) { readstat_parser_free(parser); return NULL; } parser->output_encoding = "UTF-8"; return parser; } void readstat_parser_free(readstat_parser_t *parser) { if (parser) { if (parser->io) { readstat_set_io_ctx(parser, NULL); free(parser->io); } free(parser); } } readstat_error_t readstat_set_metadata_handler(readstat_parser_t *parser, readstat_metadata_handler metadata_handler) { parser->handlers.metadata = metadata_handler; return READSTAT_OK; } readstat_error_t readstat_set_note_handler(readstat_parser_t *parser, readstat_note_handler note_handler) { parser->handlers.note = note_handler; return READSTAT_OK; } readstat_error_t readstat_set_variable_handler(readstat_parser_t *parser, readstat_variable_handler variable_handler) { parser->handlers.variable = variable_handler; return READSTAT_OK; } readstat_error_t readstat_set_value_handler(readstat_parser_t *parser, readstat_value_handler value_handler) { parser->handlers.value = value_handler; return READSTAT_OK; } readstat_error_t readstat_set_value_label_handler(readstat_parser_t *parser, readstat_value_label_handler label_handler) { parser->handlers.value_label = label_handler; return READSTAT_OK; } readstat_error_t readstat_set_error_handler(readstat_parser_t *parser, readstat_error_handler error_handler) { parser->handlers.error = error_handler; return READSTAT_OK; } readstat_error_t readstat_set_progress_handler(readstat_parser_t *parser, readstat_progress_handler progress_handler) { parser->handlers.progress = progress_handler; return READSTAT_OK; } readstat_error_t readstat_set_fweight_handler(readstat_parser_t *parser, readstat_fweight_handler fweight_handler) { parser->handlers.fweight = fweight_handler; return READSTAT_OK; } readstat_error_t readstat_set_open_handler(readstat_parser_t *parser, readstat_open_handler open_handler) { parser->io->open = open_handler; return READSTAT_OK; } readstat_error_t readstat_set_close_handler(readstat_parser_t *parser, readstat_close_handler close_handler) { parser->io->close = close_handler; return READSTAT_OK; } readstat_error_t readstat_set_seek_handler(readstat_parser_t *parser, readstat_seek_handler seek_handler) { parser->io->seek = seek_handler; return READSTAT_OK; } readstat_error_t readstat_set_read_handler(readstat_parser_t *parser, readstat_read_handler read_handler) { parser->io->read = read_handler; return READSTAT_OK; } readstat_error_t readstat_set_update_handler(readstat_parser_t *parser, readstat_update_handler update_handler) { parser->io->update = update_handler; return READSTAT_OK; } readstat_error_t readstat_set_io_ctx(readstat_parser_t *parser, void *io_ctx) { if (parser->io->io_ctx_needs_free) { free(parser->io->io_ctx); } parser->io->io_ctx = io_ctx; parser->io->io_ctx_needs_free = 0; return READSTAT_OK; } readstat_error_t readstat_set_file_character_encoding(readstat_parser_t *parser, const char *encoding) { parser->input_encoding = encoding; return READSTAT_OK; } readstat_error_t readstat_set_handler_character_encoding(readstat_parser_t *parser, const char *encoding) { parser->output_encoding = encoding; return READSTAT_OK; } readstat_error_t readstat_set_row_limit(readstat_parser_t *parser, long row_limit) { parser->row_limit = row_limit; return READSTAT_OK; } readstat_error_t readstat_set_row_offset(readstat_parser_t *parser, long row_offset) { parser->row_offset = row_offset; return READSTAT_OK; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_strings.h0000644023477200000240000000017314574360757020146 0ustar00fajardoostaffs#if defined(_MSC_VER) # define strncasecmp _strnicmp # define strcasecmp _stricmp #else # include #endif ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_value.c0000644023477200000240000001270314574360757017566 0ustar00fajardoostaffs #include "readstat.h" readstat_type_class_t readstat_type_class(readstat_type_t type) { if (type == READSTAT_TYPE_STRING || type == READSTAT_TYPE_STRING_REF) return READSTAT_TYPE_CLASS_STRING; return READSTAT_TYPE_CLASS_NUMERIC; } readstat_type_t readstat_value_type(readstat_value_t value) { return value.type; } readstat_type_class_t readstat_value_type_class(readstat_value_t value) { return readstat_type_class(value.type); } char readstat_value_tag(readstat_value_t value) { return value.tag; } int readstat_value_is_missing(readstat_value_t value, readstat_variable_t *variable) { if (value.is_system_missing || value.is_tagged_missing) return 1; if (variable) return readstat_value_is_defined_missing(value, variable); return 0; } int readstat_value_is_system_missing(readstat_value_t value) { return (value.is_system_missing); } int readstat_value_is_tagged_missing(readstat_value_t value) { return (value.is_tagged_missing); } static int readstat_double_is_defined_missing(double fp_value, readstat_variable_t *variable) { int count = readstat_variable_get_missing_ranges_count(variable); int i; for (i=0; i= lo && fp_value <= hi) { return 1; } } return 0; } static int readstat_string_is_defined_missing(const char *string, readstat_variable_t *variable) { if (string == NULL) return 0; int count = readstat_variable_get_missing_ranges_count(variable); int i; for (i=0; i= 0 && strcmp(string, hi) <= 0) { return 1; } } return 0; } int readstat_value_is_defined_missing(readstat_value_t value, readstat_variable_t *variable) { if (readstat_value_type_class(value) != readstat_variable_get_type_class(variable)) return 0; if (readstat_value_type_class(value) == READSTAT_TYPE_CLASS_STRING) return readstat_string_is_defined_missing(readstat_string_value(value), variable); if (readstat_value_type_class(value) == READSTAT_TYPE_CLASS_NUMERIC) return readstat_double_is_defined_missing(readstat_double_value(value), variable); return 0; } char readstat_int8_value(readstat_value_t value) { if (readstat_value_is_system_missing(value)) return 0; if (value.type == READSTAT_TYPE_DOUBLE) return (char)value.v.double_value; if (value.type == READSTAT_TYPE_FLOAT) return (char)value.v.float_value; if (value.type == READSTAT_TYPE_INT32) return (char)value.v.i32_value; if (value.type == READSTAT_TYPE_INT16) return (char)value.v.i16_value; if (value.type == READSTAT_TYPE_INT8) return value.v.i8_value; return 0; } int16_t readstat_int16_value(readstat_value_t value) { if (readstat_value_is_system_missing(value)) return 0; if (value.type == READSTAT_TYPE_DOUBLE) return (int16_t)value.v.double_value; if (value.type == READSTAT_TYPE_FLOAT) return (int16_t)value.v.float_value; if (value.type == READSTAT_TYPE_INT32) return (int16_t)value.v.i32_value; if (value.type == READSTAT_TYPE_INT16) return value.v.i16_value; if (value.type == READSTAT_TYPE_INT8) return value.v.i8_value; return 0; } int32_t readstat_int32_value(readstat_value_t value) { if (readstat_value_is_system_missing(value)) return 0; if (value.type == READSTAT_TYPE_DOUBLE) return (int32_t)value.v.double_value; if (value.type == READSTAT_TYPE_FLOAT) return (int32_t)value.v.float_value; if (value.type == READSTAT_TYPE_INT32) return value.v.i32_value; if (value.type == READSTAT_TYPE_INT16) return value.v.i16_value; if (value.type == READSTAT_TYPE_INT8) return value.v.i8_value; return 0; } float readstat_float_value(readstat_value_t value) { if (readstat_value_is_system_missing(value)) return NAN; if (value.type == READSTAT_TYPE_DOUBLE) return (float)value.v.double_value; if (value.type == READSTAT_TYPE_FLOAT) return value.v.float_value; if (value.type == READSTAT_TYPE_INT32) return value.v.i32_value; if (value.type == READSTAT_TYPE_INT16) return value.v.i16_value; if (value.type == READSTAT_TYPE_INT8) return value.v.i8_value; return value.v.float_value; } double readstat_double_value(readstat_value_t value) { if (readstat_value_is_system_missing(value)) return NAN; if (value.type == READSTAT_TYPE_DOUBLE) return value.v.double_value; if (value.type == READSTAT_TYPE_FLOAT) return value.v.float_value; if (value.type == READSTAT_TYPE_INT32) return value.v.i32_value; if (value.type == READSTAT_TYPE_INT16) return value.v.i16_value; if (value.type == READSTAT_TYPE_INT8) return value.v.i8_value; return NAN; } const char *readstat_string_value(readstat_value_t value) { if (readstat_value_type(value) == READSTAT_TYPE_STRING) return value.v.string_value; return NULL; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_variable.c0000644023477200000240000001070114574360757020233 0ustar00fajardoostaffs #include #include "readstat.h" static readstat_value_t make_blank_value(void); static readstat_value_t make_double_value(double dval); static readstat_value_t make_blank_value() { readstat_value_t value = { .is_system_missing = 1, .v = { .double_value = NAN }, .type = READSTAT_TYPE_DOUBLE }; return value; } static readstat_value_t make_double_value(double dval) { readstat_value_t value = { .v = { .double_value = dval }, .type = READSTAT_TYPE_DOUBLE }; return value; } static readstat_value_t make_string_value(const char *string) { readstat_value_t value = { .v = { .string_value = string }, .type = READSTAT_TYPE_STRING }; return value; } const char *readstat_variable_get_name(const readstat_variable_t *variable) { if (variable->name[0]) return variable->name; return NULL; } const char *readstat_variable_get_label(const readstat_variable_t *variable) { if (variable->label[0]) return variable->label; return NULL; } const char *readstat_variable_get_format(const readstat_variable_t *variable) { if (variable->format[0]) return variable->format; return NULL; } readstat_type_t readstat_variable_get_type(const readstat_variable_t *variable) { return variable->type; } readstat_type_class_t readstat_variable_get_type_class(const readstat_variable_t *variable) { return readstat_type_class(variable->type); } int readstat_variable_get_index(const readstat_variable_t *variable) { return variable->index; } int readstat_variable_get_index_after_skipping(const readstat_variable_t *variable) { return variable->index_after_skipping; } size_t readstat_variable_get_storage_width(const readstat_variable_t *variable) { return variable->storage_width; } readstat_measure_t readstat_variable_get_measure(const readstat_variable_t *variable) { return variable->measure; } readstat_alignment_t readstat_variable_get_alignment(const readstat_variable_t *variable) { return variable->alignment; } int readstat_variable_get_display_width(const readstat_variable_t *variable) { return variable->display_width; } int readstat_variable_get_missing_ranges_count(const readstat_variable_t *variable) { return variable->missingness.missing_ranges_count; } readstat_value_t readstat_variable_get_missing_range_lo(const readstat_variable_t *variable, int i) { if (i < variable->missingness.missing_ranges_count && 2*i+1 < sizeof(variable->missingness.missing_ranges)/sizeof(variable->missingness.missing_ranges[0])) { return variable->missingness.missing_ranges[2*i]; } return make_blank_value(); } readstat_value_t readstat_variable_get_missing_range_hi(const readstat_variable_t *variable, int i) { if (i < variable->missingness.missing_ranges_count && 2*i+1 < sizeof(variable->missingness.missing_ranges)/sizeof(variable->missingness.missing_ranges[0])) { return variable->missingness.missing_ranges[2*i+1]; } return make_blank_value(); } static readstat_error_t readstat_variable_add_missing_value_range(readstat_variable_t *variable, readstat_value_t lo, readstat_value_t hi) { int i = readstat_variable_get_missing_ranges_count(variable); if (2*i < sizeof(variable->missingness.missing_ranges)/sizeof(variable->missingness.missing_ranges[0])) { variable->missingness.missing_ranges[2*i] = lo; variable->missingness.missing_ranges[2*i+1] = hi; variable->missingness.missing_ranges_count++; return READSTAT_OK; } return READSTAT_ERROR_TOO_MANY_MISSING_VALUE_DEFINITIONS; } readstat_error_t readstat_variable_add_missing_double_range(readstat_variable_t *variable, double lo, double hi) { return readstat_variable_add_missing_value_range(variable, make_double_value(lo), make_double_value(hi)); } readstat_error_t readstat_variable_add_missing_double_value(readstat_variable_t *variable, double value) { return readstat_variable_add_missing_value_range(variable, make_double_value(value), make_double_value(value)); } readstat_error_t readstat_variable_add_missing_string_range(readstat_variable_t *variable, const char *lo, const char *hi) { return readstat_variable_add_missing_value_range(variable, make_string_value(lo), make_string_value(hi)); } readstat_error_t readstat_variable_add_missing_string_value(readstat_variable_t *variable, const char *value) { return readstat_variable_add_missing_value_range(variable, make_string_value(value), make_string_value(value)); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_writer.c0000644023477200000240000006067514574360757020001 0ustar00fajardoostaffs #include #include #include "readstat.h" #include "readstat_writer.h" #define VARIABLES_INITIAL_CAPACITY 50 #define LABEL_SETS_INITIAL_CAPACITY 50 #define NOTES_INITIAL_CAPACITY 50 #define VALUE_LABELS_INITIAL_CAPACITY 10 #define STRING_REFS_INITIAL_CAPACITY 100 #define LABEL_SET_VARIABLES_INITIAL_CAPACITY 2 static readstat_error_t readstat_write_row_default_callback(void *writer_ctx, void *bytes, size_t len) { return readstat_write_bytes((readstat_writer_t *)writer_ctx, bytes, len); } static int readstat_compare_string_refs(const void *elem1, const void *elem2) { readstat_string_ref_t *ref1 = *(readstat_string_ref_t **)elem1; readstat_string_ref_t *ref2 = *(readstat_string_ref_t **)elem2; if (ref1->first_o == ref2->first_o) return ref1->first_v - ref2->first_v; return ref1->first_o - ref2->first_o; } readstat_string_ref_t *readstat_string_ref_init(const char *string) { size_t len = strlen(string) + 1; readstat_string_ref_t *ref = calloc(1, sizeof(readstat_string_ref_t) + len); ref->first_o = -1; ref->first_v = -1; ref->len = len; memcpy(&ref->data[0], string, len); return ref; } readstat_writer_t *readstat_writer_init() { readstat_writer_t *writer = calloc(1, sizeof(readstat_writer_t)); writer->variables = calloc(VARIABLES_INITIAL_CAPACITY, sizeof(readstat_variable_t *)); writer->variables_capacity = VARIABLES_INITIAL_CAPACITY; writer->label_sets = calloc(LABEL_SETS_INITIAL_CAPACITY, sizeof(readstat_label_set_t *)); writer->label_sets_capacity = LABEL_SETS_INITIAL_CAPACITY; writer->notes = calloc(NOTES_INITIAL_CAPACITY, sizeof(char *)); writer->notes_capacity = NOTES_INITIAL_CAPACITY; writer->string_refs = calloc(STRING_REFS_INITIAL_CAPACITY, sizeof(readstat_string_ref_t *)); writer->string_refs_capacity = STRING_REFS_INITIAL_CAPACITY; writer->timestamp = time(NULL); writer->is_64bit = 1; writer->callbacks.write_row = &readstat_write_row_default_callback; return writer; } static void readstat_variable_free(readstat_variable_t *variable) { free(variable); } static void readstat_label_set_free(readstat_label_set_t *label_set) { int i; for (i=0; ivalue_labels_count; i++) { readstat_value_label_t *value_label = readstat_get_value_label(label_set, i); if (value_label->label) free(value_label->label); if (value_label->string_key) free(value_label->string_key); } free(label_set->value_labels); free(label_set->variables); free(label_set); } static void readstat_copy_label(readstat_value_label_t *value_label, const char *label) { if (label && strlen(label)) { value_label->label_len = strlen(label); value_label->label = malloc(value_label->label_len); memcpy(value_label->label, label, value_label->label_len); } } static readstat_value_label_t *readstat_add_value_label(readstat_label_set_t *label_set, const char *label) { if (label_set->value_labels_count == label_set->value_labels_capacity) { label_set->value_labels_capacity *= 2; label_set->value_labels = realloc(label_set->value_labels, label_set->value_labels_capacity * sizeof(readstat_value_label_t)); } readstat_value_label_t *new_value_label = &label_set->value_labels[label_set->value_labels_count++]; memset(new_value_label, 0, sizeof(readstat_value_label_t)); readstat_copy_label(new_value_label, label); return new_value_label; } readstat_error_t readstat_validate_variable(readstat_writer_t *writer, const readstat_variable_t *variable) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (writer->callbacks.variable_ok) return writer->callbacks.variable_ok(variable); return READSTAT_OK; } readstat_error_t readstat_validate_metadata(readstat_writer_t *writer) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (writer->callbacks.metadata_ok) return writer->callbacks.metadata_ok(writer); return READSTAT_OK; } static readstat_error_t readstat_begin_writing_data(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; size_t row_len = 0; int i; retval = readstat_validate_metadata(writer); if (retval != READSTAT_OK) goto cleanup; for (i=0; ivariables_count; i++) { readstat_variable_t *variable = readstat_get_variable(writer, i); variable->storage_width = writer->callbacks.variable_width(variable->type, variable->user_width); variable->offset = row_len; row_len += variable->storage_width; } if (writer->callbacks.variable_ok) { for (i=0; ivariables_count; i++) { retval = readstat_validate_variable(writer, readstat_get_variable(writer, i)); if (retval != READSTAT_OK) goto cleanup; } } writer->row_len = row_len; writer->row = malloc(writer->row_len); if (writer->callbacks.begin_data) { retval = writer->callbacks.begin_data(writer); } cleanup: return retval; } void readstat_writer_free(readstat_writer_t *writer) { int i; if (writer) { if (writer->callbacks.module_ctx_free && writer->module_ctx) { writer->callbacks.module_ctx_free(writer->module_ctx); } if (writer->variables) { for (i=0; ivariables_count; i++) { readstat_variable_free(writer->variables[i]); } free(writer->variables); } if (writer->label_sets) { for (i=0; ilabel_sets_count; i++) { readstat_label_set_free(writer->label_sets[i]); } free(writer->label_sets); } if (writer->notes) { for (i=0; inotes_count; i++) { free(writer->notes[i]); } free(writer->notes); } if (writer->string_refs) { for (i=0; istring_refs_count; i++) { free(writer->string_refs[i]); } free(writer->string_refs); } if (writer->row) { free(writer->row); } free(writer); } } readstat_error_t readstat_set_data_writer(readstat_writer_t *writer, readstat_data_writer data_writer) { writer->data_writer = data_writer; return READSTAT_OK; } readstat_error_t readstat_write_bytes(readstat_writer_t *writer, const void *bytes, size_t len) { size_t bytes_written = writer->data_writer(bytes, len, writer->user_ctx); if (bytes_written < len) { return READSTAT_ERROR_WRITE; } writer->bytes_written += bytes_written; return READSTAT_OK; } readstat_error_t readstat_write_bytes_as_lines(readstat_writer_t *writer, const void *bytes, size_t len, size_t line_len, const char *line_sep) { size_t line_sep_len = strlen(line_sep); readstat_error_t retval = READSTAT_OK; size_t bytes_written = 0; while (bytes_written < len) { ssize_t bytes_left_in_line = line_len - (writer->bytes_written % (line_len + line_sep_len)); if (len - bytes_written < bytes_left_in_line) { retval = readstat_write_bytes(writer, ((const char *)bytes) + bytes_written, len - bytes_written); bytes_written = len; } else { retval = readstat_write_bytes(writer, ((const char *)bytes) + bytes_written, bytes_left_in_line); bytes_written += bytes_left_in_line; } if (retval != READSTAT_OK) break; if (writer->bytes_written % (line_len + line_sep_len) == line_len) { if ((retval = readstat_write_bytes(writer, line_sep, line_sep_len)) != READSTAT_OK) break; } } return retval; } readstat_error_t readstat_write_line_padding(readstat_writer_t *writer, char pad, size_t line_len, const char *line_sep) { size_t line_sep_len = strlen(line_sep); if (writer->bytes_written % (line_len + line_sep_len) == 0) return READSTAT_OK; readstat_error_t error = READSTAT_OK; ssize_t bytes_left_in_line = line_len - (writer->bytes_written % (line_len + line_sep_len)); char *bytes = malloc(bytes_left_in_line); memset(bytes, pad, bytes_left_in_line); if ((error = readstat_write_bytes(writer, bytes, bytes_left_in_line)) != READSTAT_OK) goto cleanup; if ((error = readstat_write_bytes(writer, line_sep, line_sep_len)) != READSTAT_OK) goto cleanup; cleanup: if (bytes) free(bytes); return READSTAT_OK; } readstat_error_t readstat_write_string(readstat_writer_t *writer, const char *bytes) { return readstat_write_bytes(writer, bytes, strlen(bytes)); } static readstat_error_t readstat_write_repeated_byte(readstat_writer_t *writer, char byte, size_t len) { if (len == 0) return READSTAT_OK; char *zeros = malloc(len); memset(zeros, byte, len); readstat_error_t error = readstat_write_bytes(writer, zeros, len); free(zeros); return error; } readstat_error_t readstat_write_zeros(readstat_writer_t *writer, size_t len) { return readstat_write_repeated_byte(writer, '\0', len); } readstat_error_t readstat_write_spaces(readstat_writer_t *writer, size_t len) { return readstat_write_repeated_byte(writer, ' ', len); } readstat_error_t readstat_write_space_padded_string(readstat_writer_t *writer, const char *string, size_t max_len) { readstat_error_t retval = READSTAT_OK; if (string == NULL || string[0] == '\0') return readstat_write_spaces(writer, max_len); size_t len = strlen(string); if (len > max_len) len = max_len; if ((retval = readstat_write_bytes(writer, string, len)) != READSTAT_OK) return retval; return readstat_write_spaces(writer, max_len - len); } readstat_label_set_t *readstat_add_label_set(readstat_writer_t *writer, readstat_type_t type, const char *name) { if (writer->label_sets_count == writer->label_sets_capacity) { writer->label_sets_capacity *= 2; writer->label_sets = realloc(writer->label_sets, writer->label_sets_capacity * sizeof(readstat_label_set_t *)); } readstat_label_set_t *new_label_set = calloc(1, sizeof(readstat_label_set_t)); writer->label_sets[writer->label_sets_count++] = new_label_set; new_label_set->type = type; snprintf(new_label_set->name, sizeof(new_label_set->name), "%s", name); new_label_set->value_labels = calloc(VALUE_LABELS_INITIAL_CAPACITY, sizeof(readstat_value_label_t)); new_label_set->value_labels_capacity = VALUE_LABELS_INITIAL_CAPACITY; new_label_set->variables = calloc(LABEL_SET_VARIABLES_INITIAL_CAPACITY, sizeof(readstat_variable_t *)); new_label_set->variables_capacity = LABEL_SET_VARIABLES_INITIAL_CAPACITY; return new_label_set; } readstat_label_set_t *readstat_get_label_set(readstat_writer_t *writer, int index) { if (index < writer->label_sets_count) { return writer->label_sets[index]; } return NULL; } void readstat_sort_label_set(readstat_label_set_t *label_set, int (*compare)(const readstat_value_label_t *, const readstat_value_label_t *)) { qsort(label_set->value_labels, label_set->value_labels_count, sizeof(readstat_value_label_t), (int (*)(const void *, const void *))compare); } readstat_value_label_t *readstat_get_value_label(readstat_label_set_t *label_set, int index) { if (index < label_set->value_labels_count) { return &label_set->value_labels[index]; } return NULL; } readstat_variable_t *readstat_get_label_set_variable(readstat_label_set_t *label_set, int index) { if (index < label_set->variables_count) { return ((readstat_variable_t **)label_set->variables)[index]; } return NULL; } void readstat_label_double_value(readstat_label_set_t *label_set, double value, const char *label) { readstat_value_label_t *new_value_label = readstat_add_value_label(label_set, label); new_value_label->double_key = value; new_value_label->int32_key = value; } void readstat_label_int32_value(readstat_label_set_t *label_set, int32_t value, const char *label) { readstat_value_label_t *new_value_label = readstat_add_value_label(label_set, label); new_value_label->double_key = value; new_value_label->int32_key = value; } void readstat_label_string_value(readstat_label_set_t *label_set, const char *value, const char *label) { readstat_value_label_t *new_value_label = readstat_add_value_label(label_set, label); if (value && strlen(value)) { new_value_label->string_key_len = strlen(value); new_value_label->string_key = malloc(new_value_label->string_key_len); memcpy(new_value_label->string_key, value, new_value_label->string_key_len); } } void readstat_label_tagged_value(readstat_label_set_t *label_set, char tag, const char *label) { readstat_value_label_t *new_value_label = readstat_add_value_label(label_set, label); new_value_label->tag = tag; } readstat_variable_t *readstat_add_variable(readstat_writer_t *writer, const char *name, readstat_type_t type, size_t width) { if (writer->variables_count == writer->variables_capacity) { writer->variables_capacity *= 2; writer->variables = realloc(writer->variables, writer->variables_capacity * sizeof(readstat_variable_t *)); } readstat_variable_t *new_variable = calloc(1, sizeof(readstat_variable_t)); new_variable->index = writer->variables_count++; writer->variables[new_variable->index] = new_variable; new_variable->user_width = width; new_variable->type = type; if (readstat_variable_get_type_class(new_variable) == READSTAT_TYPE_CLASS_STRING) { new_variable->alignment = READSTAT_ALIGNMENT_LEFT; } else { new_variable->alignment = READSTAT_ALIGNMENT_RIGHT; } new_variable->measure = READSTAT_MEASURE_UNKNOWN; if (name) { snprintf(new_variable->name, sizeof(new_variable->name), "%s", name); } return new_variable; } static void readstat_append_string_ref(readstat_writer_t *writer, readstat_string_ref_t *ref) { if (writer->string_refs_count == writer->string_refs_capacity) { writer->string_refs_capacity *= 2; writer->string_refs = realloc(writer->string_refs, writer->string_refs_capacity * sizeof(readstat_string_ref_t *)); } writer->string_refs[writer->string_refs_count++] = ref; } readstat_string_ref_t *readstat_add_string_ref(readstat_writer_t *writer, const char *string) { readstat_string_ref_t *ref = readstat_string_ref_init(string); readstat_append_string_ref(writer, ref); return ref; } void readstat_add_note(readstat_writer_t *writer, const char *note) { if (writer->notes_count == writer->notes_capacity) { writer->notes_capacity *= 2; writer->notes = realloc(writer->notes, writer->notes_capacity * sizeof(const char *)); } char *note_copy = malloc(strlen(note) + 1); strcpy(note_copy, note); writer->notes[writer->notes_count++] = note_copy; } void readstat_variable_set_label(readstat_variable_t *variable, const char *label) { if (label) { snprintf(variable->label, sizeof(variable->label), "%s", label); } else { memset(variable->label, '\0', sizeof(variable->label)); } } void readstat_variable_set_format(readstat_variable_t *variable, const char *format) { if (format) { snprintf(variable->format, sizeof(variable->format), "%s", format); } else { memset(variable->format, '\0', sizeof(variable->format)); } } void readstat_variable_set_measure(readstat_variable_t *variable, readstat_measure_t measure) { variable->measure = measure; } void readstat_variable_set_alignment(readstat_variable_t *variable, readstat_alignment_t alignment) { variable->alignment = alignment; } void readstat_variable_set_display_width(readstat_variable_t *variable, int display_width) { variable->display_width = display_width; } void readstat_variable_set_label_set(readstat_variable_t *variable, readstat_label_set_t *label_set) { variable->label_set = label_set; if (label_set) { if (label_set->variables_count == label_set->variables_capacity) { label_set->variables_capacity *= 2; label_set->variables = realloc(label_set->variables, label_set->variables_capacity * sizeof(readstat_variable_t *)); } ((readstat_variable_t **)label_set->variables)[label_set->variables_count++] = variable; } } readstat_variable_t *readstat_get_variable(readstat_writer_t *writer, int index) { if (index < writer->variables_count) { return writer->variables[index]; } return NULL; } readstat_string_ref_t *readstat_get_string_ref(readstat_writer_t *writer, int index) { if (index < writer->string_refs_count) { return writer->string_refs[index]; } return NULL; } readstat_error_t readstat_writer_set_file_label(readstat_writer_t *writer, const char *file_label) { snprintf(writer->file_label, sizeof(writer->file_label), "%s", file_label); return READSTAT_OK; } readstat_error_t readstat_writer_set_file_timestamp(readstat_writer_t *writer, time_t timestamp) { writer->timestamp = timestamp; return READSTAT_OK; } readstat_error_t readstat_writer_set_table_name(readstat_writer_t *writer, const char *table_name) { snprintf(writer->table_name, sizeof(writer->table_name), "%s", table_name); return READSTAT_OK; } readstat_error_t readstat_writer_set_fweight_variable(readstat_writer_t *writer, const readstat_variable_t *variable) { if (readstat_variable_get_type_class(variable) == READSTAT_TYPE_CLASS_STRING) return READSTAT_ERROR_BAD_FREQUENCY_WEIGHT; writer->fweight_variable = variable; return READSTAT_OK; } readstat_error_t readstat_writer_set_file_format_version(readstat_writer_t *writer, uint8_t version) { writer->version = version; return READSTAT_OK; } readstat_error_t readstat_writer_set_file_format_is_64bit(readstat_writer_t *writer, int is_64bit) { writer->is_64bit = is_64bit; return READSTAT_OK; } readstat_error_t readstat_writer_set_compression(readstat_writer_t *writer, readstat_compress_t compression) { writer->compression = compression; return READSTAT_OK; } readstat_error_t readstat_writer_set_error_handler(readstat_writer_t *writer, readstat_error_handler error_handler) { writer->error_handler = error_handler; return READSTAT_OK; } readstat_error_t readstat_begin_writing_file(readstat_writer_t *writer, void *user_ctx, long row_count) { writer->row_count = row_count; writer->user_ctx = user_ctx; writer->initialized = 1; return readstat_validate_metadata(writer); } readstat_error_t readstat_begin_row(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (writer->current_row == 0) retval = readstat_begin_writing_data(writer); memset(writer->row, '\0', writer->row_len); return retval; } // Then call one of these for each variable readstat_error_t readstat_insert_int8_value(readstat_writer_t *writer, const readstat_variable_t *variable, int8_t value) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (variable->type != READSTAT_TYPE_INT8) return READSTAT_ERROR_VALUE_TYPE_MISMATCH; return writer->callbacks.write_int8(&writer->row[variable->offset], variable, value); } readstat_error_t readstat_insert_int16_value(readstat_writer_t *writer, const readstat_variable_t *variable, int16_t value) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (variable->type != READSTAT_TYPE_INT16) return READSTAT_ERROR_VALUE_TYPE_MISMATCH; return writer->callbacks.write_int16(&writer->row[variable->offset], variable, value); } readstat_error_t readstat_insert_int32_value(readstat_writer_t *writer, const readstat_variable_t *variable, int32_t value) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (variable->type != READSTAT_TYPE_INT32) return READSTAT_ERROR_VALUE_TYPE_MISMATCH; return writer->callbacks.write_int32(&writer->row[variable->offset], variable, value); } readstat_error_t readstat_insert_float_value(readstat_writer_t *writer, const readstat_variable_t *variable, float value) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (variable->type != READSTAT_TYPE_FLOAT) return READSTAT_ERROR_VALUE_TYPE_MISMATCH; return writer->callbacks.write_float(&writer->row[variable->offset], variable, value); } readstat_error_t readstat_insert_double_value(readstat_writer_t *writer, const readstat_variable_t *variable, double value) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (variable->type != READSTAT_TYPE_DOUBLE) return READSTAT_ERROR_VALUE_TYPE_MISMATCH; return writer->callbacks.write_double(&writer->row[variable->offset], variable, value); } readstat_error_t readstat_insert_string_value(readstat_writer_t *writer, const readstat_variable_t *variable, const char *value) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (variable->type != READSTAT_TYPE_STRING) return READSTAT_ERROR_VALUE_TYPE_MISMATCH; return writer->callbacks.write_string(&writer->row[variable->offset], variable, value); } readstat_error_t readstat_insert_string_ref(readstat_writer_t *writer, const readstat_variable_t *variable, readstat_string_ref_t *ref) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (variable->type != READSTAT_TYPE_STRING_REF) return READSTAT_ERROR_VALUE_TYPE_MISMATCH; if (!writer->callbacks.write_string_ref) return READSTAT_ERROR_STRING_REFS_NOT_SUPPORTED; if (ref && ref->first_o == -1 && ref->first_v == -1) { ref->first_o = writer->current_row + 1; ref->first_v = variable->index + 1; } return writer->callbacks.write_string_ref(&writer->row[variable->offset], variable, ref); } readstat_error_t readstat_insert_missing_value(readstat_writer_t *writer, const readstat_variable_t *variable) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (variable->type == READSTAT_TYPE_STRING) { return writer->callbacks.write_missing_string(&writer->row[variable->offset], variable); } if (variable->type == READSTAT_TYPE_STRING_REF) { return readstat_insert_string_ref(writer, variable, NULL); } return writer->callbacks.write_missing_number(&writer->row[variable->offset], variable); } readstat_error_t readstat_insert_tagged_missing_value(readstat_writer_t *writer, const readstat_variable_t *variable, char tag) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (!writer->callbacks.write_missing_tagged) { /* Write out a missing number but return an error */ writer->callbacks.write_missing_number(&writer->row[variable->offset], variable); return READSTAT_ERROR_TAGGED_VALUES_NOT_SUPPORTED; } return writer->callbacks.write_missing_tagged(&writer->row[variable->offset], variable, tag); } readstat_error_t readstat_end_row(readstat_writer_t *writer) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; readstat_error_t error = writer->callbacks.write_row(writer, writer->row, writer->row_len); if (error == READSTAT_OK) writer->current_row++; return error; } readstat_error_t readstat_end_writing(readstat_writer_t *writer) { if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; if (writer->current_row != writer->row_count) return READSTAT_ERROR_ROW_COUNT_MISMATCH; if (writer->row_count == 0) { readstat_error_t retval = readstat_begin_writing_data(writer); if (retval != READSTAT_OK) return retval; } /* Sort if out of order */ int i; for (i=1; istring_refs_count; i++) { if (readstat_compare_string_refs(&writer->string_refs[i-1], &writer->string_refs[i]) > 0) { qsort(writer->string_refs, writer->string_refs_count, sizeof(readstat_string_ref_t *), &readstat_compare_string_refs); break; } } if (!writer->callbacks.end_data) return READSTAT_OK; return writer->callbacks.end_data(writer); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/readstat_writer.h0000644023477200000240000000256614574360757020001 0ustar00fajardoostaffs #define READSTAT_PRODUCT_NAME "ReadStat" #define READSTAT_PRODUCT_URL "https://github.com/WizardMac/ReadStat" readstat_error_t readstat_begin_writing_file(readstat_writer_t *writer, void *user_ctx, long row_count); readstat_error_t readstat_write_bytes(readstat_writer_t *writer, const void *bytes, size_t len); readstat_error_t readstat_write_bytes_as_lines(readstat_writer_t *writer, const void *bytes, size_t len, size_t line_len, const char *line_sep); readstat_error_t readstat_write_line_padding(readstat_writer_t *writer, char pad, size_t line_len, const char *line_sep); readstat_error_t readstat_write_zeros(readstat_writer_t *writer, size_t len); readstat_error_t readstat_write_spaces(readstat_writer_t *writer, size_t len); readstat_error_t readstat_write_string(readstat_writer_t *writer, const char *bytes); readstat_error_t readstat_write_space_padded_string(readstat_writer_t *writer, const char *string, size_t max_len); readstat_value_label_t *readstat_get_value_label(readstat_label_set_t *label_set, int index); readstat_label_set_t *readstat_get_label_set(readstat_writer_t *writer, int index); readstat_variable_t *readstat_get_label_set_variable(readstat_label_set_t *label_set, int index); void readstat_sort_label_set(readstat_label_set_t *label_set, int (*compare)(const readstat_value_label_t *, const readstat_value_label_t *)); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/src/sas/0000755023477200000240000000000014574564663015204 5ustar00fajardoostaffs././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/ieee.c0000644023477200000240000003434314574360757016264 0ustar00fajardoostaffs#include #include #include "ieee.h" #include "../readstat_bits.h" /* These routines are modified versions of those found in SAS publication TS-140, * "RECORD LAYOUT OF A SAS VERSION 5 OR 6 DATA SET IN SAS TRANSPORT (XPORT) FORMAT" * https://support.sas.com/techsup/technote/ts140.pdf * * Modifications include using stdint.h and supporting infinite IEEE values. */ static void xpt2ieee(unsigned char *xport, unsigned char *ieee); static void ieee2xpt(unsigned char *ieee, unsigned char *xport); #ifndef FLOATREP #define FLOATREP get_native() int get_native(void); #endif void memreverse(void *intp_void, int l) { if (!machine_is_little_endian()) return; int i,j; char save; char *intp = (char *)intp_void; j = l/2; for (i=0;i=0;i--) { temp[7-i] = from[i]; } from = temp; fromtype = CN_TYPE_IEEEB; /* Break intentionally omitted. */ case CN_TYPE_IEEEB : /* Break intentionally omitted. */ case CN_TYPE_XPORT : break; default: return(-1); } if (totype == CN_TYPE_NATIVE) { totype = FLOATREP; } switch(totype) { case CN_TYPE_XPORT : case CN_TYPE_IEEEB : case CN_TYPE_IEEEL : break; default: return(-2); } if (fromtype == totype) { memcpy(to,from,8); return(0); } switch(fromtype) { case CN_TYPE_IEEEB : if (totype == CN_TYPE_XPORT) ieee2xpt(from,to); else memcpy(to,from,8); break; case CN_TYPE_XPORT : xpt2ieee(from,to); break; } if (totype == CN_TYPE_IEEEL) { memcpy(temp,to,8); for (i=7;i>=0;i--) { to[7-i] = temp[i]; } } return(0); } int get_native() { static unsigned char float_reps[][8] = { {0x41,0x10,0x00,0x00,0x00,0x00,0x00,0x00}, {0x3f,0xf0,0x00,0x00,0x00,0x00,0x00,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x3f} }; static double one = 1.00; int i,j; j = sizeof(float_reps)/8; for (i=0;i>= shift; ieee2 = (xport2 >> shift) | ((xport1 & 0x00000007) << (29 + (3 - shift))); } /* clear the 1 bit to the left of the binary point */ ieee1 &= 0xffefffff; /* set the exponent of the ieee number to be the actual */ /* exponent plus the shift count + 1023. Or this into the */ /* first half of the ieee number. The ibm exponent is excess */ /* 64 but is adjusted by 65 since during conversion to ibm */ /* format the exponent is incremented by 1 and the fraction */ /* bits left 4 positions to the right of the radix point. */ ieee1 |= (((((int32_t)(*temp & 0x7f) - 65) * 4) + shift + 1023) << 20) | (xport1 & 0x80000000); doret: memreverse(&ieee1,sizeof(uint32_t)); memcpy(ieee,&ieee1,sizeof(uint32_t)); memreverse(&ieee2,sizeof(uint32_t)); memcpy(ieee+4,&ieee2,sizeof(uint32_t)); return; } /*-------------------------------------------------------------*/ /* Name: ieee2xpt */ /* Purpose: converts IEEE to transport */ /* Usage: rc = ieee2xpt(to_ieee,p_data); */ /* Notes: this routine is an adaptation of the wzctdbl routine */ /* from the Apollo. */ /*-------------------------------------------------------------*/ void ieee2xpt(unsigned char *ieee, unsigned char *xport) { register int shift; unsigned char misschar; int ieee_exp; uint32_t xport1,xport2; uint32_t ieee1 = 0; uint32_t ieee2 = 0; char ieee8[8]; memcpy(ieee8,ieee,8); /*------get 2 longs for shifting------------------------------*/ memcpy(&ieee1,ieee8,sizeof(uint32_t)); memreverse(&ieee1,sizeof(uint32_t)); memcpy(&ieee2,ieee8+4,sizeof(uint32_t)); memreverse(&ieee2,sizeof(uint32_t)); memset(xport,0,8); /*-----if IEEE value is missing (1st 2 bytes are FFFF)-----*/ if (*ieee8 == (char)0xff && ieee8[1] == (char)0xff) { misschar = ~ieee8[2]; *xport = (misschar == 0xD2) ? 0x6D : misschar; return; } /**************************************************************/ /* Translate IEEE floating point number into IBM format float */ /* */ /* IEEE format: */ /* */ /* 6 5 0 */ /* 3 1 0 */ /* */ /* SEEEEEEEEEEEMMMM ........ MMMM */ /* */ /* Sign bit, 11 bit exponent, 52 fraction. Exponent is excess */ /* 1023. The fraction is multiplied by a power of 2 of the */ /* actual exponent. Normalized floating point numbers are */ /* represented with the binary point immediately to the left */ /* of the fraction with an implied "1" to the left of the */ /* binary point. */ /* */ /* IBM format: */ /* */ /* 6 5 0 */ /* 3 5 0 */ /* */ /* SEEEEEEEMMMM ......... MMMM */ /* */ /* Sign bit, 7 bit exponent, 56 bit fraction. Exponent is */ /* excess 64. The fraction is multiplied by a power of 16 of */ /* of the actual exponent. Normalized floating point numbers */ /* are presented with the radix point immediately to the left */ /* of the high order hex fraction digit. */ /* */ /* How do you translate from local to IBM format? */ /* */ /* The ieee format gives you a number that has a power of 2 */ /* exponent and a fraction of the form "1.". */ /* The first step is to get that "1" bit back into the */ /* fraction. Right shift it down 1 position, set the high */ /* order bit and reduce the binary exponent by 1. Now we have */ /* a fraction that looks like ".1" and it's */ /* ready to be shoved into ibm format. The ibm fraction has 4 */ /* more bits than the ieee, the ieee fraction must therefore */ /* be shifted left 4 positions before moving it in. We must */ /* also correct the fraction bits to account for the loss of 2*/ /* bits when converting from a binary exponent to a hex one */ /* (>> 2). We must shift the fraction left for 0, 1, 2, or 3 */ /* positions to maintain the proper magnitude. Doing */ /* conversion this way would tend to lose bits in the fraction*/ /* which is not desirable or necessary if we cheat a bit. */ /* First of all, we know that we are going to have to shift */ /* the ieee fraction left 4 places to put it in the right */ /* position; we won't do that, we'll just leave it where it is*/ /* and increment the ibm exponent by one, this will have the */ /* same effect and we won't have to do any shifting. Now, */ /* since we have 4 bits in front of the fraction to work with,*/ /* we won't lose any bits. We set the bit to the left of the */ /* fraction which is the implicit "1" in the ieee fraction. We*/ /* then adjust the fraction to account for the loss of bits */ /* when going to a hex exponent. This adjustment will never */ /* involve shifting by more than 3 positions so no bits are */ /* lost. */ /* Get ieee number less the exponent into the first half of */ /* the ibm number */ xport1 = ieee1 & 0x000fffff; /* get the second half of the number into the second half of */ /* the ibm number and see if both halves are 0. If so, ibm is */ /* also 0 and we just return */ if ((!(xport2 = ieee2)) && !ieee1) { ieee_exp = 0; goto doret; } /* get the actual exponent value out of the ieee number. The */ /* ibm fraction is a power of 16 and the ieee fraction a power*/ /* of 2 (16 ** n == 2 ** 4n). Save the low order 2 bits since */ /* they will get lost when we divide the exponent by 4 (right */ /* shift by 2) and we will have to shift the fraction by the */ /* appropriate number of bits to keep the proper magnitude. */ shift = (int) (ieee_exp = (int)(((ieee1 >> 16) & 0x7ff0) >> 4) - 1023) & 3; /* the ieee format has an implied "1" immdeiately to the left */ /* of the binary point. Show it in here. */ xport1 |= 0x00100000; if (shift) { /* set the first half of the ibm number by shifting it left */ /* the appropriate number of bits and oring in the bits */ /* from the lower half that would have been shifted in (if */ /* we could shift a double). The shift count can never */ /* exceed 3, so all we care about are the high order 3 */ /* bits. We don't want sign extention so make sure it's an */ /* unsigned char. We'll shift either5, 6, or 7 places to */ /* keep 3, 2, or 1 bits. After that, shift the second half */ /* of the number the right number of places. We always get */ /* zero fill on left shifts. */ xport1 = (xport1 << shift) | ((unsigned char) (((ieee2 >> 24) & 0xE0) >> (5 + (3 - shift)))); xport2 <<= shift; } /* Now set the ibm exponent and the sign of the fraction. The */ /* power of 2 ieee exponent must be divided by 4 and made */ /* excess 64 (we add 65 here because of the poisition of the */ /* fraction bits, essentially 4 positions lower than they */ /* should be so we incrment the ibm exponent). */ xport1 |= (((ieee_exp >>2) + 65) | ((ieee1 >> 24) & 0x80)) << 24; /* If the ieee exponent is greater than 248 or less than -260, */ /* then it cannot fit in the ibm exponent field. Send back the */ /* appropriate flag. */ doret: if (ieee_exp < -260) { memset(xport,0x00,8); } else if (ieee_exp > 248) { memset(xport+1,0xFF,7); *xport = 0x7F | ((ieee1 >> 24) & 0x80); } else { memreverse(&xport1,sizeof(uint32_t)); memcpy(xport,&xport1,sizeof(uint32_t)); memreverse(&xport2,sizeof(uint32_t)); memcpy(xport+4,&xport2,sizeof(uint32_t)); } return; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/ieee.h0000644023477200000240000000026214574360757016262 0ustar00fajardoostaffs#define CN_TYPE_NATIVE 0 #define CN_TYPE_XPORT 1 #define CN_TYPE_IEEEB 2 #define CN_TYPE_IEEEL 3 int cnxptiee(const void *from_bytes, int fromtype, void *to_bytes, int totype); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_sas.c0000644023477200000240000004351414574360757020032 0ustar00fajardoostaffs #include #include #include #include #include #include #include #include #include "readstat_sas.h" #include "../readstat_iconv.h" #include "../readstat_convert.h" #include "../readstat_writer.h" #define SAS_FILE_HEADER_SIZE_32BIT 1024 #define SAS_FILE_HEADER_SIZE_64BIT 8192 #define SAS_DEFAULT_PAGE_SIZE 4096 #define SAS_DEFAULT_STRING_ENCODING "WINDOWS-1252" unsigned char sas7bdat_magic_number[32] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc2, 0xea, 0x81, 0x60, 0xb3, 0x14, 0x11, 0xcf, 0xbd, 0x92, 0x08, 0x00, 0x09, 0xc7, 0x31, 0x8c, 0x18, 0x1f, 0x10, 0x11 }; unsigned char sas7bcat_magic_number[32] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc2, 0xea, 0x81, 0x63, 0xb3, 0x14, 0x11, 0xcf, 0xbd, 0x92, 0x08, 0x00, 0x09, 0xc7, 0x31, 0x8c, 0x18, 0x1f, 0x10, 0x11 }; /* This table is cobbled together from extant files and: * https://support.sas.com/documentation/cdl/en/nlsref/61893/HTML/default/viewer.htm#a002607278.htm * https://support.sas.com/documentation/onlinedoc/dfdmstudio/2.6/dmpdmsug/Content/dfU_Encodings_SAS.html * * Discrepancies form the official documentation are noted with a comment. It * appears that in some instances that SAS software uses a newer encoding than * what's listed in the docs. In these cases the encoding used by ReadStat * represents the author's best guess. */ static readstat_charset_entry_t _charset_table[] = { { .code = 0, .name = SAS_DEFAULT_STRING_ENCODING }, { .code = 20, .name = "UTF-8" }, { .code = 28, .name = "US-ASCII" }, { .code = 29, .name = "ISO-8859-1" }, { .code = 30, .name = "ISO-8859-2" }, { .code = 31, .name = "ISO-8859-3" }, { .code = 32, .name = "ISO-8859-4" }, { .code = 33, .name = "ISO-8859-5" }, { .code = 34, .name = "ISO-8859-6" }, { .code = 35, .name = "ISO-8859-7" }, { .code = 36, .name = "ISO-8859-8" }, { .code = 37, .name = "ISO-8859-9" }, { .code = 39, .name = "ISO-8859-11" }, { .code = 40, .name = "ISO-8859-15" }, { .code = 41, .name = "CP437" }, { .code = 42, .name = "CP850" }, { .code = 43, .name = "CP852" }, { .code = 44, .name = "CP857" }, { .code = 45, .name = "CP858" }, { .code = 46, .name = "CP862" }, { .code = 47, .name = "CP864" }, { .code = 48, .name = "CP865" }, { .code = 49, .name = "CP866" }, { .code = 50, .name = "CP869" }, { .code = 51, .name = "CP874" }, { .code = 52, .name = "CP921" }, { .code = 53, .name = "CP922" }, { .code = 54, .name = "CP1129" }, { .code = 55, .name = "CP720" }, { .code = 56, .name = "CP737" }, { .code = 57, .name = "CP775" }, { .code = 58, .name = "CP860" }, { .code = 59, .name = "CP863" }, { .code = 60, .name = "WINDOWS-1250" }, { .code = 61, .name = "WINDOWS-1251" }, { .code = 62, .name = "WINDOWS-1252" }, { .code = 63, .name = "WINDOWS-1253" }, { .code = 64, .name = "WINDOWS-1254" }, { .code = 65, .name = "WINDOWS-1255" }, { .code = 66, .name = "WINDOWS-1256" }, { .code = 67, .name = "WINDOWS-1257" }, { .code = 68, .name = "WINDOWS-1258" }, { .code = 69, .name = "MACROMAN" }, { .code = 70, .name = "MACARABIC" }, { .code = 71, .name = "MACHEBREW" }, { .code = 72, .name = "MACGREEK" }, { .code = 73, .name = "MACTHAI" }, { .code = 75, .name = "MACTURKISH" }, { .code = 76, .name = "MACUKRAINE" }, { .code = 118, .name = "CP950" }, { .code = 119, .name = "EUC-TW" }, { .code = 123, .name = "BIG-5" }, { .code = 125, .name = "GB18030" }, // "euc-cn" in SAS { .code = 126, .name = "WINDOWS-936" }, // "zwin" { .code = 128, .name = "CP1381" }, // "zpce" { .code = 134, .name = "EUC-JP" }, { .code = 136, .name = "CP949" }, { .code = 137, .name = "CP942" }, { .code = 138, .name = "CP932" }, // "shift-jis" in SAS { .code = 140, .name = "EUC-KR" }, { .code = 141, .name = "CP949" }, // "kpce" { .code = 142, .name = "CP949" }, // "kwin" { .code = 163, .name = "MACICELAND" }, { .code = 167, .name = "ISO-2022-JP" }, { .code = 168, .name = "ISO-2022-KR" }, { .code = 169, .name = "ISO-2022-CN" }, { .code = 172, .name = "ISO-2022-CN-EXT" }, { .code = 204, .name = SAS_DEFAULT_STRING_ENCODING }, // "any" in SAS { .code = 205, .name = "GB18030" }, { .code = 227, .name = "ISO-8859-14" }, { .code = 242, .name = "ISO-8859-13" }, { .code = 245, .name = "MACCROATIAN" }, { .code = 246, .name = "MACCYRILLIC" }, { .code = 247, .name = "MACROMANIA" }, { .code = 248, .name = "SHIFT_JISX0213" }, }; static time_t sas_epoch() { return - 3653 * 86400; // seconds between 01-01-1960 and 01-01-1970 } static time_t sas_convert_time(double time, time_t epoch) { time += epoch; if (isnan(time)) return 0; if (time > (double)LONG_MAX) return LONG_MAX; if (time < (double)LONG_MIN) return LONG_MIN; return time; } uint64_t sas_read8(const char *data, int bswap) { uint64_t tmp; memcpy(&tmp, data, 8); return bswap ? byteswap8(tmp) : tmp; } uint32_t sas_read4(const char *data, int bswap) { uint32_t tmp; memcpy(&tmp, data, 4); return bswap ? byteswap4(tmp) : tmp; } uint16_t sas_read2(const char *data, int bswap) { uint16_t tmp; memcpy(&tmp, data, 2); return bswap ? byteswap2(tmp) : tmp; } size_t sas_subheader_remainder(size_t len, size_t signature_len) { return len - (4+2*signature_len); } readstat_error_t sas_read_header(readstat_io_t *io, sas_header_info_t *hinfo, readstat_error_handler error_handler, void *user_ctx) { sas_header_start_t header_start; sas_header_end_t header_end; int retval = READSTAT_OK; char error_buf[1024]; time_t epoch = sas_epoch(); if (io->read(&header_start, sizeof(sas_header_start_t), io->io_ctx) < sizeof(sas_header_start_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (memcmp(header_start.magic, sas7bdat_magic_number, sizeof(sas7bdat_magic_number)) != 0 && memcmp(header_start.magic, sas7bcat_magic_number, sizeof(sas7bcat_magic_number)) != 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (header_start.a1 == SAS_ALIGNMENT_OFFSET_4) { hinfo->pad1 = 4; } if (header_start.a2 == SAS_ALIGNMENT_OFFSET_4) { hinfo->u64 = 1; } int bswap = 0; if (header_start.endian == SAS_ENDIAN_BIG) { bswap = machine_is_little_endian(); hinfo->little_endian = 0; } else if (header_start.endian == SAS_ENDIAN_LITTLE) { bswap = !machine_is_little_endian(); hinfo->little_endian = 1; } else { retval = READSTAT_ERROR_PARSE; goto cleanup; } int i; for (i=0; iencoding = _charset_table[i].name; break; } } if (hinfo->encoding == NULL) { if (error_handler) { snprintf(error_buf, sizeof(error_buf), "Unsupported character set code: %d", header_start.encoding); error_handler(error_buf, user_ctx); } retval = READSTAT_ERROR_UNSUPPORTED_CHARSET; goto cleanup; } memcpy(hinfo->table_name, header_start.table_name, sizeof(header_start.table_name)); if (io->seek(hinfo->pad1, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } double creation_time, modification_time; if (io->read(&creation_time, sizeof(double), io->io_ctx) < sizeof(double)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (bswap) creation_time = byteswap_double(creation_time); if (io->read(&modification_time, sizeof(double), io->io_ctx) < sizeof(double)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (bswap) modification_time = byteswap_double(modification_time); hinfo->creation_time = sas_convert_time(creation_time, epoch); hinfo->modification_time = sas_convert_time(modification_time, epoch); if (io->seek(16, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } uint32_t header_size, page_size; if (io->read(&header_size, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (io->read(&page_size, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } hinfo->header_size = bswap ? byteswap4(header_size) : header_size; hinfo->page_size = bswap ? byteswap4(page_size) : page_size; if (hinfo->header_size < 1024 || hinfo->page_size < 1024) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (hinfo->header_size > (1<<24) || hinfo->page_size > (1<<24)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (hinfo->u64) { hinfo->page_header_size = SAS_PAGE_HEADER_SIZE_64BIT; hinfo->subheader_pointer_size = SAS_SUBHEADER_POINTER_SIZE_64BIT; } else { hinfo->page_header_size = SAS_PAGE_HEADER_SIZE_32BIT; hinfo->subheader_pointer_size = SAS_SUBHEADER_POINTER_SIZE_32BIT; } if (hinfo->u64) { uint64_t page_count; if (io->read(&page_count, sizeof(uint64_t), io->io_ctx) < sizeof(uint64_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } hinfo->page_count = bswap ? byteswap8(page_count) : page_count; } else { uint32_t page_count; if (io->read(&page_count, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } hinfo->page_count = bswap ? byteswap4(page_count) : page_count; } if (hinfo->page_count > (1<<24)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (io->seek(8, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; if (error_handler) { snprintf(error_buf, sizeof(error_buf), "ReadStat: Failed to seek forward by %d", 8); error_handler(error_buf, user_ctx); } goto cleanup; } if (io->read(&header_end, sizeof(sas_header_end_t), io->io_ctx) < sizeof(sas_header_end_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } char major; int minor, revision; if (sscanf(header_end.release, "%c.%04dM%1d", &major, &minor, &revision) != 3) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (major >= '1' && major <= '9') { hinfo->major_version = major - '0'; } else if (major == 'V') { // It appears that SAS Visual Forecaster reports the major version as "V" // Treat it as version 9 for all intents and purposes hinfo->major_version = 9; } else { retval = READSTAT_ERROR_PARSE; goto cleanup; } hinfo->minor_version = minor; hinfo->revision = revision; if ((major == '8' || major == '9') && minor == 0 && revision == 0) { /* A bit of a hack, but most SAS installations are running a minor update */ hinfo->vendor = READSTAT_VENDOR_STAT_TRANSFER; } else { hinfo->vendor = READSTAT_VENDOR_SAS; } if (io->seek(hinfo->header_size, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; if (error_handler) { snprintf(error_buf, sizeof(error_buf), "ReadStat: Failed to seek to position %" PRId64, hinfo->header_size); error_handler(error_buf, user_ctx); } goto cleanup; } cleanup: return retval; } readstat_error_t sas_write_header(readstat_writer_t *writer, sas_header_info_t *hinfo, sas_header_start_t header_start) { readstat_error_t retval = READSTAT_OK; time_t epoch = sas_epoch(); memset(header_start.table_name, ' ', sizeof(header_start.table_name)); size_t table_name_len = strlen(writer->table_name); if (table_name_len > sizeof(header_start.table_name)) table_name_len = sizeof(header_start.table_name); if (table_name_len) { memcpy(header_start.table_name, writer->table_name, table_name_len); } else { memcpy(header_start.table_name, "DATASET", sizeof("DATASET")-1); } retval = readstat_write_bytes(writer, &header_start, sizeof(sas_header_start_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_zeros(writer, hinfo->pad1); if (retval != READSTAT_OK) goto cleanup; double creation_time = hinfo->creation_time - epoch; retval = readstat_write_bytes(writer, &creation_time, sizeof(double)); if (retval != READSTAT_OK) goto cleanup; double modification_time = hinfo->modification_time - epoch; retval = readstat_write_bytes(writer, &modification_time, sizeof(double)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_zeros(writer, 16); if (retval != READSTAT_OK) goto cleanup; uint32_t header_size = hinfo->header_size; uint32_t page_size = hinfo->page_size; retval = readstat_write_bytes(writer, &header_size, sizeof(uint32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &page_size, sizeof(uint32_t)); if (retval != READSTAT_OK) goto cleanup; if (hinfo->u64) { uint64_t page_count = hinfo->page_count; retval = readstat_write_bytes(writer, &page_count, sizeof(uint64_t)); } else { uint32_t page_count = hinfo->page_count; retval = readstat_write_bytes(writer, &page_count, sizeof(uint32_t)); } if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_zeros(writer, 8); if (retval != READSTAT_OK) goto cleanup; sas_header_end_t header_end = { .host = "9.0401M6Linux" }; char release[sizeof(header_end.release)+1] = { 0 }; snprintf(release, sizeof(release), "%1d.%04dM0", (unsigned int)writer->version % 10, 101); memcpy(header_end.release, release, sizeof(header_end.release)); retval = readstat_write_bytes(writer, &header_end, sizeof(sas_header_end_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_zeros(writer, hinfo->header_size-writer->bytes_written); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } sas_header_info_t *sas_header_info_init(readstat_writer_t *writer, int is_64bit) { sas_header_info_t *hinfo = calloc(1, sizeof(sas_header_info_t)); hinfo->creation_time = writer->timestamp; hinfo->modification_time = writer->timestamp; hinfo->page_size = SAS_DEFAULT_PAGE_SIZE; hinfo->u64 = !!is_64bit; if (hinfo->u64) { hinfo->header_size = SAS_FILE_HEADER_SIZE_64BIT; hinfo->page_header_size = SAS_PAGE_HEADER_SIZE_64BIT; hinfo->subheader_pointer_size = SAS_SUBHEADER_POINTER_SIZE_64BIT; } else { hinfo->header_size = SAS_FILE_HEADER_SIZE_32BIT; hinfo->page_header_size = SAS_PAGE_HEADER_SIZE_32BIT; hinfo->subheader_pointer_size = SAS_SUBHEADER_POINTER_SIZE_32BIT; } return hinfo; } readstat_error_t sas_fill_page(readstat_writer_t *writer, sas_header_info_t *hinfo) { if ((writer->bytes_written - hinfo->header_size) % hinfo->page_size) { size_t num_zeros = (hinfo->page_size - (writer->bytes_written - hinfo->header_size) % hinfo->page_size); return readstat_write_zeros(writer, num_zeros); } return READSTAT_OK; } readstat_error_t sas_validate_name(const char *name, size_t max_len) { int j; for (j=0; name[j]; j++) { if (name[j] != '_' && !(name[j] >= 'a' && name[j] <= 'z') && !(name[j] >= 'A' && name[j] <= 'Z') && !(name[j] >= '0' && name[j] <= '9')) { return READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER; } } char first_char = name[0]; if (!first_char) return READSTAT_ERROR_NAME_IS_ZERO_LENGTH; if (first_char != '_' && !(first_char >= 'a' && first_char <= 'z') && !(first_char >= 'A' && first_char <= 'Z')) { return READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER; } if (strcmp(name, "_N_") == 0 || strcmp(name, "_ERROR_") == 0 || strcmp(name, "_NUMERIC_") == 0 || strcmp(name, "_CHARACTER_") == 0 || strcmp(name, "_ALL_") == 0) { return READSTAT_ERROR_NAME_IS_RESERVED_WORD; } if (strlen(name) > max_len) return READSTAT_ERROR_NAME_IS_TOO_LONG; return READSTAT_OK; } readstat_error_t sas_validate_variable(const readstat_variable_t *variable) { return sas_validate_name(readstat_variable_get_name(variable), 32); } readstat_error_t sas_validate_tag(char tag) { if (tag == '_' || (tag >= 'A' && tag <= 'Z')) return READSTAT_OK; return READSTAT_ERROR_TAGGED_VALUE_IS_OUT_OF_RANGE; } void sas_assign_tag(readstat_value_t *value, uint8_t tag) { /* We accommodate two tag schemes. In the first, the tag is an ASCII code * given by uint8_t tag above. System missing is represented by an ASCII * period. In the second scheme, (tag-2) is an offset from 'A', except when * tag == 0, in which case it represents an underscore, or tag == 1, in * which case it represents system-missing. */ if (tag == 0) { tag = '_'; } else if (tag >= 2 && tag < 28) { tag = 'A' + (tag - 2); } if (sas_validate_tag(tag) == READSTAT_OK) { value->tag = tag; value->is_tagged_missing = 1; } else { value->tag = 0; value->is_system_missing = 1; } } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_sas.h0000644023477200000240000000773114574360757020040 0ustar00fajardoostaffs #include "../readstat.h" #include "../readstat_bits.h" #pragma pack(push, 1) typedef struct sas_header_start_s { unsigned char magic[32]; unsigned char a2; unsigned char mystery1[2]; unsigned char a1; unsigned char mystery2[1]; unsigned char endian; unsigned char mystery3[1]; char file_format; unsigned char mystery4[30]; unsigned char encoding; unsigned char mystery5[13]; char file_type[8]; char table_name[32]; unsigned char mystery6[32]; char file_info[8]; } sas_header_start_t; typedef struct sas_header_end_s { char release[8]; char host[16]; char version[16]; char os_vendor[16]; char os_name[16]; char extra[48]; } sas_header_end_t; #pragma pack(pop) typedef struct sas_header_info_s { int little_endian; int u64; int vendor; int major_version; int minor_version; int revision; int pad1; int64_t page_size; int64_t page_header_size; int64_t subheader_pointer_size; int64_t page_count; int64_t header_size; time_t creation_time; time_t modification_time; char table_name[32]; char file_label[256]; char *encoding; } sas_header_info_t; enum { READSTAT_VENDOR_STAT_TRANSFER, READSTAT_VENDOR_SAS }; typedef struct sas_text_ref_s { uint16_t index; uint16_t offset; uint16_t length; } sas_text_ref_t; #define SAS_ENDIAN_BIG 0x00 #define SAS_ENDIAN_LITTLE 0x01 #define SAS_FILE_FORMAT_UNIX '1' #define SAS_FILE_FORMAT_WINDOWS '2' #define SAS_ALIGNMENT_OFFSET_0 0x22 #define SAS_ALIGNMENT_OFFSET_4 0x33 #define SAS_COLUMN_TYPE_NUM 0x01 #define SAS_COLUMN_TYPE_CHR 0x02 #define SAS_SUBHEADER_SIGNATURE_ROW_SIZE 0xF7F7F7F7 #define SAS_SUBHEADER_SIGNATURE_COLUMN_SIZE 0xF6F6F6F6 #define SAS_SUBHEADER_SIGNATURE_COUNTS 0xFFFFFC00 #define SAS_SUBHEADER_SIGNATURE_COLUMN_FORMAT 0xFFFFFBFE #define SAS_SUBHEADER_SIGNATURE_COLUMN_MASK 0xFFFFFFF8 /* Seen in the wild: FA (unknown), F8 (locale?) */ #define SAS_SUBHEADER_SIGNATURE_COLUMN_ATTRS 0xFFFFFFFC #define SAS_SUBHEADER_SIGNATURE_COLUMN_TEXT 0xFFFFFFFD #define SAS_SUBHEADER_SIGNATURE_COLUMN_LIST 0xFFFFFFFE #define SAS_SUBHEADER_SIGNATURE_COLUMN_NAME 0xFFFFFFFF #define SAS_PAGE_TYPE_META 0x0000 #define SAS_PAGE_TYPE_DATA 0x0100 #define SAS_PAGE_TYPE_MIX 0x0200 #define SAS_PAGE_TYPE_AMD 0x0400 #define SAS_PAGE_TYPE_MASK 0x0F00 #define SAS_PAGE_TYPE_META2 0x4000 #define SAS_PAGE_TYPE_COMP 0x9000 #define SAS_SUBHEADER_POINTER_SIZE_32BIT 12 #define SAS_SUBHEADER_POINTER_SIZE_64BIT 24 #define SAS_PAGE_HEADER_SIZE_32BIT 24 #define SAS_PAGE_HEADER_SIZE_64BIT 40 #define SAS_COMPRESSION_NONE 0x00 #define SAS_COMPRESSION_TRUNC 0x01 #define SAS_COMPRESSION_ROW 0x04 #define SAS_COMPRESSION_SIGNATURE_RLE "SASYZCRL" #define SAS_COMPRESSION_SIGNATURE_RDC "SASYZCR2" #define SAS_DEFAULT_FILE_VERSION 9 extern unsigned char sas7bdat_magic_number[32]; extern unsigned char sas7bcat_magic_number[32]; uint64_t sas_read8(const char *data, int bswap); uint32_t sas_read4(const char *data, int bswap); uint16_t sas_read2(const char *data, int bswap); readstat_error_t sas_read_header(readstat_io_t *io, sas_header_info_t *ctx, readstat_error_handler error_handler, void *user_ctx); size_t sas_subheader_remainder(size_t len, size_t signature_len); sas_header_info_t *sas_header_info_init(readstat_writer_t *writer, int is_64bit); readstat_error_t sas_write_header(readstat_writer_t *writer, sas_header_info_t *hinfo, sas_header_start_t header_start); readstat_error_t sas_fill_page(readstat_writer_t *writer, sas_header_info_t *hinfo); readstat_error_t sas_validate_variable(const readstat_variable_t *variable); readstat_error_t sas_validate_name(const char *name, size_t max_len); readstat_error_t sas_validate_tag(char tag); void sas_assign_tag(readstat_value_t *value, uint8_t tag); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_sas7bcat_read.c0000644023477200000240000004201614574360757021742 0ustar00fajardoostaffs#include #include #include #include #include #include "readstat_sas.h" #include "../readstat_iconv.h" #include "../readstat_convert.h" #include "../readstat_malloc.h" #define SAS_CATALOG_FIRST_INDEX_PAGE 1 #define SAS_CATALOG_USELESS_PAGES 3 typedef struct sas7bcat_ctx_s { readstat_metadata_handler metadata_handler; readstat_value_label_handler value_label_handler; void *user_ctx; readstat_io_t *io; int u64; int pad1; int bswap; int64_t xlsr_size; int64_t xlsr_offset; int64_t xlsr_O_offset; int64_t page_count; int64_t page_size; int64_t header_size; uint64_t *block_pointers; int block_pointers_used; int block_pointers_capacity; const char *input_encoding; const char *output_encoding; iconv_t converter; } sas7bcat_ctx_t; static void sas7bcat_ctx_free(sas7bcat_ctx_t *ctx) { if (ctx->converter) iconv_close(ctx->converter); if (ctx->block_pointers) free(ctx->block_pointers); free(ctx); } static readstat_error_t sas7bcat_parse_value_labels(const char *value_start, size_t value_labels_len, int label_count_used, int label_count_capacity, const char *name, sas7bcat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int i; const char *lbp1 = value_start; uint32_t *value_offset = readstat_calloc(label_count_used, sizeof(uint32_t)); /* Doubles appear to be stored as big-endian, always */ int bswap_doubles = machine_is_little_endian(); int is_string = (name[0] == '$'); char *label = NULL; if (value_offset == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } /* Pass 1 -- find out the offset of the labels */ for (i=0; i value_labels_len || sas_read2(&lbp1[2], ctx->bswap) < 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (ipad1+4] - value_start > value_labels_len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } uint32_t label_pos = sas_read4(&lbp1[10+ctx->pad1], ctx->bswap); if (label_pos >= label_count_used) { retval = READSTAT_ERROR_PARSE; goto cleanup; } value_offset[label_pos] = lbp1 - value_start; } lbp1 += 6 + sas_read2(&lbp1[2], ctx->bswap); } const char *lbp2 = lbp1; /* Pass 2 -- parse pairs of values & labels */ for (i=0; i value_labels_len || &lbp2[10] - value_start > value_labels_len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } readstat_value_t value = { .type = is_string ? READSTAT_TYPE_STRING : READSTAT_TYPE_DOUBLE }; char string_val[4*16+1]; if (is_string) { size_t value_entry_len = 6 + sas_read2(&lbp1[2], ctx->bswap); retval = readstat_convert(string_val, sizeof(string_val), &lbp1[value_entry_len-16], 16, ctx->converter); if (retval != READSTAT_OK) goto cleanup; value.v.string_value = string_val; } else { uint64_t val = sas_read8(&lbp1[22], bswap_doubles); double dval = NAN; if ((val | 0xFF0000000000) == 0xFFFFFFFFFFFF) { sas_assign_tag(&value, (val >> 40)); } else { memcpy(&dval, &val, 8); dval *= -1.0; } value.v.double_value = dval; } size_t label_len = sas_read2(&lbp2[8], ctx->bswap); if (&lbp2[10] + label_len - value_start > value_labels_len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (ctx->value_label_handler) { label = realloc(label, 4 * label_len + 1); retval = readstat_convert(label, 4 * label_len + 1, &lbp2[10], label_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; if (ctx->value_label_handler(name, value, label, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } lbp2 += 8 + 2 + label_len + 1; } cleanup: free(label); free(value_offset); return retval; } static readstat_error_t sas7bcat_parse_block(const char *data, size_t data_size, sas7bcat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; size_t pad = 0; uint64_t label_count_capacity = 0; uint64_t label_count_used = 0; int payload_offset = 106; uint16_t flags = 0; char name[4*32+1]; if (data_size < payload_offset) goto cleanup; flags = sas_read2(&data[2], ctx->bswap); pad = (flags & 0x08) ? 4 : 0; // might be 0x10, not sure if (ctx->u64) { label_count_capacity = sas_read8(&data[42+pad], ctx->bswap); label_count_used = sas_read8(&data[50+pad], ctx->bswap); payload_offset += 32; } else { label_count_capacity = sas_read4(&data[38+pad], ctx->bswap); label_count_used = sas_read4(&data[42+pad], ctx->bswap); } if ((retval = readstat_convert(name, sizeof(name), &data[8], 8, ctx->converter)) != READSTAT_OK) goto cleanup; if (pad) { pad += 16; } if (((flags & 0x80) && !ctx->u64) || ((flags & 0x20) && ctx->u64)) { // has long name if (data_size < payload_offset + pad + 32) goto cleanup; retval = readstat_convert(name, sizeof(name), &data[payload_offset+pad], 32, ctx->converter); if (retval != READSTAT_OK) goto cleanup; pad += 32; } if (data_size < payload_offset + pad) goto cleanup; if (label_count_used == 0) goto cleanup; if ((retval = sas7bcat_parse_value_labels(&data[payload_offset+pad], data_size - payload_offset - pad, label_count_used, label_count_capacity, name, ctx)) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t sas7bcat_augment_index(const char *index, size_t len, sas7bcat_ctx_t *ctx) { const char *xlsr = index; readstat_error_t retval = READSTAT_OK; while (xlsr + ctx->xlsr_size <= index + len) { if (memcmp(xlsr, "XLSR", 4) != 0) // some block pointers seem to have 8 bytes of extra padding xlsr += 8; if (memcmp(xlsr, "XLSR", 4) != 0) break; if (xlsr[ctx->xlsr_O_offset] == 'O') { uint64_t page = 0, pos = 0; if (ctx->u64) { page = sas_read8(&xlsr[8], ctx->bswap); pos = sas_read2(&xlsr[16], ctx->bswap); } else { page = sas_read4(&xlsr[4], ctx->bswap); pos = sas_read2(&xlsr[8], ctx->bswap); } ctx->block_pointers[ctx->block_pointers_used++] = (page << 32) + pos; } if (ctx->block_pointers_used == ctx->block_pointers_capacity) { ctx->block_pointers = readstat_realloc(ctx->block_pointers, (ctx->block_pointers_capacity *= 2) * sizeof(uint64_t)); if (ctx->block_pointers == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } } xlsr += ctx->xlsr_size; } cleanup: return retval; } static int compare_block_pointers(const void *elem1, const void *elem2) { uint64_t v1 = *(const uint64_t *)elem1; uint64_t v2 = *(const uint64_t *)elem2; return v1 - v2; } static void sas7bcat_sort_index(sas7bcat_ctx_t *ctx) { if (ctx->block_pointers_used == 0) return; int i; for (i=1; iblock_pointers_used; i++) { if (ctx->block_pointers[i] < ctx->block_pointers[i-1]) { qsort(ctx->block_pointers, ctx->block_pointers_used, sizeof(uint64_t), &compare_block_pointers); break; } } } static void sas7bcat_uniq_index(sas7bcat_ctx_t *ctx) { if (ctx->block_pointers_used == 0) return; int i; int out_i = 1; for (i=1; iblock_pointers_used; i++) { if (ctx->block_pointers[i] != ctx->block_pointers[i-1]) { if (out_i != i) { ctx->block_pointers[out_i] = ctx->block_pointers[i]; } out_i++; } } ctx->block_pointers_used = out_i; } static int sas7bcat_block_size(int start_page, int start_page_pos, sas7bcat_ctx_t *ctx, readstat_error_t *outError) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; int next_page = start_page; int next_page_pos = start_page_pos; int link_count = 0; int buffer_len = 0; int chain_link_len = 0; char chain_link[32]; int chain_link_header_len = 16; if (ctx->u64) { chain_link_header_len = 32; } // calculate buffer size needed while (next_page > 0 && next_page_pos > 0 && next_page <= ctx->page_count && link_count++ < ctx->page_count) { if (io->seek(ctx->header_size+(next_page-1)*ctx->page_size+next_page_pos, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->read(chain_link, chain_link_header_len, io->io_ctx) < chain_link_header_len) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->u64) { next_page = sas_read4(&chain_link[0], ctx->bswap); next_page_pos = sas_read2(&chain_link[8], ctx->bswap); chain_link_len = sas_read2(&chain_link[10], ctx->bswap); } else { next_page = sas_read4(&chain_link[0], ctx->bswap); next_page_pos = sas_read2(&chain_link[4], ctx->bswap); chain_link_len = sas_read2(&chain_link[6], ctx->bswap); } buffer_len += chain_link_len; } cleanup: if (outError) *outError = retval; return retval == READSTAT_OK ? buffer_len : -1; } static readstat_error_t sas7bcat_read_block(char *buffer, size_t buffer_len, int start_page, int start_page_pos, sas7bcat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; int next_page = start_page; int next_page_pos = start_page_pos; int link_count = 0; int chain_link_len = 0; int buffer_offset = 0; char chain_link[32]; int chain_link_header_len = 16; if (ctx->u64) { chain_link_header_len = 32; } while (next_page > 0 && next_page_pos > 0 && next_page <= ctx->page_count && link_count++ < ctx->page_count) { if (io->seek(ctx->header_size+(next_page-1)*ctx->page_size+next_page_pos, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->read(chain_link, chain_link_header_len, io->io_ctx) < chain_link_header_len) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->u64) { next_page = sas_read4(&chain_link[0], ctx->bswap); next_page_pos = sas_read2(&chain_link[8], ctx->bswap); chain_link_len = sas_read2(&chain_link[10], ctx->bswap); } else { next_page = sas_read4(&chain_link[0], ctx->bswap); next_page_pos = sas_read2(&chain_link[4], ctx->bswap); chain_link_len = sas_read2(&chain_link[6], ctx->bswap); } if (buffer_offset + chain_link_len > buffer_len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (io->read(buffer + buffer_offset, chain_link_len, io->io_ctx) < chain_link_len) { retval = READSTAT_ERROR_READ; goto cleanup; } buffer_offset += chain_link_len; } cleanup: return retval; } readstat_error_t readstat_parse_sas7bcat(readstat_parser_t *parser, const char *path, void *user_ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = parser->io; int64_t i; char *page = NULL; char *buffer = NULL; sas7bcat_ctx_t *ctx = calloc(1, sizeof(sas7bcat_ctx_t)); sas_header_info_t *hinfo = calloc(1, sizeof(sas_header_info_t)); ctx->block_pointers = malloc((ctx->block_pointers_capacity = 200) * sizeof(uint64_t)); ctx->value_label_handler = parser->handlers.value_label; ctx->metadata_handler = parser->handlers.metadata; ctx->input_encoding = parser->input_encoding; ctx->output_encoding = parser->output_encoding; ctx->user_ctx = user_ctx; ctx->io = io; if (io->open(path, io->io_ctx) == -1) { retval = READSTAT_ERROR_OPEN; goto cleanup; } if ((retval = sas_read_header(io, hinfo, parser->handlers.error, user_ctx)) != READSTAT_OK) { goto cleanup; } ctx->u64 = hinfo->u64; ctx->pad1 = hinfo->pad1; ctx->bswap = machine_is_little_endian() ^ hinfo->little_endian; ctx->header_size = hinfo->header_size; ctx->page_count = hinfo->page_count; ctx->page_size = hinfo->page_size; if (ctx->input_encoding == NULL) { ctx->input_encoding = hinfo->encoding; } ctx->xlsr_size = 212 + ctx->pad1; ctx->xlsr_offset = 856 + 2 * ctx->pad1; ctx->xlsr_O_offset = 50 + ctx->pad1; if (ctx->u64) { ctx->xlsr_offset += 144; ctx->xlsr_size += 72; ctx->xlsr_O_offset += 24; } if (ctx->input_encoding && ctx->output_encoding && strcmp(ctx->input_encoding, ctx->output_encoding) != 0) { iconv_t converter = iconv_open(ctx->output_encoding, ctx->input_encoding); if (converter == (iconv_t)-1) { retval = READSTAT_ERROR_UNSUPPORTED_CHARSET; goto cleanup; } ctx->converter = converter; } if (ctx->metadata_handler) { char table_name[4*32+1]; readstat_metadata_t metadata = { .file_encoding = ctx->input_encoding, /* orig encoding? */ .modified_time = hinfo->modification_time, .creation_time = hinfo->creation_time, .file_format_version = hinfo->major_version, .endianness = hinfo->little_endian ? READSTAT_ENDIAN_LITTLE : READSTAT_ENDIAN_BIG, .is64bit = ctx->u64 }; retval = readstat_convert(table_name, sizeof(table_name), hinfo->table_name, sizeof(hinfo->table_name), ctx->converter); if (retval != READSTAT_OK) goto cleanup; metadata.table_name = table_name; if (ctx->metadata_handler(&metadata, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } if ((page = readstat_malloc(ctx->page_size)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (io->seek(ctx->header_size+SAS_CATALOG_FIRST_INDEX_PAGE*ctx->page_size, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->read(page, ctx->page_size, io->io_ctx) < ctx->page_size) { retval = READSTAT_ERROR_READ; goto cleanup; } retval = sas7bcat_augment_index(&page[ctx->xlsr_offset], ctx->page_size - ctx->xlsr_offset, ctx); if (retval != READSTAT_OK) goto cleanup; // Pass 1 -- find the XLSR entries for (i=SAS_CATALOG_USELESS_PAGES; ipage_count; i++) { if (io->seek(ctx->header_size+i*ctx->page_size, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->read(page, ctx->page_size, io->io_ctx) < ctx->page_size) { retval = READSTAT_ERROR_READ; goto cleanup; } if (memcmp(&page[16], "XLSR", sizeof("XLSR")-1) == 0) { retval = sas7bcat_augment_index(&page[16], ctx->page_size - 16, ctx); if (retval != READSTAT_OK) goto cleanup; } } sas7bcat_sort_index(ctx); sas7bcat_uniq_index(ctx); // Pass 2 -- look up the individual block pointers for (i=0; iblock_pointers_used; i++) { int start_page = ctx->block_pointers[i] >> 32; int start_page_pos = (ctx->block_pointers[i]) & 0xFFFF; int buffer_len = sas7bcat_block_size(start_page, start_page_pos, ctx, &retval); if (buffer_len == -1) { goto cleanup; } else if (buffer_len == 0) { continue; } if ((buffer = readstat_realloc(buffer, buffer_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if ((retval = sas7bcat_read_block(buffer, buffer_len, start_page, start_page_pos, ctx)) != READSTAT_OK) goto cleanup; if ((retval = sas7bcat_parse_block(buffer, buffer_len, ctx)) != READSTAT_OK) goto cleanup; } cleanup: io->close(io->io_ctx); if (page) free(page); if (buffer) free(buffer); if (ctx) sas7bcat_ctx_free(ctx); if (hinfo) free(hinfo); return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_sas7bcat_write.c0000644023477200000240000001461514574360757022165 0ustar00fajardoostaffs #include #include #include #include #include "../readstat.h" #include "../readstat_writer.h" #include "readstat_sas.h" #include "readstat_sas_rle.h" typedef struct sas7bcat_block_s { size_t len; char data[1]; // Flexible array; use [1] for C++-98 compatibility } sas7bcat_block_t; static sas7bcat_block_t *sas7bcat_block_for_label_set(readstat_label_set_t *r_label_set) { size_t len = 0; size_t name_len = strlen(r_label_set->name); int j; char name[32]; len += 106; if (name_len > 8) { len += 32; // long name if (name_len > 32) { name_len = 32; } } memcpy(&name[0], r_label_set->name, name_len); for (j=0; jvalue_labels_count; j++) { readstat_value_label_t *value_label = readstat_get_value_label(r_label_set, j); len += 30; // Value: 14-byte header + 16-byte padded value len += 8 + 2 + value_label->label_len + 1; } sas7bcat_block_t *block = calloc(1, sizeof(sas7bcat_block_t) + len); block->len = len; off_t begin = 106; int32_t count = r_label_set->value_labels_count; memcpy(&block->data[38], &count, sizeof(int32_t)); memcpy(&block->data[42], &count, sizeof(int32_t)); if (name_len > 8) { block->data[2] = (char)0x80; memcpy(&block->data[8], name, 8); memset(&block->data[106], ' ', 32); memcpy(&block->data[106], name, name_len); begin += 32; } else { memset(&block->data[8], ' ', 8); memcpy(&block->data[8], name, name_len); } char *lbp1 = &block->data[begin]; char *lbp2 = &block->data[begin+r_label_set->value_labels_count*30]; for (j=0; jvalue_labels_count; j++) { readstat_value_label_t *value_label = readstat_get_value_label(r_label_set, j); lbp1[2] = 24; // size - 6 int32_t index = j; memcpy(&lbp1[10], &index, sizeof(int32_t)); if (r_label_set->type == READSTAT_TYPE_STRING) { size_t string_len = value_label->string_key_len; if (string_len > 16) string_len = 16; memset(&lbp1[14], ' ', 16); memcpy(&lbp1[14], value_label->string_key, string_len); } else { uint64_t big_endian_value; double double_value = -1.0 * value_label->double_key; memcpy(&big_endian_value, &double_value, sizeof(double)); if (machine_is_little_endian()) { big_endian_value = byteswap8(big_endian_value); } memcpy(&lbp1[22], &big_endian_value, sizeof(uint64_t)); } int16_t label_len = value_label->label_len; memcpy(&lbp2[8], &label_len, sizeof(int16_t)); memcpy(&lbp2[10], value_label->label, label_len); lbp1 += 30; lbp2 += 8 + 2 + value_label->label_len + 1; } return block; } static readstat_error_t sas7bcat_emit_header(readstat_writer_t *writer, sas_header_info_t *hinfo) { sas_header_start_t header_start = { .a2 = hinfo->u64 ? SAS_ALIGNMENT_OFFSET_4 : SAS_ALIGNMENT_OFFSET_0, .a1 = SAS_ALIGNMENT_OFFSET_0, .endian = machine_is_little_endian() ? SAS_ENDIAN_LITTLE : SAS_ENDIAN_BIG, .file_format = SAS_FILE_FORMAT_UNIX, .encoding = 20, /* UTF-8 */ .file_type = "SAS FILE", .file_info = "CATALOG " }; memcpy(&header_start.magic, sas7bcat_magic_number, sizeof(header_start.magic)); return sas_write_header(writer, hinfo, header_start); } static readstat_error_t sas7bcat_begin_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; readstat_error_t retval = READSTAT_OK; int i; sas_header_info_t *hinfo = sas_header_info_init(writer, 0); sas7bcat_block_t **blocks = malloc(writer->label_sets_count * sizeof(sas7bcat_block_t)); char *page = malloc(hinfo->page_size); for (i=0; ilabel_sets_count; i++) { blocks[i] = sas7bcat_block_for_label_set(writer->label_sets[i]); } hinfo->page_count = 4; // Header retval = sas7bcat_emit_header(writer, hinfo); if (retval != READSTAT_OK) goto cleanup; // Page 0 retval = readstat_write_zeros(writer, hinfo->page_size); if (retval != READSTAT_OK) goto cleanup; memset(page, '\0', hinfo->page_size); // Page 1 char *xlsr = &page[856]; int16_t block_idx, block_off; block_idx = 4; block_off = 16; for (i=0; ilabel_sets_count; i++) { if (xlsr + 212 > page + hinfo->page_size) break; memcpy(&xlsr[0], "XLSR", 4); memcpy(&xlsr[4], &block_idx, sizeof(int16_t)); memcpy(&xlsr[8], &block_off, sizeof(int16_t)); xlsr[50] = 'O'; block_off += blocks[i]->len; xlsr += 212; } retval = readstat_write_bytes(writer, page, hinfo->page_size); if (retval != READSTAT_OK) goto cleanup; // Page 2 retval = readstat_write_zeros(writer, hinfo->page_size); if (retval != READSTAT_OK) goto cleanup; // Page 3 memset(page, '\0', hinfo->page_size); char block_header[16]; block_off = 16; for (i=0; ilabel_sets_count; i++) { if (block_off + sizeof(block_header) + blocks[i]->len > hinfo->page_size) break; memset(block_header, '\0', sizeof(block_header)); int32_t next_page = 0; int16_t next_off = 0; int16_t block_len = blocks[i]->len; memcpy(&block_header[0], &next_page, sizeof(int32_t)); memcpy(&block_header[4], &next_off, sizeof(int16_t)); memcpy(&block_header[6], &block_len, sizeof(int16_t)); memcpy(&page[block_off], block_header, sizeof(block_header)); block_off += sizeof(block_header); memcpy(&page[block_off], blocks[i]->data, blocks[i]->len); block_off += blocks[i]->len; } retval = readstat_write_bytes(writer, page, hinfo->page_size); if (retval != READSTAT_OK) goto cleanup; cleanup: for (i=0; ilabel_sets_count; i++) { free(blocks[i]); } free(blocks); free(hinfo); free(page); return retval; } readstat_error_t readstat_begin_writing_sas7bcat(readstat_writer_t *writer, void *user_ctx) { if (writer->version == 0) writer->version = SAS_DEFAULT_FILE_VERSION; writer->callbacks.begin_data = &sas7bcat_begin_data; return readstat_begin_writing_file(writer, user_ctx, 0); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_sas7bdat_read.c0000644023477200000240000013251414574360757021746 0ustar00fajardoostaffs #include #include #include #include #include #include #include "readstat_sas.h" #include "readstat_sas_rle.h" #include "../readstat_iconv.h" #include "../readstat_convert.h" #include "../readstat_malloc.h" typedef struct col_info_s { sas_text_ref_t name_ref; sas_text_ref_t format_ref; sas_text_ref_t label_ref; int index; uint64_t offset; uint32_t width; int type; int format_len; } col_info_t; typedef struct subheader_pointer_s { uint64_t offset; uint64_t len; unsigned char compression; unsigned char is_compressed_data; } subheader_pointer_t; typedef struct sas7bdat_ctx_s { readstat_callbacks_t handle; int64_t file_size; int little_endian; int u64; int vendor; void *user_ctx; readstat_io_t *io; int bswap; int did_submit_columns; uint32_t row_length; uint32_t page_row_count; uint32_t parsed_row_count; uint32_t column_count; uint32_t row_limit; uint32_t row_offset; uint64_t header_size; uint64_t page_count; uint64_t page_size; char *page; char *row; uint64_t page_header_size; uint64_t subheader_signature_size; uint64_t subheader_pointer_size; int text_blob_count; size_t *text_blob_lengths; char **text_blobs; int col_names_count; int col_attrs_count; int col_formats_count; size_t max_col_width; char *scratch_buffer; size_t scratch_buffer_len; int col_info_count; col_info_t *col_info; readstat_variable_t **variables; const char *input_encoding; const char *output_encoding; iconv_t converter; time_t ctime; time_t mtime; int version; char table_name[4*32+1]; char file_label[4*256+1]; char error_buf[2048]; unsigned int rdc_compression:1; } sas7bdat_ctx_t; static void sas7bdat_ctx_free(sas7bdat_ctx_t *ctx) { int i; if (ctx->text_blobs) { for (i=0; itext_blob_count; i++) { free(ctx->text_blobs[i]); } free(ctx->text_blobs); free(ctx->text_blob_lengths); } if (ctx->variables) { for (i=0; icolumn_count; i++) { if (ctx->variables[i]) free(ctx->variables[i]); } free(ctx->variables); } if (ctx->col_info) free(ctx->col_info); if (ctx->scratch_buffer) free(ctx->scratch_buffer); if (ctx->page) free(ctx->page); if (ctx->row) free(ctx->row); if (ctx->converter) iconv_close(ctx->converter); free(ctx); } static readstat_error_t sas7bdat_update_progress(sas7bdat_ctx_t *ctx) { readstat_io_t *io = ctx->io; return io->update(ctx->file_size, ctx->handle.progress, ctx->user_ctx, io->io_ctx); } static sas_text_ref_t sas7bdat_parse_text_ref(const char *data, sas7bdat_ctx_t *ctx) { sas_text_ref_t ref; ref.index = sas_read2(&data[0], ctx->bswap); ref.offset = sas_read2(&data[2], ctx->bswap); ref.length = sas_read2(&data[4], ctx->bswap); return ref; } static readstat_error_t sas7bdat_copy_text_ref(char *out_buffer, size_t out_buffer_len, sas_text_ref_t text_ref, sas7bdat_ctx_t *ctx) { if (text_ref.index >= ctx->text_blob_count) return READSTAT_ERROR_PARSE; if (text_ref.length == 0) { out_buffer[0] = '\0'; return READSTAT_OK; } char *blob = ctx->text_blobs[text_ref.index]; if (text_ref.offset + text_ref.length > ctx->text_blob_lengths[text_ref.index]) return READSTAT_ERROR_PARSE; return readstat_convert(out_buffer, out_buffer_len, &blob[text_ref.offset], text_ref.length, ctx->converter); } static readstat_error_t sas7bdat_parse_column_text_subheader(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; size_t signature_len = ctx->subheader_signature_size; uint16_t remainder = sas_read2(&subheader[signature_len], ctx->bswap); char *blob = NULL; if (remainder != sas_subheader_remainder(len, signature_len)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } ctx->text_blob_count++; ctx->text_blobs = readstat_realloc(ctx->text_blobs, ctx->text_blob_count * sizeof(char *)); ctx->text_blob_lengths = readstat_realloc(ctx->text_blob_lengths, ctx->text_blob_count * sizeof(ctx->text_blob_lengths[0])); if (ctx->text_blobs == NULL || ctx->text_blob_lengths == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if ((blob = readstat_malloc(len-signature_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } memcpy(blob, subheader+signature_len, len-signature_len); ctx->text_blob_lengths[ctx->text_blob_count-1] = len-signature_len; ctx->text_blobs[ctx->text_blob_count-1] = blob; cleanup: return retval; } static readstat_error_t sas7bdat_realloc_col_info(sas7bdat_ctx_t *ctx, size_t count) { if (ctx->col_info_count < count) { size_t old_count = ctx->col_info_count; ctx->col_info_count = count; ctx->col_info = readstat_realloc(ctx->col_info, ctx->col_info_count * sizeof(col_info_t)); if (ctx->col_info == NULL) { return READSTAT_ERROR_MALLOC; } memset(ctx->col_info + old_count, 0, (count - old_count) * sizeof(col_info_t)); } return READSTAT_OK; } static readstat_error_t sas7bdat_parse_column_size_subheader(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { uint64_t col_count; readstat_error_t retval = READSTAT_OK; if (ctx->column_count || ctx->did_submit_columns) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (len < (ctx->u64 ? 16 : 8)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (ctx->u64) { col_count = sas_read8(&subheader[8], ctx->bswap); } else { col_count = sas_read4(&subheader[4], ctx->bswap); } ctx->column_count = col_count; retval = sas7bdat_realloc_col_info(ctx, ctx->column_count); cleanup: return retval; } static readstat_error_t sas7bdat_parse_row_size_subheader(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; uint64_t total_row_count; uint64_t row_length, page_row_count; if (len < (ctx->u64 ? 250: 190)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (ctx->u64) { row_length = sas_read8(&subheader[40], ctx->bswap); total_row_count = sas_read8(&subheader[48], ctx->bswap); page_row_count = sas_read8(&subheader[120], ctx->bswap); } else { row_length = sas_read4(&subheader[20], ctx->bswap); total_row_count = sas_read4(&subheader[24], ctx->bswap); page_row_count = sas_read4(&subheader[60], ctx->bswap); } sas_text_ref_t file_label_ref = sas7bdat_parse_text_ref(&subheader[len-130], ctx); if (file_label_ref.length) { if ((retval = sas7bdat_copy_text_ref(ctx->file_label, sizeof(ctx->file_label), file_label_ref, ctx)) != READSTAT_OK) { goto cleanup; } } sas_text_ref_t compression_ref = sas7bdat_parse_text_ref(&subheader[len-118], ctx); if (compression_ref.length) { char compression[9]; if ((retval = sas7bdat_copy_text_ref(compression, sizeof(compression), compression_ref, ctx)) != READSTAT_OK) { goto cleanup; } ctx->rdc_compression = (memcmp(compression, SAS_COMPRESSION_SIGNATURE_RDC, 8) == 0); } ctx->row_length = row_length; ctx->row = readstat_realloc(ctx->row, ctx->row_length); if (ctx->row == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } ctx->page_row_count = page_row_count; uint64_t total_row_count_after_skipping = total_row_count; if (total_row_count > ctx->row_offset) { total_row_count_after_skipping -= ctx->row_offset; } else { total_row_count_after_skipping = 0; ctx->row_offset = total_row_count; } if (ctx->row_limit == 0 || total_row_count_after_skipping < ctx->row_limit) ctx->row_limit = total_row_count_after_skipping; cleanup: return retval; } static readstat_error_t sas7bdat_parse_column_name_subheader(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; size_t signature_len = ctx->subheader_signature_size; int cmax = ctx->u64 ? (len-28)/8 : (len-20)/8; int i; const char *cnp = &subheader[signature_len+8]; uint16_t remainder = sas_read2(&subheader[signature_len], ctx->bswap); if (remainder != sas_subheader_remainder(len, signature_len)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } ctx->col_names_count += cmax; if ((retval = sas7bdat_realloc_col_info(ctx, ctx->col_names_count)) != READSTAT_OK) goto cleanup; for (i=ctx->col_names_count-cmax; icol_names_count; i++) { ctx->col_info[i].name_ref = sas7bdat_parse_text_ref(cnp, ctx); cnp += 8; } cleanup: return retval; } static readstat_error_t sas7bdat_parse_column_attributes_subheader(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; size_t signature_len = ctx->subheader_signature_size; int cmax = ctx->u64 ? (len-28)/16 : (len-20)/12; int i; const char *cap = &subheader[signature_len+8]; uint16_t remainder = sas_read2(&subheader[signature_len], ctx->bswap); if (remainder != sas_subheader_remainder(len, signature_len)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } ctx->col_attrs_count += cmax; if ((retval = sas7bdat_realloc_col_info(ctx, ctx->col_attrs_count)) != READSTAT_OK) goto cleanup; for (i=ctx->col_attrs_count-cmax; icol_attrs_count; i++) { if (ctx->u64) { ctx->col_info[i].offset = sas_read8(&cap[0], ctx->bswap); } else { ctx->col_info[i].offset = sas_read4(&cap[0], ctx->bswap); } readstat_off_t off=4; if (ctx->u64) off=8; ctx->col_info[i].width = sas_read4(&cap[off], ctx->bswap); if (ctx->col_info[i].width > ctx->max_col_width) ctx->max_col_width = ctx->col_info[i].width; if (cap[off+6] == SAS_COLUMN_TYPE_NUM) { ctx->col_info[i].type = READSTAT_TYPE_DOUBLE; } else if (cap[off+6] == SAS_COLUMN_TYPE_CHR) { ctx->col_info[i].type = READSTAT_TYPE_STRING; } else { retval = READSTAT_ERROR_PARSE; goto cleanup; } ctx->col_info[i].index = i; cap += off+8; } cleanup: return retval; } static readstat_error_t sas7bdat_parse_column_format_subheader(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; if (len < (ctx->u64 ? 58 : 46)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } ctx->col_formats_count++; if ((retval = sas7bdat_realloc_col_info(ctx, ctx->col_formats_count)) != READSTAT_OK) goto cleanup; if (ctx->u64) ctx->col_info[ctx->col_formats_count-1].format_len = sas_read2(&subheader[24], ctx->bswap); ctx->col_info[ctx->col_formats_count-1].format_ref = sas7bdat_parse_text_ref( ctx->u64 ? &subheader[46] : &subheader[34], ctx); ctx->col_info[ctx->col_formats_count-1].label_ref = sas7bdat_parse_text_ref( ctx->u64 ? &subheader[52] : &subheader[40], ctx); cleanup: return retval; } static readstat_error_t sas7bdat_handle_data_value(readstat_variable_t *variable, col_info_t *col_info, const char *col_data, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int cb_retval = 0; readstat_value_t value; memset(&value, 0, sizeof(readstat_value_t)); value.type = col_info->type; if (col_info->type == READSTAT_TYPE_STRING) { retval = readstat_convert(ctx->scratch_buffer, ctx->scratch_buffer_len, col_data, col_info->width, ctx->converter); if (retval != READSTAT_OK) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Error converting string (row=%u, col=%u) to specified encoding: %.*s", ctx->parsed_row_count+1, col_info->index+1, col_info->width, col_data); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } value.v.string_value = ctx->scratch_buffer; } else if (col_info->type == READSTAT_TYPE_DOUBLE) { uint64_t val = 0; double dval = NAN; if (ctx->little_endian) { int k; for (k=0; kwidth; k++) { val = (val << 8) | (unsigned char)col_data[col_info->width-1-k]; } } else { int k; for (k=0; kwidth; k++) { val = (val << 8) | (unsigned char)col_data[k]; } } val <<= (8-col_info->width)*8; memcpy(&dval, &val, 8); if (isnan(dval)) { value.v.double_value = NAN; sas_assign_tag(&value, ~((val >> 40) & 0xFF)); } else { value.v.double_value = dval; } } cb_retval = ctx->handle.value(ctx->parsed_row_count, variable, value, ctx->user_ctx); if (cb_retval != READSTAT_HANDLER_OK) retval = READSTAT_ERROR_USER_ABORT; cleanup: return retval; } static readstat_error_t sas7bdat_parse_single_row(const char *data, sas7bdat_ctx_t *ctx) { if (ctx->parsed_row_count == ctx->row_limit) return READSTAT_OK; if (ctx->row_offset) { ctx->row_offset--; return READSTAT_OK; } readstat_error_t retval = READSTAT_OK; int j; if (ctx->handle.value) { ctx->scratch_buffer_len = 4*ctx->max_col_width+1; ctx->scratch_buffer = readstat_realloc(ctx->scratch_buffer, ctx->scratch_buffer_len); if (ctx->scratch_buffer == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } for (j=0; jcolumn_count; j++) { col_info_t *col_info = &ctx->col_info[j]; readstat_variable_t *variable = ctx->variables[j]; if (variable->skip) continue; if (col_info->offset > ctx->row_length || col_info->offset + col_info->width > ctx->row_length) { retval = READSTAT_ERROR_PARSE; goto cleanup; } retval = sas7bdat_handle_data_value(variable, col_info, &data[col_info->offset], ctx); if (retval != READSTAT_OK) { goto cleanup; } } } ctx->parsed_row_count++; cleanup: return retval; } static readstat_error_t sas7bdat_parse_rows(const char *data, size_t len, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int i; size_t row_offset=0; for (i=0; ipage_row_count && ctx->parsed_row_count < ctx->row_limit; i++) { if (row_offset + ctx->row_length > len) { retval = READSTAT_ERROR_ROW_WIDTH_MISMATCH; goto cleanup; } if ((retval = sas7bdat_parse_single_row(&data[row_offset], ctx)) != READSTAT_OK) goto cleanup; row_offset += ctx->row_length; } cleanup: return retval; } static readstat_error_t sas7bdat_parse_subheader_rdc(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; const unsigned char *input = (const unsigned char *)subheader; char *buffer = malloc(ctx->row_length); char *output = buffer; while (input + 2 <= (const unsigned char *)subheader + len) { int i; unsigned short prefix = (input[0] << 8) + input[1]; input += 2; for (i=0; i<16; i++) { if ((prefix & (1 << (15 - i))) == 0) { if (input + 1 > (const unsigned char *)subheader + len) { break; } if (output + 1 > buffer + ctx->row_length) { retval = READSTAT_ERROR_ROW_WIDTH_MISMATCH; goto cleanup; } *output++ = *input++; continue; } if (input + 2 > (const unsigned char *)subheader + len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } unsigned char marker_byte = *input++; unsigned char next_byte = *input++; size_t insert_len = 0, copy_len = 0; unsigned char insert_byte = 0x00; size_t back_offset = 0; if (marker_byte <= 0x0F) { insert_len = 3 + marker_byte; insert_byte = next_byte; } else if ((marker_byte >> 4) == 1) { if (input + 1 > (const unsigned char *)subheader + len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } insert_len = 19 + (marker_byte & 0x0F) + next_byte * 16; insert_byte = *input++; } else if ((marker_byte >> 4) == 2) { if (input + 1 > (const unsigned char *)subheader + len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } copy_len = 16 + (*input++); back_offset = 3 + (marker_byte & 0x0F) + next_byte * 16; } else { copy_len = (marker_byte >> 4); back_offset = 3 + (marker_byte & 0x0F) + next_byte * 16; } if (insert_len) { if (output + insert_len > buffer + ctx->row_length) { retval = READSTAT_ERROR_ROW_WIDTH_MISMATCH; goto cleanup; } memset(output, insert_byte, insert_len); output += insert_len; } else if (copy_len) { if (output - buffer < back_offset || copy_len > back_offset) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (output + copy_len > buffer + ctx->row_length) { retval = READSTAT_ERROR_ROW_WIDTH_MISMATCH; goto cleanup; } memcpy(output, output - back_offset, copy_len); output += copy_len; } } } if (output - buffer != ctx->row_length) { retval = READSTAT_ERROR_ROW_WIDTH_MISMATCH; goto cleanup; } retval = sas7bdat_parse_single_row(buffer, ctx); cleanup: free(buffer); return retval; } static readstat_error_t sas7bdat_parse_subheader_rle(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { if (ctx->row_limit == ctx->parsed_row_count) return READSTAT_OK; readstat_error_t retval = READSTAT_OK; ssize_t bytes_decompressed = 0; bytes_decompressed = sas_rle_decompress(ctx->row, ctx->row_length, subheader, len); if (bytes_decompressed != ctx->row_length) { retval = READSTAT_ERROR_ROW_WIDTH_MISMATCH; if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Row #%d decompressed to %ld bytes (expected %d bytes)", ctx->parsed_row_count, (long)(bytes_decompressed), ctx->row_length); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } retval = sas7bdat_parse_single_row(ctx->row, ctx); cleanup: return retval; } static readstat_error_t sas7bdat_parse_subheader_compressed(const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { if (ctx->rdc_compression) return sas7bdat_parse_subheader_rdc(subheader, len, ctx); return sas7bdat_parse_subheader_rle(subheader, len, ctx); } static readstat_error_t sas7bdat_parse_subheader(uint32_t signature, const char *subheader, size_t len, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; if (len < 2 + ctx->subheader_signature_size) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (signature == SAS_SUBHEADER_SIGNATURE_ROW_SIZE) { retval = sas7bdat_parse_row_size_subheader(subheader, len, ctx); } else if (signature == SAS_SUBHEADER_SIGNATURE_COLUMN_SIZE) { retval = sas7bdat_parse_column_size_subheader(subheader, len, ctx); } else if (signature == SAS_SUBHEADER_SIGNATURE_COUNTS) { /* void */ } else if (signature == SAS_SUBHEADER_SIGNATURE_COLUMN_TEXT) { retval = sas7bdat_parse_column_text_subheader(subheader, len, ctx); } else if (signature == SAS_SUBHEADER_SIGNATURE_COLUMN_NAME) { retval = sas7bdat_parse_column_name_subheader(subheader, len, ctx); } else if (signature == SAS_SUBHEADER_SIGNATURE_COLUMN_ATTRS) { retval = sas7bdat_parse_column_attributes_subheader(subheader, len, ctx); } else if (signature == SAS_SUBHEADER_SIGNATURE_COLUMN_FORMAT) { retval = sas7bdat_parse_column_format_subheader(subheader, len, ctx); } else if (signature == SAS_SUBHEADER_SIGNATURE_COLUMN_LIST) { /* void */ } else if ((signature & SAS_SUBHEADER_SIGNATURE_COLUMN_MASK) == SAS_SUBHEADER_SIGNATURE_COLUMN_MASK) { /* void */ } else { retval = READSTAT_ERROR_PARSE; } cleanup: return retval; } static readstat_error_t sas7bdat_validate_column(col_info_t *col_info) { if (col_info->type == READSTAT_TYPE_DOUBLE) { if (col_info->width > 8 || col_info->width < 3) { return READSTAT_ERROR_PARSE; } } if (col_info->type == READSTAT_TYPE_STRING) { if (col_info->width > INT16_MAX || col_info->width == 0) { return READSTAT_ERROR_PARSE; } } return READSTAT_OK; } static readstat_variable_t *sas7bdat_init_variable(sas7bdat_ctx_t *ctx, int i, int index_after_skipping, readstat_error_t *out_retval) { readstat_error_t retval = READSTAT_OK; readstat_variable_t *variable = readstat_calloc(1, sizeof(readstat_variable_t)); variable->index = i; variable->index_after_skipping = index_after_skipping; variable->type = ctx->col_info[i].type; variable->storage_width = ctx->col_info[i].width; if ((retval = sas7bdat_validate_column(&ctx->col_info[i])) != READSTAT_OK) { goto cleanup; } if ((retval = sas7bdat_copy_text_ref(variable->name, sizeof(variable->name), ctx->col_info[i].name_ref, ctx)) != READSTAT_OK) { goto cleanup; } if ((retval = sas7bdat_copy_text_ref(variable->format, sizeof(variable->format), ctx->col_info[i].format_ref, ctx)) != READSTAT_OK) { goto cleanup; } size_t len = strlen(variable->format); if (len && ctx->col_info[i].format_len) { snprintf(variable->format + len, sizeof(variable->format) - len, "%d", ctx->col_info[i].format_len); } if ((retval = sas7bdat_copy_text_ref(variable->label, sizeof(variable->label), ctx->col_info[i].label_ref, ctx)) != READSTAT_OK) { goto cleanup; } cleanup: if (retval != READSTAT_OK) { if (out_retval) *out_retval = retval; if (retval == READSTAT_ERROR_CONVERT_BAD_STRING) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Error converting variable #%d info to specified encoding: %s %s (%s)", i, variable->name, variable->format, variable->label); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } } free(variable); return NULL; } return variable; } static readstat_error_t sas7bdat_submit_columns(sas7bdat_ctx_t *ctx, int compressed) { readstat_error_t retval = READSTAT_OK; if (ctx->handle.metadata) { readstat_metadata_t metadata = { .row_count = ctx->row_limit, .var_count = ctx->column_count, .table_name = ctx->table_name, .file_label = ctx->file_label, .file_encoding = ctx->input_encoding, /* orig encoding? */ .creation_time = ctx->ctime, .modified_time = ctx->mtime, .file_format_version = ctx->version, .compression = READSTAT_COMPRESS_NONE, .endianness = ctx->little_endian ? READSTAT_ENDIAN_LITTLE : READSTAT_ENDIAN_BIG, .is64bit = ctx->u64 }; if (compressed) { if (ctx->rdc_compression) { metadata.compression = READSTAT_COMPRESS_BINARY; } else { metadata.compression = READSTAT_COMPRESS_ROWS; } } if (ctx->handle.metadata(&metadata, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } if (ctx->column_count == 0) goto cleanup; if ((ctx->variables = readstat_calloc(ctx->column_count, sizeof(readstat_variable_t *))) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } int i; int index_after_skipping = 0; for (i=0; icolumn_count; i++) { ctx->variables[i] = sas7bdat_init_variable(ctx, i, index_after_skipping, &retval); if (ctx->variables[i] == NULL) break; int cb_retval = READSTAT_HANDLER_OK; if (ctx->handle.variable) { cb_retval = ctx->handle.variable(i, ctx->variables[i], ctx->variables[i]->format, ctx->user_ctx); } if (cb_retval == READSTAT_HANDLER_ABORT) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } if (cb_retval == READSTAT_HANDLER_SKIP_VARIABLE) { ctx->variables[i]->skip = 1; } else { index_after_skipping++; } } cleanup: return retval; } static readstat_error_t sas7bdat_submit_columns_if_needed(sas7bdat_ctx_t *ctx, int compressed) { readstat_error_t retval = READSTAT_OK; if (!ctx->did_submit_columns) { if ((retval = sas7bdat_submit_columns(ctx, compressed)) != READSTAT_OK) { goto cleanup; } ctx->did_submit_columns = 1; } cleanup: return retval; } static int sas7bdat_signature_is_recognized(uint32_t signature) { return (signature == SAS_SUBHEADER_SIGNATURE_ROW_SIZE || signature == SAS_SUBHEADER_SIGNATURE_COLUMN_SIZE || signature == SAS_SUBHEADER_SIGNATURE_COUNTS || signature == SAS_SUBHEADER_SIGNATURE_COLUMN_FORMAT || (signature & SAS_SUBHEADER_SIGNATURE_COLUMN_MASK) == SAS_SUBHEADER_SIGNATURE_COLUMN_MASK); } static readstat_error_t sas7bdat_parse_subheader_pointer(const char *shp, size_t shp_size, subheader_pointer_t *info, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; if (ctx->u64) { if (shp_size <= 17) { retval = READSTAT_ERROR_PARSE; goto cleanup; } info->offset = sas_read8(&shp[0], ctx->bswap); info->len = sas_read8(&shp[8], ctx->bswap); info->compression = shp[16]; info->is_compressed_data = shp[17]; } else { if (shp_size <= 9) { retval = READSTAT_ERROR_PARSE; goto cleanup; } info->offset = sas_read4(&shp[0], ctx->bswap); info->len = sas_read4(&shp[4], ctx->bswap); info->compression = shp[8]; info->is_compressed_data = shp[9]; } cleanup: return retval; } static readstat_error_t sas7bdat_validate_subheader_pointer(subheader_pointer_t *shp_info, size_t page_size, uint16_t subheader_count, sas7bdat_ctx_t *ctx) { if (shp_info->offset > page_size) return READSTAT_ERROR_PARSE; if (shp_info->len > page_size) return READSTAT_ERROR_PARSE; if (shp_info->offset + shp_info->len > page_size) return READSTAT_ERROR_PARSE; if (shp_info->offset < ctx->page_header_size + subheader_count*ctx->subheader_pointer_size) return READSTAT_ERROR_PARSE; if (shp_info->compression == SAS_COMPRESSION_NONE) { if (shp_info->len < ctx->subheader_signature_size) return READSTAT_ERROR_PARSE; if (shp_info->offset + ctx->subheader_signature_size > page_size) return READSTAT_ERROR_PARSE; } return READSTAT_OK; } /* First, extract column text */ static readstat_error_t sas7bdat_parse_page_pass1(const char *page, size_t page_size, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; uint16_t subheader_count = sas_read2(&page[ctx->page_header_size-4], ctx->bswap); int i; const char *shp = &page[ctx->page_header_size]; int lshp = ctx->subheader_pointer_size; if (ctx->page_header_size + subheader_count*lshp > page_size) { retval = READSTAT_ERROR_PARSE; goto cleanup; } for (i=0; isubheader_signature_size; if ((retval = sas7bdat_parse_subheader_pointer(shp, page + page_size - shp, &shp_info, ctx)) != READSTAT_OK) { goto cleanup; } if (shp_info.len > 0 && shp_info.compression != SAS_COMPRESSION_TRUNC) { if ((retval = sas7bdat_validate_subheader_pointer(&shp_info, page_size, subheader_count, ctx)) != READSTAT_OK) { goto cleanup; } if (shp_info.compression == SAS_COMPRESSION_NONE) { signature = sas_read4(page + shp_info.offset, ctx->bswap); if (!ctx->little_endian && signature == -1 && signature_len == 8) { signature = sas_read4(page + shp_info.offset + 4, ctx->bswap); } if (signature == SAS_SUBHEADER_SIGNATURE_COLUMN_TEXT) { if ((retval = sas7bdat_parse_subheader(signature, page + shp_info.offset, shp_info.len, ctx)) != READSTAT_OK) { goto cleanup; } } } else if (shp_info.compression == SAS_COMPRESSION_ROW) { /* void */ } else { retval = READSTAT_ERROR_UNSUPPORTED_COMPRESSION; goto cleanup; } } shp += lshp; } cleanup: return retval; } static readstat_error_t sas7bdat_parse_page_pass2(const char *page, size_t page_size, sas7bdat_ctx_t *ctx) { uint16_t page_type; readstat_error_t retval = READSTAT_OK; page_type = sas_read2(&page[ctx->page_header_size-8], ctx->bswap); const char *data = NULL; if ((page_type & SAS_PAGE_TYPE_MASK) == SAS_PAGE_TYPE_DATA) { ctx->page_row_count = sas_read2(&page[ctx->page_header_size-6], ctx->bswap); data = &page[ctx->page_header_size]; } else if (!(page_type & SAS_PAGE_TYPE_COMP)) { uint16_t subheader_count = sas_read2(&page[ctx->page_header_size-4], ctx->bswap); int i; const char *shp = &page[ctx->page_header_size]; int lshp = ctx->subheader_pointer_size; if (ctx->page_header_size + subheader_count*lshp > page_size) { retval = READSTAT_ERROR_PARSE; goto cleanup; } for (i=0; i 0 && shp_info.compression != SAS_COMPRESSION_TRUNC) { if ((retval = sas7bdat_validate_subheader_pointer(&shp_info, page_size, subheader_count, ctx)) != READSTAT_OK) { goto cleanup; } if (shp_info.compression == SAS_COMPRESSION_NONE) { signature = sas_read4(page + shp_info.offset, ctx->bswap); if (!ctx->little_endian && signature == -1 && ctx->u64) { signature = sas_read4(page + shp_info.offset + 4, ctx->bswap); } if (shp_info.is_compressed_data && !sas7bdat_signature_is_recognized(signature)) { if (shp_info.len != ctx->row_length) { retval = READSTAT_ERROR_ROW_WIDTH_MISMATCH; goto cleanup; } if ((retval = sas7bdat_submit_columns_if_needed(ctx, 1)) != READSTAT_OK) { goto cleanup; } if ((retval = sas7bdat_parse_single_row(page + shp_info.offset, ctx)) != READSTAT_OK) { goto cleanup; } } else { if (signature != SAS_SUBHEADER_SIGNATURE_COLUMN_TEXT) { if ((retval = sas7bdat_parse_subheader(signature, page + shp_info.offset, shp_info.len, ctx)) != READSTAT_OK) { goto cleanup; } } } } else if (shp_info.compression == SAS_COMPRESSION_ROW) { if ((retval = sas7bdat_submit_columns_if_needed(ctx, 1)) != READSTAT_OK) { goto cleanup; } if ((retval = sas7bdat_parse_subheader_compressed(page + shp_info.offset, shp_info.len, ctx)) != READSTAT_OK) { goto cleanup; } } else { retval = READSTAT_ERROR_UNSUPPORTED_COMPRESSION; goto cleanup; } } shp += lshp; } if ((page_type & SAS_PAGE_TYPE_MASK) == SAS_PAGE_TYPE_MIX) { /* HACK - this is supposed to obey 8-byte boundaries but * some files created by Stat/Transfer don't. So verify that the * padding is { 0, 0, 0, 0 } or { ' ', ' ', ' ', ' ' } (or that * the file is not from Stat/Transfer) before skipping it */ if ((shp-page)%8 == 4 && shp + 4 <= page + page_size && (*(uint32_t *)shp == 0x00000000 || *(uint32_t *)shp == 0x20202020 || ctx->vendor != READSTAT_VENDOR_STAT_TRANSFER)) { data = shp + 4; } else { data = shp; } } } if (data) { if ((retval = sas7bdat_submit_columns_if_needed(ctx, 0)) != READSTAT_OK) { goto cleanup; } if (ctx->handle.value) { retval = sas7bdat_parse_rows(data, page + page_size - data, ctx); } } cleanup: return retval; } static readstat_error_t sas7bdat_parse_meta_pages_pass1(sas7bdat_ctx_t *ctx, int64_t *outLastExaminedPage) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; int64_t i; /* look for META and MIX pages at beginning... */ for (i=0; ipage_count; i++) { if (io->seek(ctx->header_size + i*ctx->page_size, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Failed to seek to position %" PRId64 " (= %" PRId64 " + %" PRId64 "*%" PRId64 ")", ctx->header_size + i*ctx->page_size, ctx->header_size, i, ctx->page_size); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } readstat_off_t off = 0; if (ctx->u64) off = 16; size_t head_len = off + 16 + 2; size_t tail_len = ctx->page_size - head_len; if (io->read(ctx->page, head_len, io->io_ctx) < head_len) { retval = READSTAT_ERROR_READ; goto cleanup; } uint16_t page_type = sas_read2(&ctx->page[off+16], ctx->bswap); if ((page_type & SAS_PAGE_TYPE_MASK) == SAS_PAGE_TYPE_DATA) break; if ((page_type & SAS_PAGE_TYPE_COMP)) continue; if (io->read(ctx->page + head_len, tail_len, io->io_ctx) < tail_len) { retval = READSTAT_ERROR_READ; goto cleanup; } if ((retval = sas7bdat_parse_page_pass1(ctx->page, ctx->page_size, ctx)) != READSTAT_OK) { if (ctx->handle.error && retval != READSTAT_ERROR_USER_ABORT) { int64_t pos = io->seek(0, READSTAT_SEEK_CUR, io->io_ctx); snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Error parsing page %" PRId64 ", bytes %" PRId64 "-%" PRId64, i, pos - ctx->page_size, pos-1); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } } cleanup: if (outLastExaminedPage) *outLastExaminedPage = i; return retval; } static readstat_error_t sas7bdat_parse_amd_pages_pass1(int64_t last_examined_page_pass1, sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; uint64_t i; uint64_t amd_page_count = 0; /* ...then AMD pages at the end */ for (i=ctx->page_count-1; i>last_examined_page_pass1; i--) { if (io->seek(ctx->header_size + i*ctx->page_size, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Failed to seek to position %" PRId64 " (= %" PRId64 " + %" PRId64 "*%" PRId64 ")", ctx->header_size + i*ctx->page_size, ctx->header_size, i, ctx->page_size); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } readstat_off_t off = 0; if (ctx->u64) off = 16; size_t head_len = off + 16 + 2; size_t tail_len = ctx->page_size - head_len; if (io->read(ctx->page, head_len, io->io_ctx) < head_len) { retval = READSTAT_ERROR_READ; goto cleanup; } uint16_t page_type = sas_read2(&ctx->page[off+16], ctx->bswap); if ((page_type & SAS_PAGE_TYPE_MASK) == SAS_PAGE_TYPE_DATA) { /* Usually AMD pages are at the end but sometimes data pages appear after them */ if (amd_page_count > 0) break; continue; } if ((page_type & SAS_PAGE_TYPE_COMP)) continue; if (io->read(ctx->page + head_len, tail_len, io->io_ctx) < tail_len) { retval = READSTAT_ERROR_READ; goto cleanup; } if ((retval = sas7bdat_parse_page_pass1(ctx->page, ctx->page_size, ctx)) != READSTAT_OK) { if (ctx->handle.error && retval != READSTAT_ERROR_USER_ABORT) { int64_t pos = io->seek(0, READSTAT_SEEK_CUR, io->io_ctx); snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Error parsing page %" PRId64 ", bytes %" PRId64 "-%" PRId64, i, pos - ctx->page_size, pos-1); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } amd_page_count++; } cleanup: return retval; } static readstat_error_t sas7bdat_parse_all_pages_pass2(sas7bdat_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; int64_t i; for (i=0; ipage_count; i++) { if ((retval = sas7bdat_update_progress(ctx)) != READSTAT_OK) { goto cleanup; } if (io->read(ctx->page, ctx->page_size, io->io_ctx) < ctx->page_size) { retval = READSTAT_ERROR_READ; goto cleanup; } if ((retval = sas7bdat_parse_page_pass2(ctx->page, ctx->page_size, ctx)) != READSTAT_OK) { if (ctx->handle.error && retval != READSTAT_ERROR_USER_ABORT) { int64_t pos = io->seek(0, READSTAT_SEEK_CUR, io->io_ctx); snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Error parsing page %" PRId64 ", bytes %" PRId64 "-%" PRId64, i, pos - ctx->page_size, pos-1); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } if (ctx->parsed_row_count == ctx->row_limit) break; } cleanup: return retval; } readstat_error_t readstat_parse_sas7bdat(readstat_parser_t *parser, const char *path, void *user_ctx) { int64_t last_examined_page_pass1 = 0; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = parser->io; sas7bdat_ctx_t *ctx = calloc(1, sizeof(sas7bdat_ctx_t)); sas_header_info_t *hinfo = calloc(1, sizeof(sas_header_info_t)); ctx->handle = parser->handlers; ctx->input_encoding = parser->input_encoding; ctx->output_encoding = parser->output_encoding; ctx->user_ctx = user_ctx; ctx->io = parser->io; ctx->row_limit = parser->row_limit; if (parser->row_offset > 0) ctx->row_offset = parser->row_offset; if (io->open(path, io->io_ctx) == -1) { retval = READSTAT_ERROR_OPEN; goto cleanup; } if ((ctx->file_size = io->seek(0, READSTAT_SEEK_END, io->io_ctx)) == -1) { retval = READSTAT_ERROR_SEEK; if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Failed to seek to end of file"); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } if (io->seek(0, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Failed to seek to beginning of file"); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } if ((retval = sas_read_header(io, hinfo, ctx->handle.error, user_ctx)) != READSTAT_OK) { goto cleanup; } ctx->u64 = hinfo->u64; ctx->little_endian = hinfo->little_endian; ctx->vendor = hinfo->vendor; ctx->bswap = machine_is_little_endian() ^ hinfo->little_endian; ctx->header_size = hinfo->header_size; ctx->page_count = hinfo->page_count; ctx->page_size = hinfo->page_size; ctx->page_header_size = hinfo->page_header_size; ctx->subheader_pointer_size = hinfo->subheader_pointer_size; ctx->subheader_signature_size = ctx->u64 ? 8 : 4; ctx->ctime = hinfo->creation_time; ctx->mtime = hinfo->modification_time; ctx->version = hinfo->major_version; if (ctx->input_encoding == NULL) { ctx->input_encoding = hinfo->encoding; } if ((ctx->page = readstat_malloc(ctx->page_size)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (ctx->input_encoding && ctx->output_encoding && strcmp(ctx->input_encoding, ctx->output_encoding) != 0) { iconv_t converter = iconv_open(ctx->output_encoding, ctx->input_encoding); if (converter == (iconv_t)-1) { retval = READSTAT_ERROR_UNSUPPORTED_CHARSET; goto cleanup; } ctx->converter = converter; } if ((retval = readstat_convert(ctx->table_name, sizeof(ctx->table_name), hinfo->table_name, sizeof(hinfo->table_name), ctx->converter)) != READSTAT_OK) { goto cleanup; } if ((retval = sas7bdat_parse_meta_pages_pass1(ctx, &last_examined_page_pass1)) != READSTAT_OK) { goto cleanup; } if ((retval = sas7bdat_parse_amd_pages_pass1(last_examined_page_pass1, ctx)) != READSTAT_OK) { goto cleanup; } if (io->seek(ctx->header_size, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Failed to seek to position %" PRId64, ctx->header_size); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } if ((retval = sas7bdat_parse_all_pages_pass2(ctx)) != READSTAT_OK) { goto cleanup; } if ((retval = sas7bdat_submit_columns_if_needed(ctx, 0)) != READSTAT_OK) { goto cleanup; } if (ctx->handle.value && ctx->parsed_row_count != ctx->row_limit) { retval = READSTAT_ERROR_ROW_COUNT_MISMATCH; if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: Expected %d rows in file, found %d", ctx->row_limit, ctx->parsed_row_count); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } goto cleanup; } if ((retval = sas7bdat_update_progress(ctx)) != READSTAT_OK) { goto cleanup; } cleanup: io->close(io->io_ctx); if (retval == READSTAT_ERROR_OPEN || retval == READSTAT_ERROR_READ || retval == READSTAT_ERROR_SEEK) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "ReadStat: %s (retval = %d): %s (errno = %d)", readstat_error_message(retval), retval, strerror(errno), errno); ctx->handle.error(ctx->error_buf, user_ctx); } } if (ctx) sas7bdat_ctx_free(ctx); if (hinfo) free(hinfo); return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_sas7bdat_write.c0000644023477200000240000007475614574360757022202 0ustar00fajardoostaffs #include #include #include #include #include "../readstat.h" #include "../readstat_writer.h" #include "readstat_sas.h" #include "readstat_sas_rle.h" typedef struct sas7bdat_subheader_s { uint32_t signature; char *data; size_t len; int is_row_data; int is_row_data_compressed; } sas7bdat_subheader_t; typedef struct sas7bdat_subheader_array_s { int64_t count; int64_t capacity; sas7bdat_subheader_t **subheaders; } sas7bdat_subheader_array_t; typedef struct sas7bdat_column_text_s { char *data; size_t capacity; size_t used; int64_t index; } sas7bdat_column_text_t; typedef struct sas7bdat_column_text_array_s { int64_t count; sas7bdat_column_text_t **column_texts; } sas7bdat_column_text_array_t; typedef struct sas7bdat_write_ctx_s { sas_header_info_t *hinfo; sas7bdat_subheader_array_t *sarray; } sas7bdat_write_ctx_t; static size_t sas7bdat_variable_width(readstat_type_t type, size_t user_width); static int32_t sas7bdat_count_meta_pages(readstat_writer_t *writer) { sas7bdat_write_ctx_t *ctx = (sas7bdat_write_ctx_t *)writer->module_ctx; sas_header_info_t *hinfo = ctx->hinfo; sas7bdat_subheader_array_t *sarray = ctx->sarray; int i; int pages = 1; size_t bytes_left = hinfo->page_size - hinfo->page_header_size; size_t shp_ptr_size = hinfo->subheader_pointer_size; for (i=sarray->count-1; i>=0; i--) { sas7bdat_subheader_t *subheader = sarray->subheaders[i]; if (subheader->len + shp_ptr_size > bytes_left) { bytes_left = hinfo->page_size - hinfo->page_header_size; pages++; } bytes_left -= (subheader->len + shp_ptr_size); } return pages; } static size_t sas7bdat_row_length(readstat_writer_t *writer) { int i; size_t len = 0; for (i=0; ivariables_count; i++) { readstat_variable_t *variable = readstat_get_variable(writer, i); len += sas7bdat_variable_width(readstat_variable_get_type(variable), readstat_variable_get_storage_width(variable)); } return len; } static int32_t sas7bdat_rows_per_page(readstat_writer_t *writer, sas_header_info_t *hinfo) { size_t row_length = sas7bdat_row_length(writer); return (hinfo->page_size - hinfo->page_header_size) / row_length; } static int32_t sas7bdat_count_data_pages(readstat_writer_t *writer, sas_header_info_t *hinfo) { if (writer->compression == READSTAT_COMPRESS_ROWS) return 0; int32_t rows_per_page = sas7bdat_rows_per_page(writer, hinfo); return (writer->row_count + (rows_per_page - 1)) / rows_per_page; } static sas7bdat_column_text_t *sas7bdat_column_text_init(int64_t index, size_t len) { sas7bdat_column_text_t *column_text = calloc(1, sizeof(sas7bdat_column_text_t)); column_text->data = malloc(len); column_text->capacity = len; column_text->index = index; return column_text; } static void sas7bdat_column_text_free(sas7bdat_column_text_t *column_text) { free(column_text->data); free(column_text); } static void sas7bdat_column_text_array_free(sas7bdat_column_text_array_t *column_text_array) { int i; for (i=0; icount; i++) { sas7bdat_column_text_free(column_text_array->column_texts[i]); } free(column_text_array->column_texts); free(column_text_array); } static sas_text_ref_t sas7bdat_make_text_ref(sas7bdat_column_text_array_t *column_text_array, const char *string) { size_t len = strlen(string); size_t padded_len = (len + 3) / 4 * 4; sas7bdat_column_text_t *column_text = column_text_array->column_texts[ column_text_array->count-1]; if (column_text->used + padded_len > column_text->capacity) { column_text_array->count++; column_text_array->column_texts = realloc(column_text_array->column_texts, sizeof(sas7bdat_column_text_t *) * column_text_array->count); column_text = sas7bdat_column_text_init(column_text_array->count-1, column_text->capacity); column_text_array->column_texts[column_text_array->count-1] = column_text; } sas_text_ref_t text_ref = { .index = column_text->index, .offset = column_text->used + 28, .length = len }; strncpy(&column_text->data[column_text->used], string, padded_len); column_text->used += padded_len; return text_ref; } static readstat_error_t sas7bdat_emit_header(readstat_writer_t *writer, sas_header_info_t *hinfo) { sas_header_start_t header_start = { .a2 = hinfo->u64 ? SAS_ALIGNMENT_OFFSET_4 : SAS_ALIGNMENT_OFFSET_0, .a1 = SAS_ALIGNMENT_OFFSET_0, .endian = machine_is_little_endian() ? SAS_ENDIAN_LITTLE : SAS_ENDIAN_BIG, .file_format = SAS_FILE_FORMAT_UNIX, .encoding = 20, /* UTF-8 */ .file_type = "SAS FILE", .file_info = "DATA " }; memcpy(&header_start.magic, sas7bdat_magic_number, sizeof(header_start.magic)); return sas_write_header(writer, hinfo, header_start); } static sas7bdat_subheader_t *sas7bdat_subheader_init(uint32_t signature, size_t len) { sas7bdat_subheader_t *subheader = calloc(1, sizeof(sas7bdat_subheader_t)); subheader->signature = signature; subheader->len = len; subheader->data = calloc(1, len); return subheader; } static sas7bdat_subheader_t *sas7bdat_row_size_subheader_init(readstat_writer_t *writer, sas_header_info_t *hinfo, sas7bdat_column_text_array_t *column_text_array) { sas7bdat_subheader_t *subheader = sas7bdat_subheader_init( SAS_SUBHEADER_SIGNATURE_ROW_SIZE, hinfo->u64 ? 808 : 480); if (hinfo->u64) { int64_t row_length = sas7bdat_row_length(writer); int64_t row_count = writer->row_count; int64_t ncfl1 = writer->variables_count; int64_t page_size = hinfo->page_size; memcpy(&subheader->data[40], &row_length, sizeof(int64_t)); memcpy(&subheader->data[48], &row_count, sizeof(int64_t)); memcpy(&subheader->data[72], &ncfl1, sizeof(int64_t)); memcpy(&subheader->data[104], &page_size, sizeof(int64_t)); memset(&subheader->data[128], 0xFF, 16); } else { int32_t row_length = sas7bdat_row_length(writer); int32_t row_count = writer->row_count; int32_t ncfl1 = writer->variables_count; int32_t page_size = hinfo->page_size; memcpy(&subheader->data[20], &row_length, sizeof(int32_t)); memcpy(&subheader->data[24], &row_count, sizeof(int32_t)); memcpy(&subheader->data[36], &ncfl1, sizeof(int32_t)); memcpy(&subheader->data[52], &page_size, sizeof(int32_t)); memset(&subheader->data[64], 0xFF, 8); } sas_text_ref_t text_ref = { 0 }; if (writer->file_label[0]) { text_ref = sas7bdat_make_text_ref(column_text_array, writer->file_label); memcpy(&subheader->data[subheader->len-130], &text_ref, sizeof(sas_text_ref_t)); } if (writer->compression == READSTAT_COMPRESS_ROWS) { text_ref = sas7bdat_make_text_ref(column_text_array, SAS_COMPRESSION_SIGNATURE_RLE); memcpy(&subheader->data[subheader->len-118], &text_ref, sizeof(sas_text_ref_t)); } return subheader; } static sas7bdat_subheader_t *sas7bdat_col_size_subheader_init(readstat_writer_t *writer, sas_header_info_t *hinfo) { sas7bdat_subheader_t *subheader = sas7bdat_subheader_init( SAS_SUBHEADER_SIGNATURE_COLUMN_SIZE, hinfo->u64 ? 24 : 12); if (hinfo->u64) { int64_t col_count = writer->variables_count; memcpy(&subheader->data[8], &col_count, sizeof(int64_t)); } else { int32_t col_count = writer->variables_count; memcpy(&subheader->data[4], &col_count, sizeof(int32_t)); } return subheader; } static size_t sas7bdat_col_name_subheader_length(readstat_writer_t *writer, sas_header_info_t *hinfo) { return (hinfo->u64 ? 28+8*writer->variables_count : 20+8*writer->variables_count); } static sas7bdat_subheader_t *sas7bdat_col_name_subheader_init(readstat_writer_t *writer, sas_header_info_t *hinfo, sas7bdat_column_text_array_t *column_text_array) { size_t len = sas7bdat_col_name_subheader_length(writer, hinfo); size_t signature_len = hinfo->u64 ? 8 : 4; uint16_t remainder = sas_subheader_remainder(len, signature_len); sas7bdat_subheader_t *subheader = sas7bdat_subheader_init( SAS_SUBHEADER_SIGNATURE_COLUMN_NAME, len); memcpy(&subheader->data[signature_len], &remainder, sizeof(uint16_t)); int i; char *ptrs = &subheader->data[signature_len+8]; for (i=0; ivariables_count; i++) { readstat_variable_t *variable = readstat_get_variable(writer, i); const char *name = readstat_variable_get_name(variable); sas_text_ref_t text_ref = sas7bdat_make_text_ref(column_text_array, name); memcpy(ptrs, &text_ref, sizeof(sas_text_ref_t)); ptrs += 8; } return subheader; } static size_t sas7bdat_col_attrs_subheader_length(readstat_writer_t *writer, sas_header_info_t *hinfo) { return (hinfo->u64 ? 28+16*writer->variables_count : 20+12*writer->variables_count); } static sas7bdat_subheader_t *sas7bdat_col_attrs_subheader_init(readstat_writer_t *writer, sas_header_info_t *hinfo) { size_t len = sas7bdat_col_attrs_subheader_length(writer, hinfo); size_t signature_len = hinfo->u64 ? 8 : 4; uint16_t remainder = sas_subheader_remainder(len, signature_len); sas7bdat_subheader_t *subheader = sas7bdat_subheader_init( SAS_SUBHEADER_SIGNATURE_COLUMN_ATTRS, len); memcpy(&subheader->data[signature_len], &remainder, sizeof(uint16_t)); char *ptrs = &subheader->data[signature_len+8]; uint64_t offset = 0; int i; for (i=0; ivariables_count; i++) { readstat_variable_t *variable = readstat_get_variable(writer, i); const char *name = readstat_variable_get_name(variable); readstat_type_t type = readstat_variable_get_type(variable); uint16_t name_length_flag = strlen(name) <= 8 ? 4 : 2048; uint32_t width = 0; if (hinfo->u64) { memcpy(&ptrs[0], &offset, sizeof(uint64_t)); ptrs += sizeof(uint64_t); } else { uint32_t offset32 = offset; memcpy(&ptrs[0], &offset32, sizeof(uint32_t)); ptrs += sizeof(uint32_t); } if (type == READSTAT_TYPE_STRING) { ptrs[6] = SAS_COLUMN_TYPE_CHR; width = readstat_variable_get_storage_width(variable); } else { ptrs[6] = SAS_COLUMN_TYPE_NUM; width = 8; } memcpy(&ptrs[0], &width, sizeof(uint32_t)); memcpy(&ptrs[4], &name_length_flag, sizeof(uint16_t)); offset += width; ptrs += 8; } return subheader; } static sas7bdat_subheader_t *sas7bdat_col_format_subheader_init(readstat_variable_t *variable, sas_header_info_t *hinfo, sas7bdat_column_text_array_t *column_text_array) { sas7bdat_subheader_t *subheader = sas7bdat_subheader_init( SAS_SUBHEADER_SIGNATURE_COLUMN_FORMAT, hinfo->u64 ? 64 : 52); const char *format = readstat_variable_get_format(variable); const char *label = readstat_variable_get_label(variable); off_t format_offset = hinfo->u64 ? 46 : 34; off_t label_offset = hinfo->u64 ? 52 : 40; if (format) { sas_text_ref_t text_ref = sas7bdat_make_text_ref(column_text_array, format); memcpy(&subheader->data[format_offset+0], &text_ref.index, sizeof(uint16_t)); memcpy(&subheader->data[format_offset+2], &text_ref.offset, sizeof(uint16_t)); memcpy(&subheader->data[format_offset+4], &text_ref.length, sizeof(uint16_t)); } if (label) { sas_text_ref_t text_ref = sas7bdat_make_text_ref(column_text_array, label); memcpy(&subheader->data[label_offset+0], &text_ref.index, sizeof(uint16_t)); memcpy(&subheader->data[label_offset+2], &text_ref.offset, sizeof(uint16_t)); memcpy(&subheader->data[label_offset+4], &text_ref.length, sizeof(uint16_t)); } return subheader; } static size_t sas7bdat_col_text_subheader_length(sas_header_info_t *hinfo, sas7bdat_column_text_t *column_text) { size_t signature_len = hinfo->u64 ? 8 : 4; size_t text_len = column_text ? column_text->used : 0; return signature_len + 28 + text_len; } static sas7bdat_subheader_t *sas7bdat_col_text_subheader_init(readstat_writer_t *writer, sas_header_info_t *hinfo, sas7bdat_column_text_t *column_text) { size_t signature_len = hinfo->u64 ? 8 : 4; size_t len = sas7bdat_col_text_subheader_length(hinfo, column_text); sas7bdat_subheader_t *subheader = sas7bdat_subheader_init( SAS_SUBHEADER_SIGNATURE_COLUMN_TEXT, len); uint16_t used = sas_subheader_remainder(len, signature_len); memcpy(&subheader->data[signature_len], &used, sizeof(uint16_t)); memset(&subheader->data[signature_len+12], ' ', 8); memcpy(&subheader->data[signature_len+28], column_text->data, column_text->used); return subheader; } static sas7bdat_subheader_array_t *sas7bdat_subheader_array_init(readstat_writer_t *writer, sas_header_info_t *hinfo) { sas7bdat_column_text_array_t *column_text_array = calloc(1, sizeof(sas7bdat_column_text_array_t)); column_text_array->count = 1; column_text_array->column_texts = malloc(sizeof(sas7bdat_column_text_t *)); column_text_array->column_texts[0] = sas7bdat_column_text_init(0, hinfo->page_size - hinfo->page_header_size - hinfo->subheader_pointer_size - sas7bdat_col_text_subheader_length(hinfo, NULL)); sas7bdat_subheader_array_t *sarray = calloc(1, sizeof(sas7bdat_subheader_array_t)); sarray->count = 4+writer->variables_count; sarray->subheaders = calloc(sarray->count, sizeof(sas7bdat_subheader_t *)); long idx = 0; int i; sas7bdat_subheader_t *col_name_subheader = NULL; sas7bdat_subheader_t *col_attrs_subheader = NULL; sas7bdat_subheader_t **col_format_subheaders = NULL; col_name_subheader = sas7bdat_col_name_subheader_init(writer, hinfo, column_text_array); col_attrs_subheader = sas7bdat_col_attrs_subheader_init(writer, hinfo); sarray->subheaders[idx++] = sas7bdat_row_size_subheader_init(writer, hinfo, column_text_array); sarray->subheaders[idx++] = sas7bdat_col_size_subheader_init(writer, hinfo); col_format_subheaders = calloc(writer->variables_count, sizeof(sas7bdat_subheader_t *)); for (i=0; ivariables_count; i++) { readstat_variable_t *variable = readstat_get_variable(writer, i); col_format_subheaders[i] = sas7bdat_col_format_subheader_init(variable, hinfo, column_text_array); } sarray->count += column_text_array->count; sarray->subheaders = realloc(sarray->subheaders, sarray->count * sizeof(sas7bdat_subheader_t *)); for (i=0; icount; i++) { sarray->subheaders[idx++] = sas7bdat_col_text_subheader_init(writer, hinfo, column_text_array->column_texts[i]); } sas7bdat_column_text_array_free(column_text_array); sarray->subheaders[idx++] = col_name_subheader; sarray->subheaders[idx++] = col_attrs_subheader; for (i=0; ivariables_count; i++) { sarray->subheaders[idx++] = col_format_subheaders[i]; } free(col_format_subheaders); sarray->capacity = sarray->count; if (writer->compression == READSTAT_COMPRESS_ROWS) { sarray->capacity = (sarray->count + writer->row_count); sarray->subheaders = realloc(sarray->subheaders, sarray->capacity * sizeof(sas7bdat_subheader_t *)); } return sarray; } static void sas7bdat_subheader_free(sas7bdat_subheader_t *subheader) { if (!subheader) return; if (subheader->data) free(subheader->data); free(subheader); } static void sas7bdat_subheader_array_free(sas7bdat_subheader_array_t *sarray) { int i; for (i=0; icount; i++) { sas7bdat_subheader_free(sarray->subheaders[i]); } free(sarray->subheaders); free(sarray); } static int sas7bdat_subheader_type(uint32_t signature) { return (signature == SAS_SUBHEADER_SIGNATURE_COLUMN_TEXT || signature == SAS_SUBHEADER_SIGNATURE_COLUMN_NAME || signature == SAS_SUBHEADER_SIGNATURE_COLUMN_ATTRS || signature == SAS_SUBHEADER_SIGNATURE_COLUMN_LIST); } static readstat_error_t sas7bdat_emit_meta_pages(readstat_writer_t *writer) { sas7bdat_write_ctx_t *ctx = (sas7bdat_write_ctx_t *)writer->module_ctx; sas_header_info_t *hinfo = ctx->hinfo; sas7bdat_subheader_array_t *sarray = ctx->sarray; readstat_error_t retval = READSTAT_OK; int16_t page_type = SAS_PAGE_TYPE_META; char *page = malloc(hinfo->page_size); int64_t shp_written = 0; while (sarray->count > shp_written) { memset(page, 0, hinfo->page_size); int16_t shp_count = 0; size_t shp_data_offset = hinfo->page_size; size_t shp_ptr_offset = hinfo->page_header_size; size_t shp_ptr_size = hinfo->subheader_pointer_size; memcpy(&page[hinfo->page_header_size-8], &page_type, sizeof(int16_t)); if (sarray->subheaders[shp_written]->len + shp_ptr_size > shp_data_offset - shp_ptr_offset) { retval = READSTAT_ERROR_ROW_IS_TOO_WIDE_FOR_PAGE; goto cleanup; } while (sarray->count > shp_written && sarray->subheaders[shp_written]->len + shp_ptr_size <= shp_data_offset - shp_ptr_offset) { sas7bdat_subheader_t *subheader = sarray->subheaders[shp_written]; uint32_t signature32 = subheader->signature; /* copy ptr */ if (hinfo->u64) { uint64_t offset = shp_data_offset - subheader->len; uint64_t len = subheader->len; memcpy(&page[shp_ptr_offset], &offset, sizeof(uint64_t)); memcpy(&page[shp_ptr_offset+8], &len, sizeof(uint64_t)); if (subheader->is_row_data) { if (subheader->is_row_data_compressed) { page[shp_ptr_offset+16] = SAS_COMPRESSION_ROW; } else { page[shp_ptr_offset+16] = SAS_COMPRESSION_NONE; } page[shp_ptr_offset+17] = 1; } else { page[shp_ptr_offset+17] = sas7bdat_subheader_type(subheader->signature); if (signature32 >= 0xFF000000) { int64_t signature64 = (int32_t)signature32; memcpy(&subheader->data[0], &signature64, sizeof(int64_t)); } else { memcpy(&subheader->data[0], &signature32, sizeof(int32_t)); } } } else { uint32_t offset = shp_data_offset - subheader->len; uint32_t len = subheader->len; memcpy(&page[shp_ptr_offset], &offset, sizeof(uint32_t)); memcpy(&page[shp_ptr_offset+4], &len, sizeof(uint32_t)); if (subheader->is_row_data) { if (subheader->is_row_data_compressed) { page[shp_ptr_offset+8] = SAS_COMPRESSION_ROW; } else { page[shp_ptr_offset+8] = SAS_COMPRESSION_NONE; } page[shp_ptr_offset+9] = 1; } else { page[shp_ptr_offset+9] = sas7bdat_subheader_type(subheader->signature); memcpy(&subheader->data[0], &signature32, sizeof(int32_t)); } } shp_ptr_offset += shp_ptr_size; /* copy data */ shp_data_offset -= subheader->len; memcpy(&page[shp_data_offset], subheader->data, subheader->len); shp_written++; shp_count++; } if (hinfo->u64) { memcpy(&page[34], &shp_count, sizeof(int16_t)); memcpy(&page[36], &shp_count, sizeof(int16_t)); } else { memcpy(&page[18], &shp_count, sizeof(int16_t)); memcpy(&page[20], &shp_count, sizeof(int16_t)); } retval = readstat_write_bytes(writer, page, hinfo->page_size); if (retval != READSTAT_OK) goto cleanup; } cleanup: free(page); return retval; } static int sas7bdat_page_is_too_small(readstat_writer_t *writer, sas_header_info_t *hinfo, size_t row_length) { size_t page_length = hinfo->page_size - hinfo->page_header_size; if (writer->compression == READSTAT_COMPRESS_NONE && page_length < row_length) return 1; if (writer->compression == READSTAT_COMPRESS_ROWS && page_length < row_length + hinfo->subheader_pointer_size) return 1; if (page_length < sas7bdat_col_name_subheader_length(writer, hinfo) + hinfo->subheader_pointer_size) return 1; if (page_length < sas7bdat_col_attrs_subheader_length(writer, hinfo) + hinfo->subheader_pointer_size) return 1; return 0; } static sas7bdat_write_ctx_t *sas7bdat_write_ctx_init(readstat_writer_t *writer) { sas7bdat_write_ctx_t *ctx = calloc(1, sizeof(sas7bdat_write_ctx_t)); sas_header_info_t *hinfo = sas_header_info_init(writer, writer->is_64bit); size_t row_length = sas7bdat_row_length(writer); while (sas7bdat_page_is_too_small(writer, hinfo, row_length)) { hinfo->page_size <<= 1; } ctx->hinfo = hinfo; ctx->sarray = sas7bdat_subheader_array_init(writer, hinfo); return ctx; } static void sas7bdat_write_ctx_free(sas7bdat_write_ctx_t *ctx) { free(ctx->hinfo); sas7bdat_subheader_array_free(ctx->sarray); free(ctx); } static readstat_error_t sas7bdat_emit_header_and_meta_pages(readstat_writer_t *writer) { sas7bdat_write_ctx_t *ctx = (sas7bdat_write_ctx_t *)writer->module_ctx; readstat_error_t retval = READSTAT_OK; if (sas7bdat_row_length(writer) == 0) { retval = READSTAT_ERROR_TOO_FEW_COLUMNS; goto cleanup; } if (writer->compression == READSTAT_COMPRESS_NONE && sas7bdat_rows_per_page(writer, ctx->hinfo) == 0) { retval = READSTAT_ERROR_ROW_IS_TOO_WIDE_FOR_PAGE; goto cleanup; } ctx->hinfo->page_count = sas7bdat_count_meta_pages(writer) + sas7bdat_count_data_pages(writer, ctx->hinfo); retval = sas7bdat_emit_header(writer, ctx->hinfo); if (retval != READSTAT_OK) goto cleanup; retval = sas7bdat_emit_meta_pages(writer); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t sas7bdat_begin_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; readstat_error_t retval = READSTAT_OK; writer->module_ctx = sas7bdat_write_ctx_init(writer); if (writer->compression == READSTAT_COMPRESS_NONE) { retval = sas7bdat_emit_header_and_meta_pages(writer); if (retval != READSTAT_OK) goto cleanup; } cleanup: if (retval != READSTAT_OK) { if (writer->module_ctx) { sas7bdat_write_ctx_free(writer->module_ctx); writer->module_ctx = NULL; } } return retval; } static readstat_error_t sas7bdat_end_data(void *writer_ctx) { readstat_error_t retval = READSTAT_OK; readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; sas7bdat_write_ctx_t *ctx = (sas7bdat_write_ctx_t *)writer->module_ctx; if (writer->compression == READSTAT_COMPRESS_ROWS) { retval = sas7bdat_emit_header_and_meta_pages(writer); } else { retval = sas_fill_page(writer, ctx->hinfo); } return retval; } static void sas7bdat_module_ctx_free(void *module_ctx) { sas7bdat_write_ctx_free(module_ctx); } static readstat_error_t sas7bdat_write_double(void *row, const readstat_variable_t *var, double value) { memcpy(row, &value, sizeof(double)); return READSTAT_OK; } static readstat_error_t sas7bdat_write_float(void *row, const readstat_variable_t *var, float value) { return sas7bdat_write_double(row, var, value); } static readstat_error_t sas7bdat_write_int32(void *row, const readstat_variable_t *var, int32_t value) { return sas7bdat_write_double(row, var, value); } static readstat_error_t sas7bdat_write_int16(void *row, const readstat_variable_t *var, int16_t value) { return sas7bdat_write_double(row, var, value); } static readstat_error_t sas7bdat_write_int8(void *row, const readstat_variable_t *var, int8_t value) { return sas7bdat_write_double(row, var, value); } static readstat_error_t sas7bdat_write_missing_tagged_raw(void *row, const readstat_variable_t *var, char tag) { union { double dval; char chars[8]; } nan_value; nan_value.dval = NAN; nan_value.chars[machine_is_little_endian() ? 5 : 2] = ~tag; return sas7bdat_write_double(row, var, nan_value.dval); } static readstat_error_t sas7bdat_write_missing_tagged(void *row, const readstat_variable_t *var, char tag) { readstat_error_t error = sas_validate_tag(tag); if (error == READSTAT_OK) return sas7bdat_write_missing_tagged_raw(row, var, tag); return error; } static readstat_error_t sas7bdat_write_missing_numeric(void *row, const readstat_variable_t *var) { return sas7bdat_write_missing_tagged_raw(row, var, '.'); } static readstat_error_t sas7bdat_write_string(void *row, const readstat_variable_t *var, const char *value) { size_t max_len = readstat_variable_get_storage_width(var); if (value == NULL || value[0] == '\0') { memset(row, '\0', max_len); } else { size_t value_len = strlen(value); if (value_len > max_len) return READSTAT_ERROR_STRING_VALUE_IS_TOO_LONG; strncpy((char *)row, value, max_len); } return READSTAT_OK; } static readstat_error_t sas7bdat_write_missing_string(void *row, const readstat_variable_t *var) { return sas7bdat_write_string(row, var, NULL); } static size_t sas7bdat_variable_width(readstat_type_t type, size_t user_width) { if (type == READSTAT_TYPE_STRING) { return user_width; } return 8; } static readstat_error_t sas7bdat_write_row_uncompressed(readstat_writer_t *writer, sas7bdat_write_ctx_t *ctx, void *bytes, size_t len) { readstat_error_t retval = READSTAT_OK; sas_header_info_t *hinfo = ctx->hinfo; int32_t rows_per_page = sas7bdat_rows_per_page(writer, hinfo); if (writer->current_row % rows_per_page == 0) { retval = sas_fill_page(writer, ctx->hinfo); if (retval != READSTAT_OK) goto cleanup; int16_t page_type = SAS_PAGE_TYPE_DATA; int16_t page_row_count = (writer->row_count - writer->current_row < rows_per_page ? writer->row_count - writer->current_row : rows_per_page); char *header = calloc(hinfo->page_header_size, 1); memcpy(&header[hinfo->page_header_size-6], &page_row_count, sizeof(int16_t)); memcpy(&header[hinfo->page_header_size-8], &page_type, sizeof(int16_t)); retval = readstat_write_bytes(writer, header, hinfo->page_header_size); free(header); if (retval != READSTAT_OK) goto cleanup; } retval = readstat_write_bytes(writer, bytes, len); cleanup: return retval; } /* We don't actually write compressed data out at this point; the file header * requires a page count, so instead we collect the compressed subheaders in * memory and write the entire file at the end, once the page count can be * determined. */ static readstat_error_t sas7bdat_write_row_compressed(readstat_writer_t *writer, sas7bdat_write_ctx_t *ctx, void *bytes, size_t len) { readstat_error_t retval = READSTAT_OK; size_t compressed_len = sas_rle_compressed_len(bytes, len); sas7bdat_subheader_t *subheader = NULL; if (compressed_len < len) { subheader = sas7bdat_subheader_init(0, compressed_len); subheader->is_row_data = 1; subheader->is_row_data_compressed = 1; size_t actual_len = sas_rle_compress(subheader->data, subheader->len, bytes, len); if (actual_len != compressed_len) { retval = READSTAT_ERROR_ROW_WIDTH_MISMATCH; goto cleanup; } } else { subheader = sas7bdat_subheader_init(0, len); subheader->is_row_data = 1; memcpy(subheader->data, bytes, len); } ctx->sarray->subheaders[ctx->sarray->count++] = subheader; cleanup: if (retval != READSTAT_OK) sas7bdat_subheader_free(subheader); return retval; } static readstat_error_t sas7bdat_write_row(void *writer_ctx, void *bytes, size_t len) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; sas7bdat_write_ctx_t *ctx = (sas7bdat_write_ctx_t *)writer->module_ctx; readstat_error_t retval = READSTAT_OK; if (writer->compression == READSTAT_COMPRESS_NONE) { retval = sas7bdat_write_row_uncompressed(writer, ctx, bytes, len); } else if (writer->compression == READSTAT_COMPRESS_ROWS) { retval = sas7bdat_write_row_compressed(writer, ctx, bytes, len); } return retval; } static readstat_error_t sas7bdat_metadata_ok(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; if (writer->compression != READSTAT_COMPRESS_NONE && writer->compression != READSTAT_COMPRESS_ROWS) return READSTAT_ERROR_UNSUPPORTED_COMPRESSION; return READSTAT_OK; } readstat_error_t readstat_begin_writing_sas7bdat(readstat_writer_t *writer, void *user_ctx, long row_count) { if (writer->version == 0) writer->version = SAS_DEFAULT_FILE_VERSION; writer->callbacks.metadata_ok = &sas7bdat_metadata_ok; writer->callbacks.write_int8 = &sas7bdat_write_int8; writer->callbacks.write_int16 = &sas7bdat_write_int16; writer->callbacks.write_int32 = &sas7bdat_write_int32; writer->callbacks.write_float = &sas7bdat_write_float; writer->callbacks.write_double = &sas7bdat_write_double; writer->callbacks.write_string = &sas7bdat_write_string; writer->callbacks.write_missing_string = &sas7bdat_write_missing_string; writer->callbacks.write_missing_number = &sas7bdat_write_missing_numeric; writer->callbacks.write_missing_tagged = &sas7bdat_write_missing_tagged; writer->callbacks.variable_width = &sas7bdat_variable_width; writer->callbacks.variable_ok = &sas_validate_variable; writer->callbacks.begin_data = &sas7bdat_begin_data; writer->callbacks.end_data = &sas7bdat_end_data; writer->callbacks.module_ctx_free = &sas7bdat_module_ctx_free; writer->callbacks.write_row = &sas7bdat_write_row; return readstat_begin_writing_file(writer, user_ctx, row_count); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_sas_rle.c0000644023477200000240000002370114574360757020670 0ustar00fajardoostaffs #include #include #include #if defined(_MSC_VER) #include typedef SSIZE_T ssize_t; #endif #include "readstat_sas_rle.h" #define SAS_RLE_COMMAND_COPY64 0 #define SAS_RLE_COMMAND_COPY64_PLUS_4096 1 #define SAS_RLE_COMMAND_COPY96 2 #define SAS_RLE_COMMAND_INSERT_BYTE18 4 #define SAS_RLE_COMMAND_INSERT_AT17 5 #define SAS_RLE_COMMAND_INSERT_BLANK17 6 #define SAS_RLE_COMMAND_INSERT_ZERO17 7 #define SAS_RLE_COMMAND_COPY1 8 #define SAS_RLE_COMMAND_COPY17 9 #define SAS_RLE_COMMAND_COPY33 10 #define SAS_RLE_COMMAND_COPY49 11 #define SAS_RLE_COMMAND_INSERT_BYTE3 12 #define SAS_RLE_COMMAND_INSERT_AT2 13 #define SAS_RLE_COMMAND_INSERT_BLANK2 14 #define SAS_RLE_COMMAND_INSERT_ZERO2 15 #define MAX_INSERT_RUN 4112 // 4095 + 17 #define MAX_COPY_RUN 4159 // 4095 + 64 static size_t command_lengths[16] = { [SAS_RLE_COMMAND_COPY64] = 1, [SAS_RLE_COMMAND_COPY64_PLUS_4096] = 1, [SAS_RLE_COMMAND_INSERT_BYTE18] = 2, [SAS_RLE_COMMAND_INSERT_AT17] = 1, [SAS_RLE_COMMAND_INSERT_BLANK17] = 1, [SAS_RLE_COMMAND_INSERT_ZERO17] = 1, [SAS_RLE_COMMAND_INSERT_BYTE3] = 1 }; ssize_t sas_rle_decompressed_len(const void *input_buf, size_t input_len) { return sas_rle_decompress(NULL, 0, input_buf, input_len); } ssize_t sas_rle_decompress(void *output_buf, size_t output_len, const void *input_buf, size_t input_len) { unsigned char *buffer = (unsigned char *)output_buf; unsigned char *output = buffer; size_t output_written = 0; const unsigned char *input = (const unsigned char *)input_buf; while (input < (const unsigned char *)input_buf + input_len) { unsigned char control = *input++; unsigned char command = (control & 0xF0) >> 4; unsigned char length = (control & 0x0F); int copy_len = 0; int insert_len = 0; unsigned char insert_byte = '\0'; if (input + command_lengths[command] > (const unsigned char *)input_buf + input_len) { return -1; } switch (command) { case SAS_RLE_COMMAND_COPY64: copy_len = (*input++) + 64 + length * 256; break; case SAS_RLE_COMMAND_COPY64_PLUS_4096: copy_len = (*input++) + 64 + length * 256 + 4096; break; case SAS_RLE_COMMAND_COPY96: copy_len = length + 96; break; case SAS_RLE_COMMAND_INSERT_BYTE18: insert_len = (*input++) + 18 + length * 256; insert_byte = *input++; break; case SAS_RLE_COMMAND_INSERT_AT17: insert_len = (*input++) + 17 + length * 256; insert_byte = '@'; break; case SAS_RLE_COMMAND_INSERT_BLANK17: insert_len = (*input++) + 17 + length * 256; insert_byte = ' '; break; case SAS_RLE_COMMAND_INSERT_ZERO17: insert_len = (*input++) + 17 + length * 256; insert_byte = '\0'; break; case SAS_RLE_COMMAND_COPY1: copy_len = length + 1; break; case SAS_RLE_COMMAND_COPY17: copy_len = length + 17; break; case SAS_RLE_COMMAND_COPY33: copy_len = length + 33; break; case SAS_RLE_COMMAND_COPY49: copy_len = length + 49; break; case SAS_RLE_COMMAND_INSERT_BYTE3: insert_byte = *input++; insert_len = length + 3; break; case SAS_RLE_COMMAND_INSERT_AT2: insert_byte = '@'; insert_len = length + 2; break; case SAS_RLE_COMMAND_INSERT_BLANK2: insert_byte = ' '; insert_len = length + 2; break; case SAS_RLE_COMMAND_INSERT_ZERO2: insert_byte = '\0'; insert_len = length + 2; break; default: /* error out here? */ break; } if (copy_len) { if (output_written + copy_len > output_len) { return -1; } if (input + copy_len > (const unsigned char *)input_buf + input_len) { return -1; } if (output) { memcpy(&output[output_written], input, copy_len); } input += copy_len; output_written += copy_len; } if (insert_len) { if (output_written + insert_len > output_len) { return -1; } if (output) { memset(&output[output_written], insert_byte, insert_len); } output_written += insert_len; } } return output_written; } static size_t sas_rle_measure_copy_run(size_t copy_run) { size_t len = 0; while (copy_run >= MAX_COPY_RUN) { len += 2 + MAX_COPY_RUN; copy_run -= MAX_COPY_RUN; } return len + (copy_run > 64) + (copy_run > 0) + copy_run; } static size_t sas_rle_copy_run(unsigned char *output_buf, size_t offset, const unsigned char *copy, size_t copy_run) { unsigned char *out = output_buf + offset; if (output_buf == NULL) return sas_rle_measure_copy_run(copy_run); while (copy_run >= MAX_COPY_RUN) { *out++ = (SAS_RLE_COMMAND_COPY64 << 4) + 0x0F; *out++ = 0xFF; memcpy(out, copy, MAX_COPY_RUN); out += MAX_COPY_RUN; copy += MAX_COPY_RUN; copy_run -= MAX_COPY_RUN; } if (copy_run > 64) { int length = (copy_run - 64) / 256; unsigned char rem = (copy_run - 64) % 256; *out++ = (SAS_RLE_COMMAND_COPY64 << 4) + (length & 0x0F); *out++ = rem; } else if (copy_run >= 49) { *out++ = (SAS_RLE_COMMAND_COPY49 << 4) + (copy_run - 49); } else if (copy_run >= 33) { *out++ = (SAS_RLE_COMMAND_COPY33 << 4) + (copy_run - 33); } else if (copy_run >= 17) { *out++ = (SAS_RLE_COMMAND_COPY17 << 4) + (copy_run - 17); } else if (copy_run >= 1) { *out++ = (SAS_RLE_COMMAND_COPY1 << 4) + (copy_run - 1); } memcpy(out, copy, copy_run); out += copy_run; return out - (output_buf + offset); } static int sas_rle_is_special_byte(unsigned char last_byte) { return (last_byte == '@' || last_byte == ' ' || last_byte == '\0'); } static size_t sas_rle_measure_insert_run(unsigned char last_byte, size_t insert_run) { if (sas_rle_is_special_byte(last_byte)) return insert_run > 17 ? 2 : 1; return insert_run > 18 ? 3 : 2; } static size_t sas_rle_insert_run(unsigned char *output_buf, size_t offset, unsigned char last_byte, size_t insert_run) { unsigned char *out = output_buf + offset; if (output_buf == NULL) return sas_rle_measure_insert_run(last_byte, insert_run); if (sas_rle_is_special_byte(last_byte)) { if (insert_run > 17) { int length = (insert_run - 17) / 256; unsigned char rem = (insert_run - 17) % 256; if (last_byte == '@') { *out++ = (SAS_RLE_COMMAND_INSERT_AT17 << 4) + (length & 0x0F); } else if (last_byte == ' ') { *out++ = (SAS_RLE_COMMAND_INSERT_BLANK17 << 4) + (length & 0x0F); } else if (last_byte == '\0') { *out++ = (SAS_RLE_COMMAND_INSERT_ZERO17 << 4) + (length & 0x0F); } *out++ = rem; } else if (insert_run >= 2) { if (last_byte == '@') { *out++ = (SAS_RLE_COMMAND_INSERT_AT2 << 4) + (insert_run - 2); } else if (last_byte == ' ') { *out++ = (SAS_RLE_COMMAND_INSERT_BLANK2 << 4) + (insert_run - 2); } else if (last_byte == '\0') { *out++ = (SAS_RLE_COMMAND_INSERT_ZERO2 << 4) + (insert_run - 2); } } } else if (insert_run > 18) { int length = (insert_run - 18) / 256; unsigned char rem = (insert_run - 18) % 256; *out++ = (SAS_RLE_COMMAND_INSERT_BYTE18 << 4) + (length & 0x0F); *out++ = rem; *out++ = last_byte; } else if (insert_run >= 3) { *out++ = (SAS_RLE_COMMAND_INSERT_BYTE3 << 4) + (insert_run - 3); *out++ = last_byte; } return out - (output_buf + offset); } static int sas_rle_is_insert_run(unsigned char last_byte, size_t insert_run) { if (sas_rle_is_special_byte(last_byte)) return (insert_run > 1); return (insert_run > 2); } ssize_t sas_rle_compressed_len(const void *bytes, size_t len) { return sas_rle_compress(NULL, 0, bytes, len); } ssize_t sas_rle_compress(void *output_buf, size_t output_len, const void *input_buf, size_t input_len) { /* TODO bounds check */ const unsigned char *p = (const unsigned char *)input_buf; const unsigned char *pe = p + input_len; const unsigned char *copy = p; unsigned char *out = (unsigned char *)output_buf; size_t insert_run = 0; size_t copy_run = 0; size_t out_written = 0; unsigned char last_byte = 0; while (p < pe) { unsigned char c = *p; if (insert_run == 0) { insert_run = 1; } else if (c == last_byte && insert_run < MAX_INSERT_RUN) { insert_run++; } else { if (sas_rle_is_insert_run(last_byte, insert_run)) { out_written += sas_rle_copy_run(out, out_written, copy, copy_run); out_written += sas_rle_insert_run(out, out_written, last_byte, insert_run); copy_run = 0; copy = p; } else { copy_run += insert_run; } insert_run = 1; } last_byte = c; p++; } if (sas_rle_is_insert_run(last_byte, insert_run)) { out_written += sas_rle_copy_run(out, out_written, copy, copy_run); out_written += sas_rle_insert_run(out, out_written, last_byte, insert_run); } else { out_written += sas_rle_copy_run(out, out_written, copy, copy_run + insert_run); } return out_written; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_sas_rle.h0000644023477200000240000000055614574360757020700 0ustar00fajardoostaffs ssize_t sas_rle_decompress(void *output_buf, size_t output_len, const void *input_buf, size_t input_len); ssize_t sas_rle_compress(void *output_buf, size_t output_len, const void *input_buf, size_t input_len); ssize_t sas_rle_decompressed_len(const void *input_buf, size_t input_len); ssize_t sas_rle_compressed_len(const void *bytes, size_t len); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_xport.c0000644023477200000240000000147414574360757020417 0ustar00fajardoostaffs#include #include "readstat_xport.h" #include "../readstat_bits.h" char _xport_months[12][4] = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; void xport_namestr_bswap(xport_namestr_t *namestr) { if (!machine_is_little_endian()) return; namestr->ntype = byteswap2(namestr->ntype); namestr->nhfun = byteswap2(namestr->nhfun); namestr->nlng = byteswap2(namestr->nlng); namestr->nvar0 = byteswap2(namestr->nvar0); namestr->nfl = byteswap2(namestr->nfl); namestr->nfd = byteswap2(namestr->nfd); namestr->nfj = byteswap2(namestr->nfj); namestr->nifl = byteswap2(namestr->nifl); namestr->nifd = byteswap2(namestr->nifd); namestr->npos = byteswap4(namestr->npos); namestr->labeln = byteswap2(namestr->labeln); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_xport.h0000644023477200000240000000175714574360757020430 0ustar00fajardoostaffs typedef struct xport_header_record_s { char name[9]; int num1; int num2; int num3; int num4; int num5; int num6; } xport_header_record_t; extern char _xport_months[12][4]; #pragma pack(push, 1) typedef struct xport_namestr_s { uint16_t ntype; uint16_t nhfun; uint16_t nlng; uint16_t nvar0; char nname[8]; char nlabel[40]; char nform[8]; uint16_t nfl; uint16_t nfd; uint16_t nfj; char nfill[2]; char niform[8]; uint16_t nifl; uint16_t nifd; uint32_t npos; char longname[32]; uint16_t labeln; char rest[18]; } xport_namestr_t; #pragma pack(pop) typedef struct xport_format_s { char name[32]; int width; int decimals; } xport_format_t; #define XPORT_MIN_DOUBLE_SIZE 3 #define XPORT_MAX_DOUBLE_SIZE 8 void xport_namestr_bswap(xport_namestr_t *namestr); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_xport_parse_format.c0000644023477200000240000001406014574360757023154 0ustar00fajardoostaffs #line 1 "src/sas/readstat_xport_parse_format.rl" #include "../readstat.h" #include "readstat_xport.h" #include "readstat_xport_parse_format.h" #line 10 "src/sas/readstat_xport_parse_format.c" static const char _xport_format_parse_actions[] = { 0, 1, 0, 1, 1, 1, 3, 1, 4, 2, 2, 0, 3, 1, 2, 0 }; static const char _xport_format_parse_key_offsets[] = { 0, 0, 7, 14, 23, 31, 31, 34, 42, 50, 58, 60, 62, 65, 73, 81 }; static const char _xport_format_parse_trans_keys[] = { 95, 48, 57, 65, 90, 97, 122, 95, 48, 57, 65, 90, 97, 122, 36, 46, 95, 48, 57, 65, 90, 97, 122, 46, 95, 48, 57, 65, 90, 97, 122, 46, 48, 57, 46, 95, 48, 57, 65, 90, 97, 122, 46, 95, 48, 57, 65, 90, 97, 122, 46, 95, 48, 57, 65, 90, 97, 122, 48, 57, 48, 57, 46, 48, 57, 46, 95, 48, 57, 65, 90, 97, 122, 46, 95, 48, 57, 65, 90, 97, 122, 46, 95, 48, 57, 65, 90, 97, 122, 0 }; static const char _xport_format_parse_single_lengths[] = { 0, 1, 1, 3, 2, 0, 1, 2, 2, 2, 0, 0, 1, 2, 2, 2 }; static const char _xport_format_parse_range_lengths[] = { 0, 3, 3, 3, 3, 0, 1, 3, 3, 3, 1, 1, 1, 3, 3, 3 }; static const char _xport_format_parse_index_offsets[] = { 0, 0, 5, 10, 17, 23, 24, 27, 33, 39, 45, 47, 49, 52, 58, 64 }; static const char _xport_format_parse_indicies[] = { 2, 0, 2, 2, 1, 4, 3, 4, 4, 1, 5, 6, 8, 7, 8, 8, 1, 9, 11, 10, 11, 11, 1, 1, 12, 13, 1, 9, 0, 14, 0, 0, 1, 12, 2, 15, 2, 2, 1, 9, 2, 14, 2, 2, 1, 16, 1, 17, 1, 18, 19, 1, 6, 3, 20, 3, 3, 1, 18, 4, 21, 4, 4, 1, 6, 4, 20, 4, 4, 1, 0 }; static const char _xport_format_parse_trans_targs[] = { 1, 0, 9, 2, 15, 4, 10, 12, 13, 5, 6, 7, 5, 6, 8, 8, 11, 11, 10, 12, 14, 14 }; static const char _xport_format_parse_trans_actions[] = { 0, 0, 0, 0, 0, 0, 3, 12, 0, 3, 12, 0, 5, 1, 12, 1, 9, 1, 5, 1, 12, 1 }; static const char _xport_format_parse_eof_actions[] = { 0, 0, 0, 3, 3, 0, 5, 3, 5, 3, 0, 7, 5, 3, 5, 3 }; static const int xport_format_parse_start = 3; static const int xport_format_parse_en_main = 3; #line 9 "src/sas/readstat_xport_parse_format.rl" readstat_error_t xport_parse_format(const char *data, size_t len, xport_format_t *fmt, readstat_error_handler error_handler, void *user_ctx) { fmt->name[0] = '\0'; fmt->width = 0; fmt->decimals = 0; readstat_error_t retval = READSTAT_OK; const char *p = data; const char *pe = p + len; const char *eof = pe; int cs; unsigned int temp_val = 0; size_t parsed_len = 0; #line 106 "src/sas/readstat_xport_parse_format.c" { cs = xport_format_parse_start; } #line 111 "src/sas/readstat_xport_parse_format.c" { int _klen; unsigned int _trans; const char *_acts; unsigned int _nacts; const char *_keys; if ( p == pe ) goto _test_eof; if ( cs == 0 ) goto _out; _resume: _keys = _xport_format_parse_trans_keys + _xport_format_parse_key_offsets[cs]; _trans = _xport_format_parse_index_offsets[cs]; _klen = _xport_format_parse_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + _klen - 1; while (1) { if ( _upper < _lower ) break; _mid = _lower + ((_upper-_lower) >> 1); if ( (*p) < *_mid ) _upper = _mid - 1; else if ( (*p) > *_mid ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } _keys += _klen; _trans += _klen; } _klen = _xport_format_parse_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + (_klen<<1) - 2; while (1) { if ( _upper < _lower ) break; _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( (*p) < _mid[0] ) _upper = _mid - 2; else if ( (*p) > _mid[1] ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); goto _match; } } _trans += _klen; } _match: _trans = _xport_format_parse_indicies[_trans]; cs = _xport_format_parse_trans_targs[_trans]; if ( _xport_format_parse_trans_actions[_trans] == 0 ) goto _again; _acts = _xport_format_parse_actions + _xport_format_parse_trans_actions[_trans]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 0: #line 28 "src/sas/readstat_xport_parse_format.rl" { temp_val = 10 * temp_val + ((*p) - '0'); } break; case 1: #line 32 "src/sas/readstat_xport_parse_format.rl" { parsed_len = p - data; if (parsed_len < sizeof(fmt->name)) { memcpy(fmt->name, data, parsed_len); fmt->name[parsed_len] = '\0'; } } break; case 2: #line 40 "src/sas/readstat_xport_parse_format.rl" { temp_val = 0; } break; case 3: #line 47 "src/sas/readstat_xport_parse_format.rl" { fmt->width = temp_val; } break; #line 209 "src/sas/readstat_xport_parse_format.c" } } _again: if ( cs == 0 ) goto _out; if ( ++p != pe ) goto _resume; _test_eof: {} if ( p == eof ) { const char *__acts = _xport_format_parse_actions + _xport_format_parse_eof_actions[cs]; unsigned int __nacts = (unsigned int) *__acts++; while ( __nacts-- > 0 ) { switch ( *__acts++ ) { case 1: #line 32 "src/sas/readstat_xport_parse_format.rl" { parsed_len = p - data; if (parsed_len < sizeof(fmt->name)) { memcpy(fmt->name, data, parsed_len); fmt->name[parsed_len] = '\0'; } } break; case 3: #line 47 "src/sas/readstat_xport_parse_format.rl" { fmt->width = temp_val; } break; case 4: #line 48 "src/sas/readstat_xport_parse_format.rl" { fmt->decimals = temp_val; } break; #line 243 "src/sas/readstat_xport_parse_format.c" } } } _out: {} } #line 54 "src/sas/readstat_xport_parse_format.rl" if (cs < 3|| p != pe || parsed_len + 1 > sizeof(fmt->name)) { char error_buf[1024]; if (error_handler) { snprintf(error_buf, sizeof(error_buf), "Invalid format string (length=%d): %.*s", (int)len, (int)len, data); error_handler(error_buf, user_ctx); } retval = READSTAT_ERROR_BAD_FORMAT_STRING; } (void)xport_format_parse_en_main; return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_xport_parse_format.h0000644023477200000240000000023014574360757023153 0ustar00fajardoostaffs readstat_error_t xport_parse_format(const char *data, size_t len, xport_format_t *fmt, readstat_error_handler error_handler, void *user_ctx); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_xport_read.c0000644023477200000240000005511314574360757021411 0ustar00fajardoostaffs#include #include #include #include #include #include #include "../readstat.h" #include "../readstat_iconv.h" #include "../readstat_convert.h" #include "../readstat_malloc.h" #include "readstat_sas.h" #include "readstat_xport.h" #include "ieee.h" #define LINE_LEN 80 typedef struct xport_ctx_s { readstat_callbacks_t handle; size_t file_size; void *user_ctx; const char *input_encoding; const char *output_encoding; iconv_t converter; readstat_io_t *io; time_t timestamp; int obs_count; int var_count; int row_limit; int row_offset; size_t row_length; int parsed_row_count; char file_label[256*4+1]; char table_name[32*4+1]; readstat_variable_t **variables; int version; } xport_ctx_t; static readstat_error_t xport_update_progress(xport_ctx_t *ctx) { readstat_io_t *io = ctx->io; return io->update(ctx->file_size, ctx->handle.progress, ctx->user_ctx, io->io_ctx); } static xport_ctx_t *xport_ctx_init() { xport_ctx_t *ctx = calloc(1, sizeof(xport_ctx_t)); return ctx; } static void xport_ctx_free(xport_ctx_t *ctx) { if (ctx->variables) { int i; for (i=0; ivar_count; i++) { if (ctx->variables[i]) free(ctx->variables[i]); } free(ctx->variables); } if (ctx->converter) { iconv_close(ctx->converter); } free(ctx); } static ssize_t read_bytes(xport_ctx_t *ctx, void *dst, size_t dst_len) { readstat_io_t *io = (readstat_io_t *)ctx->io; return io->read(dst, dst_len, io->io_ctx); } static readstat_error_t xport_skip_record(xport_ctx_t *ctx) { readstat_io_t *io = (readstat_io_t *)ctx->io; if (io->seek(LINE_LEN, READSTAT_SEEK_CUR, io->io_ctx) == -1) return READSTAT_ERROR_SEEK; return READSTAT_OK; } static readstat_error_t xport_skip_rest_of_record(xport_ctx_t *ctx) { readstat_io_t *io = (readstat_io_t *)ctx->io; off_t pos = io->seek(0, READSTAT_SEEK_CUR, io->io_ctx); if (pos == -1) return READSTAT_ERROR_SEEK; if (pos % LINE_LEN) { if (io->seek(LINE_LEN - (pos % LINE_LEN), READSTAT_SEEK_CUR, io->io_ctx) == -1) return READSTAT_ERROR_SEEK; } return READSTAT_OK; } static readstat_error_t xport_read_record(xport_ctx_t *ctx, char *record) { ssize_t bytes_read = read_bytes(ctx, record, LINE_LEN); if (bytes_read < LINE_LEN) return READSTAT_ERROR_READ; record[LINE_LEN] = '\0'; return READSTAT_OK; } static readstat_error_t xport_read_header_record(xport_ctx_t *ctx, xport_header_record_t *xrecord) { char line[LINE_LEN+1]; readstat_error_t retval = READSTAT_OK; retval = xport_read_record(ctx, line); if (retval != READSTAT_OK) return retval; memset(xrecord, 0, sizeof(xport_header_record_t)); int matches = sscanf(line, "HEADER RECORD*******%8s HEADER RECORD!!!!!!!" "%05d%05d%05d" "%05d%05d%05d", xrecord->name, &xrecord->num1, &xrecord->num2, &xrecord->num3, &xrecord->num4, &xrecord->num5, &xrecord->num6); if (matches < 2) { return READSTAT_ERROR_PARSE; } return READSTAT_OK; } static readstat_error_t xport_expect_header_record(xport_ctx_t *ctx, const char *v5_name, const char *v8_name) { readstat_error_t retval = READSTAT_OK; xport_header_record_t xrecord; retval = xport_read_header_record(ctx, &xrecord); if (retval != READSTAT_OK) goto cleanup; if (ctx->version == 5 && strcmp(xrecord.name, v5_name) != 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } else if (ctx->version == 8 && strcmp(xrecord.name, v8_name) != 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } cleanup: return retval; } static readstat_error_t xport_read_table_name_record(xport_ctx_t *ctx) { char line[LINE_LEN+1]; readstat_error_t retval = READSTAT_OK; retval = xport_read_record(ctx, line); if (retval != READSTAT_OK) goto cleanup; retval = readstat_convert(ctx->table_name, sizeof(ctx->table_name), &line[8], ctx->version == 5 ? 8 : 32, ctx->converter); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t xport_read_file_label_record(xport_ctx_t *ctx) { char line[LINE_LEN+1]; readstat_error_t retval = READSTAT_OK; retval = xport_read_record(ctx, line); if (retval != READSTAT_OK) goto cleanup; retval = readstat_convert(ctx->file_label, sizeof(ctx->file_label), &line[32], 40, ctx->converter); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t xport_read_library_record(xport_ctx_t *ctx) { xport_header_record_t xrecord; readstat_error_t retval = xport_read_header_record(ctx, &xrecord); if (retval != READSTAT_OK) goto cleanup; if (strcmp(xrecord.name, "LIBRARY") == 0) { ctx->version = 5; } else if (strcmp(xrecord.name, "LIBV8") == 0) { ctx->version = 8; } else { retval = READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION; goto cleanup; } cleanup: return retval; } static readstat_error_t xport_read_timestamp_record(xport_ctx_t *ctx) { char line[LINE_LEN+1]; readstat_error_t retval = READSTAT_OK; struct tm ts = { .tm_isdst = -1 }; char month[4]; int i; retval = xport_read_record(ctx, line); if (retval != READSTAT_OK) goto cleanup; sscanf(line, "%02d%3s%02d:%02d:%02d:%02d", &ts.tm_mday, month, &ts.tm_year, &ts.tm_hour, &ts.tm_min, &ts.tm_sec); for (i=0; itimestamp = mktime(&ts); cleanup: return retval; } static readstat_error_t xport_read_namestr_header_record(xport_ctx_t *ctx) { xport_header_record_t xrecord; readstat_error_t retval = READSTAT_OK; retval = xport_read_header_record(ctx, &xrecord); if (retval != READSTAT_OK) goto cleanup; if (ctx->version == 5 && strcmp(xrecord.name, "NAMESTR") != 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } else if (ctx->version == 8 && strcmp(xrecord.name, "NAMSTV8") != 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } ctx->var_count = xrecord.num2; ctx->variables = readstat_calloc(ctx->var_count, sizeof(readstat_variable_t *)); if (ctx->variables == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (ctx->handle.metadata) { readstat_metadata_t metadata = { .row_count = -1, .var_count = ctx->var_count, .file_label = ctx->file_label, .table_name = ctx->table_name, .creation_time = ctx->timestamp, .modified_time = ctx->timestamp, .file_format_version = ctx->version }; if (ctx->handle.metadata(&metadata, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } cleanup: return retval; } static readstat_error_t xport_read_obs_header_record(xport_ctx_t *ctx) { return xport_expect_header_record(ctx, "OBS", "OBSV8"); } static readstat_error_t xport_construct_format(char *dst, size_t dst_len, const char *src, size_t src_len, int width, int decimals) { char *format = malloc(4 * src_len + 1); readstat_error_t retval = readstat_convert(format, 4 * src_len + 1, src, src_len, NULL); if (retval != READSTAT_OK) { free(format); return retval; } char *pos = dst; *dst = '\0'; if (format[0]) { pos += snprintf(dst, dst_len, "%s", format); } if (width) { pos += snprintf(pos, dst_len-(pos-dst), "%d", width); } if (decimals) { pos += snprintf(pos, dst_len-(pos-dst), ".%d", decimals); } free(format); return retval; } static readstat_error_t xport_read_labels_v8(xport_ctx_t *ctx, int label_count) { readstat_error_t retval = READSTAT_OK; uint16_t labeldef[3]; char *name = NULL; char *label = NULL; int i; for (i=0; i ctx->var_count || index == 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } name = realloc(name, name_len + 1); label = realloc(label, label_len + 1); readstat_variable_t *variable = ctx->variables[index-1]; if (read_bytes(ctx, name, name_len) != name_len || read_bytes(ctx, label, label_len) != label_len) { retval = READSTAT_ERROR_READ; goto cleanup; } retval = readstat_convert(variable->name, sizeof(variable->name), name, name_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; retval = readstat_convert(variable->label, sizeof(variable->label), label, label_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; } retval = xport_skip_rest_of_record(ctx); if (retval != READSTAT_OK) goto cleanup; retval = xport_read_obs_header_record(ctx); if (retval != READSTAT_OK) goto cleanup; cleanup: free(name); free(label); return retval; } static readstat_error_t xport_read_labels_v9(xport_ctx_t *ctx, int label_count) { readstat_error_t retval = READSTAT_OK; uint16_t labeldef[5]; int i; char *name = NULL; char *label = NULL; char *format = NULL; char *informat = NULL; for (i=0; i ctx->var_count || index == 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } name = realloc(name, name_len + 1); label = realloc(label, label_len + 1); format = realloc(format, format_len + 1); informat = realloc(informat, informat_len + 1); readstat_variable_t *variable = ctx->variables[index-1]; if (read_bytes(ctx, name, name_len) != name_len || read_bytes(ctx, label, label_len) != label_len || read_bytes(ctx, format, format_len) != format_len || read_bytes(ctx, informat, informat_len) != informat_len) { retval = READSTAT_ERROR_READ; goto cleanup; } retval = readstat_convert(variable->name, sizeof(variable->name), name, name_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; retval = readstat_convert(variable->label, sizeof(variable->label), label, label_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; retval = readstat_convert(variable->format, sizeof(variable->format), format, format_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; } retval = xport_skip_rest_of_record(ctx); if (retval != READSTAT_OK) goto cleanup; retval = xport_read_obs_header_record(ctx); if (retval != READSTAT_OK) goto cleanup; cleanup: free(name); free(format); free(informat); free(label); return retval; } static readstat_error_t xport_read_variables(xport_ctx_t *ctx) { int i; readstat_error_t retval = READSTAT_OK; for (i=0; ivar_count; i++) { xport_namestr_t namestr; ssize_t bytes_read = read_bytes(ctx, &namestr, sizeof(xport_namestr_t)); if (bytes_read < sizeof(xport_namestr_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } xport_namestr_bswap(&namestr); readstat_variable_t *variable = calloc(1, sizeof(readstat_variable_t)); variable->index = i; variable->type = namestr.ntype == SAS_COLUMN_TYPE_CHR ? READSTAT_TYPE_STRING : READSTAT_TYPE_DOUBLE; variable->storage_width = namestr.nlng; variable->display_width = namestr.nfl; variable->decimals = namestr.nfd; variable->alignment = namestr.nfj ? READSTAT_ALIGNMENT_RIGHT : READSTAT_ALIGNMENT_LEFT; if (ctx->version == 5) { retval = readstat_convert(variable->name, sizeof(variable->name), namestr.nname, sizeof(namestr.nname), ctx->converter); } else { retval = readstat_convert(variable->name, sizeof(variable->name), namestr.longname, sizeof(namestr.longname), ctx->converter); } if (retval != READSTAT_OK) goto cleanup; retval = readstat_convert(variable->label, sizeof(variable->label), namestr.nlabel, sizeof(namestr.nlabel), ctx->converter); if (retval != READSTAT_OK) goto cleanup; retval = xport_construct_format(variable->format, sizeof(variable->format), namestr.nform, sizeof(namestr.nform), variable->display_width, variable->decimals); if (retval != READSTAT_OK) goto cleanup; ctx->variables[i] = variable; } retval = xport_skip_rest_of_record(ctx); if (retval != READSTAT_OK) goto cleanup; if (ctx->version == 5) { retval = xport_read_obs_header_record(ctx); if (retval != READSTAT_OK) goto cleanup; } else { xport_header_record_t xrecord; retval = xport_read_header_record(ctx, &xrecord); if (retval != READSTAT_OK) goto cleanup; if (strcmp(xrecord.name, "OBSV8") == 0) { /* void */ } else if (strcmp(xrecord.name, "LABELV8") == 0) { retval = xport_read_labels_v8(ctx, xrecord.num1); } else if (strcmp(xrecord.name, "LABELV9") == 0) { retval = xport_read_labels_v9(ctx, xrecord.num1); } if (retval != READSTAT_OK) goto cleanup; } ctx->row_length = 0; int index_after_skipping = 0; for (i=0; ivar_count; i++) { readstat_variable_t *variable = ctx->variables[i]; variable->index_after_skipping = index_after_skipping; int cb_retval = READSTAT_HANDLER_OK; if (ctx->handle.variable) { cb_retval = ctx->handle.variable(i, variable, variable->format, ctx->user_ctx); } if (cb_retval == READSTAT_HANDLER_ABORT) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } if (cb_retval == READSTAT_HANDLER_SKIP_VARIABLE) { variable->skip = 1; } else { index_after_skipping++; } ctx->row_length += variable->storage_width; } cleanup: return retval; } static readstat_error_t xport_process_row(xport_ctx_t *ctx, const char *row, size_t row_length) { readstat_error_t retval = READSTAT_OK; int i; off_t pos = 0; char *string = NULL; for (i=0; ivar_count; i++) { readstat_variable_t *variable = ctx->variables[i]; readstat_value_t value = { .type = variable->type }; if (variable->type == READSTAT_TYPE_STRING) { string = readstat_realloc(string, 4*variable->storage_width+1); if (string == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } retval = readstat_convert(string, 4*variable->storage_width+1, &row[pos], variable->storage_width, ctx->converter); if (retval != READSTAT_OK) goto cleanup; value.v.string_value = string; } else { double dval = NAN; if (variable->storage_width <= XPORT_MAX_DOUBLE_SIZE && variable->storage_width >= XPORT_MIN_DOUBLE_SIZE) { char full_value[8] = { 0 }; if (memcmp(&full_value[1], &row[pos+1], variable->storage_width - 1) == 0 && (row[pos] == '.' || sas_validate_tag(row[pos]) == READSTAT_OK)) { if (row[pos] == '.') { value.is_system_missing = 1; } else { value.tag = row[pos]; value.is_tagged_missing = 1; } } else { memcpy(full_value, &row[pos], variable->storage_width); int rc = cnxptiee(full_value, CN_TYPE_XPORT, &dval, CN_TYPE_NATIVE); if (rc != 0) { retval = READSTAT_ERROR_CONVERT; goto cleanup; } } } value.v.double_value = dval; } pos += variable->storage_width; if (ctx->handle.value && !ctx->variables[i]->skip && !ctx->row_offset) { if (ctx->handle.value(ctx->parsed_row_count, variable, value, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } } if (ctx->row_offset) { ctx->row_offset--; } else { ctx->parsed_row_count++; } cleanup: free(string); return retval; } static readstat_error_t xport_read_data(xport_ctx_t *ctx) { if (!ctx->row_length) return READSTAT_OK; if (!ctx->handle.value) return READSTAT_OK; readstat_error_t retval = READSTAT_OK; char *row = readstat_malloc(ctx->row_length); char *blank_row = readstat_malloc(ctx->row_length); int num_blank_rows = 0; if (row == NULL || blank_row == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } memset(blank_row, ' ', ctx->row_length); while (1) { ssize_t bytes_read = read_bytes(ctx, row, ctx->row_length); if (bytes_read == -1) { retval = READSTAT_ERROR_READ; goto cleanup; } else if (bytes_read < ctx->row_length) { break; } off_t pos = 0; int row_is_blank = 1; for (pos=0; posrow_length; pos++) { if (row[pos] != ' ') { row_is_blank = 0; break; } } if (row_is_blank) { num_blank_rows++; continue; } while (num_blank_rows) { retval = xport_process_row(ctx, blank_row, ctx->row_length); if (retval != READSTAT_OK) goto cleanup; if (ctx->row_limit > 0 && ctx->parsed_row_count == ctx->row_limit) goto cleanup; num_blank_rows--; } retval = xport_process_row(ctx, row, ctx->row_length); if (retval != READSTAT_OK) goto cleanup; retval = xport_update_progress(ctx); if (retval != READSTAT_OK) goto cleanup; if (ctx->row_limit > 0 && ctx->parsed_row_count == ctx->row_limit) break; } cleanup: if (row) free(row); if (blank_row) free(blank_row); return retval; } readstat_error_t readstat_parse_xport(readstat_parser_t *parser, const char *path, void *user_ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = parser->io; xport_ctx_t *ctx = xport_ctx_init(); ctx->handle = parser->handlers; ctx->input_encoding = parser->input_encoding; ctx->output_encoding = parser->output_encoding; ctx->user_ctx = user_ctx; ctx->io = io; ctx->row_limit = parser->row_limit; if (parser->row_offset > 0) ctx->row_offset = parser->row_offset; if (io->open(path, io->io_ctx) == -1) { retval = READSTAT_ERROR_OPEN; goto cleanup; } if ((ctx->file_size = io->seek(0, READSTAT_SEEK_END, io->io_ctx)) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->seek(0, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (ctx->input_encoding && ctx->output_encoding && strcmp(ctx->input_encoding, ctx->output_encoding) != 0) { iconv_t converter = iconv_open(ctx->output_encoding, ctx->input_encoding); if (converter == (iconv_t)-1) { retval = READSTAT_ERROR_UNSUPPORTED_CHARSET; goto cleanup; } ctx->converter = converter; } retval = xport_read_library_record(ctx); if (retval != READSTAT_OK) goto cleanup; retval = xport_skip_record(ctx); if (retval != READSTAT_OK) goto cleanup; retval = xport_read_timestamp_record(ctx); if (retval != READSTAT_OK) goto cleanup; retval = xport_expect_header_record(ctx, "MEMBER", "MEMBV8"); if (retval != READSTAT_OK) goto cleanup; retval = xport_expect_header_record(ctx, "DSCRPTR", "DSCPTV8"); if (retval != READSTAT_OK) goto cleanup; retval = xport_read_table_name_record(ctx); if (retval != READSTAT_OK) goto cleanup; retval = xport_read_file_label_record(ctx); if (retval != READSTAT_OK) goto cleanup; retval = xport_read_namestr_header_record(ctx); if (retval != READSTAT_OK) goto cleanup; retval = xport_read_variables(ctx); if (retval != READSTAT_OK) goto cleanup; if (ctx->row_length) { retval = xport_read_data(ctx); if (retval != READSTAT_OK) goto cleanup; } cleanup: io->close(io->io_ctx); xport_ctx_free(ctx); return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/sas/readstat_xport_write.c0000644023477200000240000004354514574360757021636 0ustar00fajardoostaffs #include #include #include #include "../readstat.h" #include "../readstat_writer.h" #include "readstat_sas.h" #include "readstat_xport.h" #include "readstat_xport_parse_format.h" #include "ieee.h" #define XPORT_DEFAULT_VERISON 8 #define RECORD_LEN 80 #if defined _MSC_VER #define restrict __restrict #endif static void copypad(char * restrict dst, size_t dst_len, const char * restrict src) { char *dst_end = dst + dst_len; while (dst < dst_end && *src) *dst++ = *src++; while (dst < dst_end) *dst++ = ' '; } static readstat_error_t xport_write_bytes(readstat_writer_t *writer, const void *bytes, size_t len) { return readstat_write_bytes_as_lines(writer, bytes, len, RECORD_LEN, ""); } static readstat_error_t xport_finish_record(readstat_writer_t *writer) { return readstat_write_line_padding(writer, ' ', RECORD_LEN, ""); } static readstat_error_t xport_write_record(readstat_writer_t *writer, const char *record) { size_t len = strlen(record); readstat_error_t retval = READSTAT_OK; retval = xport_write_bytes(writer, record, len); if (retval != READSTAT_OK) goto cleanup; retval = xport_finish_record(writer); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t xport_write_header_record_v8(readstat_writer_t *writer, xport_header_record_t *xrecord) { char record[RECORD_LEN+1]; snprintf(record, sizeof(record), "HEADER RECORD*******%-8sHEADER RECORD!!!!!!!%-30d", xrecord->name, xrecord->num1); return xport_write_record(writer, record); } static readstat_error_t xport_write_header_record(readstat_writer_t *writer, xport_header_record_t *xrecord) { char record[RECORD_LEN+1]; snprintf(record, sizeof(record), "HEADER RECORD*******%-8sHEADER RECORD!!!!!!!" "%05d%05d%05d" "%05d%05d%05d", xrecord->name, xrecord->num1, xrecord->num2, xrecord->num3, xrecord->num4, xrecord->num5, xrecord->num6); return xport_write_record(writer, record); } static size_t xport_variable_width(readstat_type_t type, size_t user_width) { if (type == READSTAT_TYPE_STRING) return user_width; if (user_width >= XPORT_MAX_DOUBLE_SIZE || user_width == 0) return XPORT_MAX_DOUBLE_SIZE; if (user_width <= XPORT_MIN_DOUBLE_SIZE) return XPORT_MIN_DOUBLE_SIZE; return user_width; } static readstat_error_t xport_write_variables(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; int i; long offset = 0; int num_long_labels = 0; int any_has_long_format = 0; for (i=0; ivariables_count; i++) { int needs_long_record = 0; readstat_variable_t *variable = readstat_get_variable(writer, i); size_t width = xport_variable_width(variable->type, variable->user_width); xport_namestr_t namestr = { .nvar0 = i+1, .nlng = width, .npos = offset, .niform = " ", .nform = " " }; if (readstat_variable_get_type_class(variable) == READSTAT_TYPE_CLASS_STRING) { namestr.ntype = SAS_COLUMN_TYPE_CHR; } else { namestr.ntype = SAS_COLUMN_TYPE_NUM; } copypad(namestr.nname, sizeof(namestr.nname), variable->name); copypad(namestr.nlabel, sizeof(namestr.nlabel), variable->label); if (variable->format[0]) { xport_format_t format; retval = xport_parse_format(variable->format, strlen(variable->format), &format, NULL, NULL); if (retval != READSTAT_OK) goto cleanup; copypad(namestr.nform, sizeof(namestr.nform), format.name); namestr.nfl = format.width; namestr.nfd = format.decimals; copypad(namestr.niform, sizeof(namestr.niform), format.name); namestr.nifl = format.width; namestr.nifd = format.decimals; if (strlen(format.name) > 8) { any_has_long_format = 1; needs_long_record = 1; } } else if (variable->display_width) { namestr.nfl = variable->display_width; } namestr.nfj = (variable->alignment == READSTAT_ALIGNMENT_RIGHT); if (writer->version == 8) { copypad(namestr.longname, sizeof(namestr.longname), variable->name); size_t label_len = strlen(variable->label); if (label_len > 40) { needs_long_record = 1; } namestr.labeln = label_len; } if (needs_long_record) { num_long_labels++; } offset += width; xport_namestr_bswap(&namestr); retval = xport_write_bytes(writer, &namestr, sizeof(xport_namestr_t)); if (retval != READSTAT_OK) goto cleanup; } retval = xport_finish_record(writer); if (retval != READSTAT_OK) goto cleanup; if (writer->version == 8 && num_long_labels) { xport_header_record_t header = { .name = "LABELV8", .num1 = num_long_labels }; if (any_has_long_format) { strcpy(header.name, "LABELV9"); } retval = xport_write_header_record_v8(writer, &header); if (retval != READSTAT_OK) goto cleanup; for (i=0; ivariables_count; i++) { readstat_variable_t *variable = readstat_get_variable(writer, i); size_t label_len = strlen(variable->label); size_t name_len = strlen(variable->name); size_t format_len = strlen(variable->format); int has_long_label = 0; int has_long_format = 0; has_long_label = (label_len > 40); if (variable->format[0]) { xport_format_t format; retval = xport_parse_format(variable->format, strlen(variable->format), &format, NULL, NULL); if (retval != READSTAT_OK) goto cleanup; if (strlen(format.name) > 8) { has_long_format = 1; } } if (has_long_format) { uint16_t labeldef[5] = { i+1, name_len, label_len, format_len, format_len }; if (machine_is_little_endian()) { labeldef[0] = byteswap2(labeldef[0]); labeldef[1] = byteswap2(labeldef[1]); labeldef[2] = byteswap2(labeldef[2]); labeldef[3] = byteswap2(labeldef[3]); labeldef[4] = byteswap2(labeldef[4]); } retval = readstat_write_bytes(writer, labeldef, sizeof(labeldef)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_string(writer, variable->name); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_string(writer, variable->label); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_string(writer, variable->format); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_string(writer, variable->format); if (retval != READSTAT_OK) goto cleanup; } else if (has_long_label) { uint16_t labeldef[3] = { i+1, name_len, label_len }; if (machine_is_little_endian()) { labeldef[0] = byteswap2(labeldef[0]); labeldef[1] = byteswap2(labeldef[1]); labeldef[2] = byteswap2(labeldef[2]); } retval = readstat_write_bytes(writer, labeldef, sizeof(labeldef)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_string(writer, variable->name); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_string(writer, variable->label); if (retval != READSTAT_OK) goto cleanup; } } retval = xport_finish_record(writer); if (retval != READSTAT_OK) goto cleanup; } cleanup: return retval; } static readstat_error_t xport_write_first_header_record(readstat_writer_t *writer) { xport_header_record_t xrecord = { .name = "LIBRARY" }; if (writer->version == 8) { strcpy(xrecord.name, "LIBV8"); } return xport_write_header_record(writer, &xrecord); } static readstat_error_t xport_write_first_real_header_record(readstat_writer_t *writer, const char *timestamp) { char real_record[RECORD_LEN+1]; snprintf(real_record, sizeof(real_record), "%-8.8s" "%-8.8s" "%-8.8s" "%-8.8s" "%-8.8s" "%-24.24s" "%16.16s", "SAS", "SAS", "SASLIB", "6.06", "bsd4.2", "", timestamp); return xport_write_record(writer, real_record); } static readstat_error_t xport_write_member_header_record(readstat_writer_t *writer) { xport_header_record_t xrecord = { .name = "MEMBER", .num4 = 160, .num6 = 140 }; if (writer->version == 8) { strcpy(xrecord.name, "MEMBV8"); } return xport_write_header_record(writer, &xrecord); } static readstat_error_t xport_write_descriptor_header_record(readstat_writer_t *writer) { xport_header_record_t xrecord = { .name = "DSCRPTR" }; if (writer->version == 8) { strcpy(xrecord.name, "DSCPTV8"); } return xport_write_header_record(writer, &xrecord); } static readstat_error_t xport_write_member_record_v8(readstat_writer_t *writer, char *timestamp) { readstat_error_t retval = READSTAT_OK; char member_header[RECORD_LEN+1]; char *ds_name = "DATASET"; if (writer->table_name[0]) ds_name = writer->table_name; snprintf(member_header, sizeof(member_header), "%-8.8s" "%-32.32s" "%-8.8s" "%-8.8s" "%-8.8s" "%16.16s", "SAS", ds_name, "SASDATA", "6.06", "bsd4.2", timestamp); retval = xport_write_record(writer, member_header); return retval; } static readstat_error_t xport_write_member_record(readstat_writer_t *writer, char *timestamp) { if (writer->version == 8) return xport_write_member_record_v8(writer, timestamp); readstat_error_t retval = READSTAT_OK; char member_header[RECORD_LEN+1]; char *ds_name = "DATASET"; if (writer->table_name[0]) ds_name = writer->table_name; snprintf(member_header, sizeof(member_header), "%-8.8s" "%-8.8s" "%-8.8s" "%-8.8s" "%-8.8s" "%-24.24s" "%16.16s", "SAS", ds_name, "SASDATA", "6.06", "bsd4.2", "", timestamp); retval = xport_write_record(writer, member_header); return retval; } static readstat_error_t xport_write_file_label_record(readstat_writer_t *writer, char *timestamp) { char member_header[RECORD_LEN+1]; snprintf(member_header, sizeof(member_header), "%16.16s" "%16.16s" "%-40.40s" "%-8.8s", timestamp, "", writer->file_label, "" /* dstype? */); return xport_write_record(writer, member_header); } static readstat_error_t xport_write_namestr_header_record(readstat_writer_t *writer) { xport_header_record_t xrecord = { .name = "NAMESTR", .num2 = writer->variables_count }; if (writer->version == 8) { strcpy(xrecord.name, "NAMSTV8"); } return xport_write_header_record(writer, &xrecord); } static readstat_error_t xport_write_obs_header_record(readstat_writer_t *writer) { xport_header_record_t xrecord = { .name = "OBS" }; if (writer->version == 8) { strcpy(xrecord.name, "OBSV8"); } return xport_write_header_record(writer, &xrecord); } static readstat_error_t xport_format_timestamp(char *output, size_t output_len, time_t timestamp) { struct tm *ts = localtime(×tamp); if (!ts) return READSTAT_ERROR_BAD_TIMESTAMP_VALUE; snprintf(output, output_len, "%02d%3.3s%02d:%02d:%02d:%02d", (unsigned int)ts->tm_mday % 100, _xport_months[ts->tm_mon], (unsigned int)ts->tm_year % 100, (unsigned int)ts->tm_hour % 100, (unsigned int)ts->tm_min % 100, (unsigned int)ts->tm_sec % 100 ); return READSTAT_OK; } static readstat_error_t xport_begin_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; readstat_error_t retval = READSTAT_OK; char timestamp[17]; retval = xport_format_timestamp(timestamp, sizeof(timestamp), writer->timestamp); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_first_header_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_first_real_header_record(writer, timestamp); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_record(writer, timestamp); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_member_header_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_descriptor_header_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_member_record(writer, timestamp); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_file_label_record(writer, timestamp); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_namestr_header_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_variables(writer); if (retval != READSTAT_OK) goto cleanup; retval = xport_write_obs_header_record(writer); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t xport_end_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; readstat_error_t retval = READSTAT_OK; retval = xport_finish_record(writer); return retval; } static readstat_error_t xport_write_row(void *writer_ctx, void *row, size_t row_len) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; return xport_write_bytes(writer, row, row_len); } static readstat_error_t xport_write_double(void *row, const readstat_variable_t *var, double value) { char full_value[8]; int rc = cnxptiee(&value, CN_TYPE_NATIVE, full_value, CN_TYPE_XPORT); if (rc) return READSTAT_ERROR_CONVERT; memcpy(row, full_value, var->storage_width); return READSTAT_OK; } static readstat_error_t xport_write_float(void *row, const readstat_variable_t *var, float value) { return xport_write_double(row, var, value); } static readstat_error_t xport_write_int32(void *row, const readstat_variable_t *var, int32_t value) { return xport_write_double(row, var, value); } static readstat_error_t xport_write_int16(void *row, const readstat_variable_t *var, int16_t value) { return xport_write_double(row, var, value); } static readstat_error_t xport_write_int8(void *row, const readstat_variable_t *var, int8_t value) { return xport_write_double(row, var, value); } static readstat_error_t xport_write_string(void *row, const readstat_variable_t *var, const char *string) { memset(row, ' ', var->storage_width); if (string != NULL && string[0]) { size_t value_len = strlen(string); if (value_len > var->storage_width) return READSTAT_ERROR_STRING_VALUE_IS_TOO_LONG; memcpy(row, string, value_len); } return READSTAT_OK; } static readstat_error_t xport_write_missing_numeric(void *row, const readstat_variable_t *var) { char *row_bytes = (char *)row; row_bytes[0] = 0x2e; return READSTAT_OK; } static readstat_error_t xport_write_missing_string(void *row, const readstat_variable_t *var) { return xport_write_string(row, var, NULL); } static readstat_error_t xport_write_missing_tagged(void *row, const readstat_variable_t *var, char tag) { char *row_bytes = (char *)row; readstat_error_t error = sas_validate_tag(tag); if (error == READSTAT_OK) { row_bytes[0] = tag; } return error; } static readstat_error_t xport_metadata_ok(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; if (writer->version != 5 && writer->version != 8) return READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION; if (writer->table_name[0]) { if (writer->version == 8) { return sas_validate_name(writer->table_name, 32); } if (writer->version == 5) { return sas_validate_name(writer->table_name, 8); } } return READSTAT_OK; } readstat_error_t readstat_begin_writing_xport(readstat_writer_t *writer, void *user_ctx, long row_count) { if (writer->version == 0) writer->version = XPORT_DEFAULT_VERISON; writer->callbacks.metadata_ok = &xport_metadata_ok; writer->callbacks.write_int8 = &xport_write_int8; writer->callbacks.write_int16 = &xport_write_int16; writer->callbacks.write_int32 = &xport_write_int32; writer->callbacks.write_float = &xport_write_float; writer->callbacks.write_double = &xport_write_double; writer->callbacks.write_string = &xport_write_string; writer->callbacks.write_missing_string = &xport_write_missing_string; writer->callbacks.write_missing_number = &xport_write_missing_numeric; writer->callbacks.write_missing_tagged = &xport_write_missing_tagged; writer->callbacks.variable_width = &xport_variable_width; writer->callbacks.variable_ok = &sas_validate_variable; writer->callbacks.begin_data = &xport_begin_data; writer->callbacks.end_data = &xport_end_data; writer->callbacks.write_row = &xport_write_row; return readstat_begin_writing_file(writer, user_ctx, row_count); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/src/spss/0000755023477200000240000000000014574564663015406 5ustar00fajardoostaffs././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_por.c0000644023477200000240000001305414574360757020242 0ustar00fajardoostaffs#include #include #include "../readstat.h" #include "../CKHashTable.h" #include "../readstat_convert.h" #include "readstat_spss.h" #include "readstat_por.h" int8_t por_ascii_lookup[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ', '.', '<', '(', '+', '|', '&', '[', ']', '!', '$', '*', ')', ';', '^', '-', '/', '|', ',', '%', '_', '>', '?', '`', ':', '#', '@', '\'', '=', '"', 0, 0, 0, 0, 0, 0, '~', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '{', '}', '\\', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint16_t por_unicode_lookup[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' ', '.', '<', '(', '+', '|', '&', '[', ']', '!', '$', '*', ')', ';', '^', '-', '/', 0x00A3, ',', '%', '_', '>', '?', 0x2018, ':', 0x00A6, '@', 0x2019, '=', '"', 0x2264, 0x25A1, 0x00B1, 0x25A0, 0x00B0, 0x2020, '~', 0x2013, 0x2514, 0x250C, 0x2265, 0x2070, 0x2071, 0x00B2, 0x00B3, 0x2074, 0x2075, 0x2076, 0x2077, 0x2078, 0x2079, 0x2518, 0x2510, 0x2260, 0x2014, 0x207D, 0x207E, 0x2E38, '{', '}', '\\', 0x00A2, 0x2022, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; por_ctx_t *por_ctx_init() { por_ctx_t *ctx = calloc(1, sizeof(por_ctx_t)); ctx->space = ' '; ctx->base30_precision = 20; ctx->var_dict = ck_hash_table_init(1024, 8); return ctx; } void por_ctx_free(por_ctx_t *ctx) { if (ctx->string_buffer) free(ctx->string_buffer); if (ctx->varinfo) { int i; for (i=0; ivar_count; i++) { if (ctx->varinfo[i].label) free(ctx->varinfo[i].label); } free(ctx->varinfo); } if (ctx->variables) { int i; for (i=0; ivar_count; i++) { if (ctx->variables[i]) free(ctx->variables[i]); } free(ctx->variables); } if (ctx->var_dict) ck_hash_table_free(ctx->var_dict); if (ctx->converter) iconv_close(ctx->converter); free(ctx); } ssize_t por_utf8_encode(const unsigned char *input, size_t input_len, char *output, size_t output_len, uint16_t lookup[256]) { int offset = 0; int i; for (i=0; i output_len) return offset; output[offset++] = codepoint; } else { if (codepoint <= 0x07FF) { if (offset + 2 > output_len) return offset; } else /* if (codepoint <= 0xFFFF) */{ if (offset + 3 > output_len) return offset; } /* TODO - For some reason that replacement character isn't recognized * by some systems, so be prepared to insert an ASCII space instead */ int printed = snprintf(output + offset, output_len - offset, "%lc", codepoint); if (printed > 0) { offset += printed; } else { output[offset++] = ' '; } } } return offset; } ssize_t por_utf8_decode( const char *input, size_t input_len, char *output, size_t output_len, uint8_t *lookup, size_t lookup_len) { int offset = 0; wchar_t codepoint = 0; while (1) { int char_len = 0; if (offset + 1 > output_len) return offset; unsigned char val = *input; if (val >= 0x20 && val < 0x7F) { if (!lookup[val]) return -1; output[offset++] = lookup[val]; input++; } else { int conversions = sscanf(input, "%lc%n", &codepoint, &char_len); if (conversions == 0 || codepoint >= lookup_len || lookup[codepoint] == 0) { return -1; } output[offset++] = lookup[codepoint]; input += char_len; } } return offset; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_por.h0000644023477200000240000000240714574360757020247 0ustar00fajardoostaffs extern int8_t por_ascii_lookup[256]; extern uint16_t por_unicode_lookup[256]; typedef struct por_ctx_s { readstat_callbacks_t handle; size_t file_size; void *user_ctx; int pos; readstat_io_t *io; char space; long num_spaces; time_t timestamp; long version; char fweight_name[9]; char file_label[21]; uint16_t byte2unicode[256]; size_t base30_precision; iconv_t converter; unsigned char *string_buffer; size_t string_buffer_len; int labels_offset; int obs_count; int var_count; int var_offset; int row_limit; int row_offset; readstat_variable_t **variables; spss_varinfo_t *varinfo; ck_hash_table_t *var_dict; } por_ctx_t; por_ctx_t *por_ctx_init(void); void por_ctx_free(por_ctx_t *ctx); ssize_t por_utf8_encode(const unsigned char *input, size_t input_len, char *output, size_t output_len, uint16_t lookup[256]); ssize_t por_utf8_decode( const char *input, size_t input_len, char *output, size_t output_len, uint8_t *lookup, size_t lookup_len); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_por_parse.c0000644023477200000240000001604014574360757021432 0ustar00fajardoostaffs#line 1 "src/spss/readstat_por_parse.rl" #include #include "../readstat.h" #include "readstat_por_parse.h" #line 9 "src/spss/readstat_por_parse.c" static const signed char _por_field_parse_actions[] = { 0, 1, 0, 1, 1, 1, 5, 1, 8, 1, 9, 1, 10, 2, 2, 0, 2, 3, 1, 2, 5, 10, 2, 7, 10, 3, 4, 2, 0, 3, 6, 2, 0, 0 }; static const signed char _por_field_parse_key_offsets[] = { 0, 0, 8, 9, 14, 18, 23, 31, 35, 40, 44, 48, 55, 0 }; static const char _por_field_parse_trans_keys[] = { 32, 42, 45, 46, 48, 57, 65, 84, 46, 46, 48, 57, 65, 84, 48, 57, 65, 84, 47, 48, 57, 65, 84, 43, 45, 46, 47, 48, 57, 65, 84, 48, 57, 65, 84, 47, 48, 57, 65, 84, 48, 57, 65, 84, 48, 57, 65, 84, 43, 45, 47, 48, 57, 65, 84, 0 }; static const signed char _por_field_parse_single_lengths[] = { 0, 4, 1, 1, 0, 1, 4, 0, 1, 0, 0, 3, 0, 0 }; static const signed char _por_field_parse_range_lengths[] = { 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0 }; static const signed char _por_field_parse_index_offsets[] = { 0, 0, 7, 9, 13, 16, 20, 27, 30, 34, 37, 40, 46, 0 }; static const signed char _por_field_parse_cond_targs[] = { 1, 2, 3, 4, 6, 6, 0, 12, 0, 4, 6, 6, 0, 5, 5, 0, 12, 5, 5, 0, 7, 9, 10, 12, 6, 6, 0, 8, 8, 0, 12, 8, 8, 0, 8, 8, 0, 11, 11, 0, 7, 9, 12, 11, 11, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0 }; static const signed char _por_field_parse_cond_actions[] = { 0, 9, 0, 0, 13, 13, 0, 11, 0, 7, 25, 25, 0, 16, 16, 0, 11, 3, 3, 0, 5, 5, 5, 19, 1, 1, 0, 13, 13, 0, 22, 1, 1, 0, 29, 29, 0, 16, 16, 0, 0, 0, 11, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const int por_field_parse_start = 1; static const int por_field_parse_en_main = 1; #line 9 "src/spss/readstat_por_parse.rl" ssize_t readstat_por_parse_double(const char *data, size_t len, double *result, readstat_error_handler error_cb, void *user_ctx) { ssize_t retval = 0; double val = 0.0; double denom = 30.0; double temp_frac = 0.0; double num = 0.0; double exp = 0.0; double temp_val = 0.0; const unsigned char *p = (const unsigned char *)data; const unsigned char *pe = p + len; int cs; int is_negative = 0, exp_is_negative = 0; int success = 0; #line 97 "src/spss/readstat_por_parse.c" { cs = (int)por_field_parse_start; } #line 102 "src/spss/readstat_por_parse.c" { int _klen; unsigned int _trans = 0; const char * _keys; const signed char * _acts; unsigned int _nacts; _resume: {} if ( p == pe ) goto _out; _keys = ( _por_field_parse_trans_keys + (_por_field_parse_key_offsets[cs])); _trans = (unsigned int)_por_field_parse_index_offsets[cs]; _klen = (int)_por_field_parse_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + _klen - 1; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _keys += _klen; _trans += (unsigned int)_klen; break; } _mid = _lower + ((_upper-_lower) >> 1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 1; else if ( ( (*( p))) > (*( _mid)) ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } } _klen = (int)_por_field_parse_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + (_klen<<1) - 2; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _trans += (unsigned int)_klen; break; } _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 2; else if ( ( (*( p))) > (*( _mid + 1)) ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); break; } } } _match: {} cs = (int)_por_field_parse_cond_targs[_trans]; if ( _por_field_parse_cond_actions[_trans] != 0 ) { _acts = ( _por_field_parse_actions + (_por_field_parse_cond_actions[_trans])); _nacts = (unsigned int)(*( _acts)); _acts += 1; while ( _nacts > 0 ) { switch ( (*( _acts)) ) { case 0: { { #line 30 "src/spss/readstat_por_parse.rl" if ((( (*( p)))) >= '0' && (( (*( p)))) <= '9') { temp_val = 30 * temp_val + ((( (*( p)))) - '0'); } else if ((( (*( p)))) >= 'A' && (( (*( p)))) <= 'T') { temp_val = 30 * temp_val + (10 + (( (*( p)))) - 'A'); } } #line 184 "src/spss/readstat_por_parse.c" break; } case 1: { { #line 38 "src/spss/readstat_por_parse.rl" if ((( (*( p)))) >= '0' && (( (*( p)))) <= '9') { temp_frac += ((( (*( p)))) - '0') / denom; } else if ((( (*( p)))) >= 'A' && (( (*( p)))) <= 'T') { temp_frac += (10 + (( (*( p)))) - 'A') / denom; } denom *= 30.0; } #line 200 "src/spss/readstat_por_parse.c" break; } case 2: { { #line 47 "src/spss/readstat_por_parse.rl" temp_val = 0; } #line 209 "src/spss/readstat_por_parse.c" break; } case 3: { { #line 49 "src/spss/readstat_por_parse.rl" temp_frac = 0.0; } #line 218 "src/spss/readstat_por_parse.c" break; } case 4: { { #line 53 "src/spss/readstat_por_parse.rl" is_negative = 1; } #line 227 "src/spss/readstat_por_parse.c" break; } case 5: { { #line 53 "src/spss/readstat_por_parse.rl" num = temp_val; } #line 236 "src/spss/readstat_por_parse.c" break; } case 6: { { #line 54 "src/spss/readstat_por_parse.rl" exp_is_negative = 1; } #line 245 "src/spss/readstat_por_parse.c" break; } case 7: { { #line 54 "src/spss/readstat_por_parse.rl" exp = temp_val; } #line 254 "src/spss/readstat_por_parse.c" break; } case 8: { { #line 56 "src/spss/readstat_por_parse.rl" is_negative = 1; } #line 263 "src/spss/readstat_por_parse.c" break; } case 9: { { #line 58 "src/spss/readstat_por_parse.rl" val = NAN; } #line 272 "src/spss/readstat_por_parse.c" break; } case 10: { { #line 60 "src/spss/readstat_por_parse.rl" success = 1; {p += 1; goto _out; } } #line 281 "src/spss/readstat_por_parse.c" break; } } _nacts -= 1; _acts += 1; } } if ( cs != 0 ) { p += 1; goto _resume; } _out: {} } #line 64 "src/spss/readstat_por_parse.rl" if (!isnan(val)) { val = 1.0 * num + temp_frac; if (exp_is_negative) exp *= -1; if (exp) { val *= pow(30.0, exp); } if (is_negative) val *= -1; } if (!success) { retval = -1; if (error_cb) { char error_buf[1024]; snprintf(error_buf, sizeof(error_buf), "Read bytes: %ld String: %.*s Ending state: %d", (long)(p - (const unsigned char *)data), (int)len, data, cs); error_cb(error_buf, user_ctx); } } if (retval == 0) { if (result) *result = val; retval = (p - (const unsigned char *)data); } /* suppress warning */ (void)por_field_parse_en_main; return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_por_parse.h0000644023477200000240000000025314574360757021436 0ustar00fajardoostaffs// // readstat_por_parse.h // ssize_t readstat_por_parse_double(const char *data, size_t len, double *result, readstat_error_handler error_cb, void *user_ctx); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_por_read.c0000644023477200000240000007152714574360757021246 0ustar00fajardoostaffs// // readstat_por.c // #include #include #include #include #include #include #include #include #include "../readstat.h" #include "../readstat_iconv.h" #include "../readstat_convert.h" #include "../readstat_malloc.h" #include "../CKHashTable.h" #include "readstat_por_parse.h" #include "readstat_spss.h" #include "readstat_por.h" #define POR_LINE_LENGTH 80 #define POR_LABEL_NAME_PREFIX "labels" #define POR_FORMAT_SHIFT 82 #define MAX_FORMAT_TYPE (POR_FORMAT_SHIFT+SPSS_FORMAT_TYPE_YMDHMS) #define MAX_FORMAT_WIDTH 20000 #define MAX_FORMAT_DECIMALS 100 #define MAX_STRING_LENGTH 20000 #define MAX_VARS 1000000 #define MAX_WIDTH 1000000 #define MAX_LINES 1000000 #define MAX_STRINGS 1000000 #define MAX_LABELS 1000000 static ssize_t read_bytes(por_ctx_t *ctx, void *dst, size_t len); static readstat_error_t read_string(por_ctx_t *ctx, char *data, size_t len); static readstat_error_t por_update_progress(por_ctx_t *ctx) { readstat_io_t *io = ctx->io; return io->update(ctx->file_size, ctx->handle.progress, ctx->user_ctx, io->io_ctx); } static ssize_t read_bytes(por_ctx_t *ctx, void *dst, size_t len) { char *dst_pos = (char *)dst; readstat_io_t *io = ctx->io; char byte; while (dst_pos < (char *)dst + len) { if (ctx->num_spaces) { *dst_pos++ = ctx->space; ctx->num_spaces--; continue; } ssize_t bytes_read = io->read(&byte, 1, io->io_ctx); if (bytes_read == 0) { break; } if (bytes_read == -1) { return -1; } if (byte == '\r' || byte == '\n') { if (byte == '\r') { bytes_read = io->read(&byte, 1, io->io_ctx); if (bytes_read == 0 || bytes_read == -1 || byte != '\n') return -1; } ctx->num_spaces = POR_LINE_LENGTH - ctx->pos; ctx->pos = 0; continue; } else if (ctx->pos == POR_LINE_LENGTH) { return -1; } *dst_pos++ = byte; ctx->pos++; } return (int)(dst_pos - (char *)dst); } static uint16_t read_tag(por_ctx_t *ctx) { unsigned char tag; if (read_bytes(ctx, &tag, 1) != 1) { return -1; } return ctx->byte2unicode[tag]; } static readstat_error_t read_double_with_peek(por_ctx_t *ctx, double *out_double, unsigned char peek) { readstat_error_t retval = READSTAT_OK; double value = NAN; unsigned char buffer[100]; char utf8_buffer[300]; char error_buf[1024]; int64_t len = 0; ssize_t bytes_read = 0; buffer[0] = peek; bytes_read = read_bytes(ctx, &buffer[1], 1); if (bytes_read != 1) return READSTAT_ERROR_PARSE; if (ctx->byte2unicode[buffer[0]] == '*' && ctx->byte2unicode[buffer[1]] == '.') { if (out_double) *out_double = NAN; return READSTAT_OK; } int64_t i=2; while (ibyte2unicode[buffer[i-1]] != '/') { bytes_read = read_bytes(ctx, &buffer[i], 1); if (bytes_read != 1) return READSTAT_ERROR_PARSE; i++; } if (i == sizeof(buffer)) { return READSTAT_ERROR_PARSE; } len = por_utf8_encode(buffer, i, utf8_buffer, sizeof(utf8_buffer), ctx->byte2unicode); if (len == -1) { if (ctx->handle.error) { snprintf(error_buf, sizeof(error_buf), "Error converting double string (length=%" PRId64 "): %.*s", i, (int)i, buffer); ctx->handle.error(error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_CONVERT; goto cleanup; } bytes_read = readstat_por_parse_double(utf8_buffer, len, &value, ctx->handle.error, ctx->user_ctx); if (bytes_read == -1) { if (ctx->handle.error) { snprintf(error_buf, sizeof(error_buf), "Error parsing double string (length=%" PRId64 "): %.*s [%s]", len, (int)len, utf8_buffer, buffer); ctx->handle.error(error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_PARSE; goto cleanup; } cleanup: if (out_double) *out_double = value; return retval; } static readstat_error_t read_double(por_ctx_t *ctx, double *out_double) { unsigned char peek; size_t bytes_read = read_bytes(ctx, &peek, 1); if (bytes_read != 1) return READSTAT_ERROR_PARSE; return read_double_with_peek(ctx, out_double, peek); } static readstat_error_t read_integer_in_range(por_ctx_t *ctx, int min, int max, int *out_integer) { double dval = NAN; readstat_error_t retval = read_double(ctx, &dval); if (retval != READSTAT_OK) return retval; if (isnan(dval) || dval < min || dval > max) return READSTAT_ERROR_PARSE; if (out_integer) *out_integer = (int)dval; return READSTAT_OK; } static readstat_error_t maybe_read_double(por_ctx_t *ctx, double *out_double, int *out_finished) { unsigned char peek; size_t bytes_read = read_bytes(ctx, &peek, 1); if (bytes_read != 1) return READSTAT_ERROR_PARSE; if (ctx->byte2unicode[peek] == 'Z') { if (out_double) *out_double = NAN; if (out_finished) *out_finished = 1; return READSTAT_OK; } if (out_finished) *out_finished = 0; return read_double_with_peek(ctx, out_double, peek); } static readstat_error_t maybe_read_string(por_ctx_t *ctx, char *data, size_t len, int *out_finished) { readstat_error_t retval = READSTAT_OK; double value; int finished = 0; char error_buf[1024]; size_t string_length = 0; retval = maybe_read_double(ctx, &value, &finished); if (retval != READSTAT_OK || finished) { if (out_finished) *out_finished = finished; return retval; } if (value < 0 || value > MAX_STRING_LENGTH || isnan(value)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } string_length = (size_t)value; if (string_length > ctx->string_buffer_len) { ctx->string_buffer_len = string_length; ctx->string_buffer = realloc(ctx->string_buffer, ctx->string_buffer_len); memset(ctx->string_buffer, 0, ctx->string_buffer_len); } if (read_bytes(ctx, ctx->string_buffer, string_length) == -1) { retval = READSTAT_ERROR_READ; goto cleanup; } size_t bytes_encoded = por_utf8_encode(ctx->string_buffer, string_length, data, len - 1, ctx->byte2unicode); if (bytes_encoded == -1) { if (ctx->handle.error) { snprintf(error_buf, sizeof(error_buf), "Error converting string: %.*s", (int)string_length, ctx->string_buffer); ctx->handle.error(error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_CONVERT; goto cleanup; } data[bytes_encoded] = '\0'; if (out_finished) *out_finished = 0; cleanup: return retval; } static readstat_error_t read_string(por_ctx_t *ctx, char *data, size_t len) { int finished = 0; readstat_error_t retval = maybe_read_string(ctx, data, len, &finished); if (retval == READSTAT_OK && finished) { return READSTAT_ERROR_PARSE; } return retval; } static readstat_error_t read_variable_count_record(por_ctx_t *ctx) { int value; readstat_error_t retval = READSTAT_OK; if (ctx->var_count) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if ((retval = read_integer_in_range(ctx, 0, MAX_VARS, &value)) != READSTAT_OK) { goto cleanup; } ctx->var_count = value; ctx->variables = readstat_calloc(ctx->var_count, sizeof(readstat_variable_t *)); ctx->varinfo = readstat_calloc(ctx->var_count, sizeof(spss_varinfo_t)); if (ctx->variables == NULL || ctx->varinfo == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (ctx->handle.metadata) { readstat_metadata_t metadata = { .row_count = -1, .var_count = ctx->var_count, .creation_time = ctx->timestamp, .modified_time = ctx->timestamp, .file_format_version = ctx->version, .file_label = ctx->file_label }; if (ctx->handle.metadata(&metadata, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } cleanup: return retval; } static readstat_error_t read_precision_record(por_ctx_t *ctx) { int precision = 0; readstat_error_t error = read_integer_in_range(ctx, 0, 100, &precision); if (error == READSTAT_OK) ctx->base30_precision = precision; return error; } static readstat_error_t read_case_weight_record(por_ctx_t *ctx) { return read_string(ctx, ctx->fweight_name, sizeof(ctx->fweight_name)); } static readstat_error_t read_variable_record(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int value; int i; spss_varinfo_t *varinfo = NULL; spss_format_t *formats[2]; ctx->var_offset++; if (ctx->var_offset == ctx->var_count) { retval = READSTAT_ERROR_PARSE; goto cleanup; } varinfo = &ctx->varinfo[ctx->var_offset]; formats[0] = &varinfo->print_format; formats[1] = &varinfo->write_format; varinfo->labels_index = -1; if ((retval = read_integer_in_range(ctx, 0, MAX_WIDTH, &value)) != READSTAT_OK) { goto cleanup; } varinfo->width = value; if (varinfo->width == 0) { varinfo->type = READSTAT_TYPE_DOUBLE; } else { varinfo->type = READSTAT_TYPE_STRING; } if ((retval = read_string(ctx, varinfo->name, sizeof(varinfo->name))) != READSTAT_OK) { goto cleanup; } ck_str_hash_insert(varinfo->name, varinfo, ctx->var_dict); for (i=0; i POR_FORMAT_SHIFT) { // Some files in the wild have their format types shifted by 82 for date/time values // I have no idea why, but see test files linked from: // https://github.com/WizardMac/ReadStat/issues/158 format->type = value - POR_FORMAT_SHIFT; } else { format->type = value; } if ((retval = read_integer_in_range(ctx, 0, MAX_FORMAT_WIDTH, &value)) != READSTAT_OK) { goto cleanup; } format->width = value; if ((retval = read_integer_in_range(ctx, 0, MAX_FORMAT_DECIMALS, &value)) != READSTAT_OK) { goto cleanup; } format->decimal_places = value; } cleanup: return retval; } static readstat_error_t read_missing_value_record(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; spss_varinfo_t *varinfo = NULL; if (ctx->var_offset < 0 || ctx->var_offset >= ctx->var_count) { retval = READSTAT_ERROR_PARSE; goto cleanup; } varinfo = &ctx->varinfo[ctx->var_offset]; if (varinfo->type == READSTAT_TYPE_DOUBLE) { if ((retval = read_double(ctx, &varinfo->missing_double_values[varinfo->n_missing_values])) != READSTAT_OK) { goto cleanup; } } else { if ((retval = read_string(ctx, varinfo->missing_string_values[varinfo->n_missing_values], sizeof(varinfo->missing_string_values[varinfo->n_missing_values]))) != READSTAT_OK) { goto cleanup; } } if (varinfo->n_missing_values > 2) { retval = READSTAT_ERROR_PARSE; goto cleanup; } varinfo->n_missing_values++; cleanup: return retval; } static readstat_error_t read_missing_value_range_record(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; spss_varinfo_t *varinfo = NULL; if (ctx->var_offset < 0 || ctx->var_offset == ctx->var_count) { retval = READSTAT_ERROR_PARSE; goto cleanup; } varinfo = &ctx->varinfo[ctx->var_offset]; varinfo->missing_range = 1; varinfo->n_missing_values = 2; if (varinfo->type == READSTAT_TYPE_DOUBLE) { if ((retval = read_double(ctx, &varinfo->missing_double_values[0])) != READSTAT_OK) { goto cleanup; } if ((retval = read_double(ctx, &varinfo->missing_double_values[1])) != READSTAT_OK) { goto cleanup; } } else { if ((retval = read_string(ctx, varinfo->missing_string_values[0], sizeof(varinfo->missing_string_values[0]))) != READSTAT_OK) { goto cleanup; } if ((retval = read_string(ctx, varinfo->missing_string_values[1], sizeof(varinfo->missing_string_values[1]))) != READSTAT_OK) { goto cleanup; } } cleanup: return retval; } static readstat_error_t read_missing_value_lo_range_record(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; spss_varinfo_t *varinfo = NULL; if (ctx->var_offset < 0 || ctx->var_offset == ctx->var_count) { retval = READSTAT_ERROR_PARSE; goto cleanup; } varinfo = &ctx->varinfo[ctx->var_offset]; varinfo->missing_range = 1; varinfo->n_missing_values = 2; if (varinfo->type == READSTAT_TYPE_DOUBLE) { varinfo->missing_double_values[0] = -HUGE_VAL; if ((retval = read_double(ctx, &varinfo->missing_double_values[1])) != READSTAT_OK) { goto cleanup; } } else { varinfo->missing_string_values[0][0] = '\0'; if ((retval = read_string(ctx, varinfo->missing_string_values[1], sizeof(varinfo->missing_string_values[1]))) != READSTAT_OK) { goto cleanup; } } cleanup: return retval; } static readstat_error_t read_missing_value_hi_range_record(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; spss_varinfo_t *varinfo = NULL; if (ctx->var_offset < 0 || ctx->var_offset == ctx->var_count) { retval = READSTAT_ERROR_PARSE; goto cleanup; } varinfo = &ctx->varinfo[ctx->var_offset]; varinfo->missing_range = 1; varinfo->n_missing_values = 2; if (varinfo->type == READSTAT_TYPE_DOUBLE) { if ((retval = read_double(ctx, &varinfo->missing_double_values[0])) != READSTAT_OK) { goto cleanup; } varinfo->missing_double_values[1] = HUGE_VAL; } else { if ((retval = read_string(ctx, varinfo->missing_string_values[0], sizeof(varinfo->missing_string_values[0]))) != READSTAT_OK) { goto cleanup; } varinfo->missing_string_values[1][0] = '\0'; } cleanup: return retval; } static readstat_error_t read_document_record(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; char string[256]; int i; int line_count = 0; if ((retval = read_integer_in_range(ctx, 0, MAX_LINES, &line_count)) != READSTAT_OK) { goto cleanup; } for (i=0; ihandle.note) { if (ctx->handle.note(i, string, ctx->user_ctx) != READSTAT_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } } cleanup: return retval; } static readstat_error_t read_variable_label_record(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; char string[256]; spss_varinfo_t *varinfo = NULL; if (ctx->var_offset < 0 || ctx->var_offset == ctx->var_count) { retval = READSTAT_ERROR_PARSE; goto cleanup; } varinfo = &ctx->varinfo[ctx->var_offset]; if ((retval = read_string(ctx, string, sizeof(string))) != READSTAT_OK) { goto cleanup; } varinfo->label = realloc(varinfo->label, 4*strlen(string) + 1); retval = readstat_convert(varinfo->label, 4*strlen(string) + 1, string, strlen(string), ctx->converter); cleanup: return retval; } static readstat_error_t read_value_label_record(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; double dval; int i; char string[256]; int count = 0, label_count = 0; char label_name_buf[256]; char label_buf[256]; snprintf(label_name_buf, sizeof(label_name_buf), POR_LABEL_NAME_PREFIX "%d", ctx->labels_offset); readstat_type_t value_type = READSTAT_TYPE_DOUBLE; if ((retval = read_integer_in_range(ctx, 0, MAX_STRINGS, &count)) != READSTAT_OK) { goto cleanup; } for (i=0; ivar_dict); if (info) { value_type = info->type; info->labels_index = ctx->labels_offset; } } if ((retval = read_integer_in_range(ctx, 0, MAX_LABELS, &label_count)) != READSTAT_OK) { goto cleanup; } for (i=0; ihandle.value_label) { if (ctx->handle.value_label(label_name_buf, value, label_buf, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } } ctx->labels_offset++; cleanup: return retval; } static readstat_error_t read_por_file_data(por_ctx_t *ctx) { int i; char input_string[256]; char output_string[4*256+1]; char error_buf[1024]; readstat_error_t rs_retval = READSTAT_OK; if (ctx->var_count == 0) return READSTAT_OK; while (1) { int finished = 0; for (i=0; ivar_count; i++) { spss_varinfo_t *info = &ctx->varinfo[i]; readstat_value_t value = { .type = info->type }; if (info->type == READSTAT_TYPE_STRING) { rs_retval = maybe_read_string(ctx, input_string, sizeof(input_string), &finished); if (rs_retval != READSTAT_OK) { if (ctx->handle.error) { snprintf(error_buf, sizeof(error_buf), "Error in %s (row=%d)", info->name, ctx->obs_count+1); ctx->handle.error(error_buf, ctx->user_ctx); } goto cleanup; } else if (finished) { if (i != 0) rs_retval = READSTAT_ERROR_PARSE; goto cleanup; } rs_retval = readstat_convert(output_string, sizeof(output_string), input_string, strlen(input_string), ctx->converter); if (rs_retval != READSTAT_OK) { goto cleanup; } value.v.string_value = output_string; } else if (info->type == READSTAT_TYPE_DOUBLE) { rs_retval = maybe_read_double(ctx, &value.v.double_value, &finished); if (rs_retval != READSTAT_OK) { if (ctx->handle.error) { snprintf(error_buf, sizeof(error_buf), "Error in %s (row=%d)", info->name, ctx->obs_count+1); ctx->handle.error(error_buf, ctx->user_ctx); } goto cleanup; } else if (finished) { if (i != 0) rs_retval = READSTAT_ERROR_PARSE; goto cleanup; } value.is_system_missing = isnan(value.v.double_value); } if (ctx->handle.value && !ctx->variables[i]->skip && !ctx->row_offset) { if (ctx->handle.value(ctx->obs_count, ctx->variables[i], value, ctx->user_ctx) != READSTAT_HANDLER_OK) { rs_retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } } if (ctx->row_offset) { ctx->row_offset--; } else { ctx->obs_count++; } rs_retval = por_update_progress(ctx); if (rs_retval != READSTAT_OK) break; if (ctx->row_limit > 0 && ctx->obs_count == ctx->row_limit) break; } cleanup: return rs_retval; } readstat_error_t read_version_and_timestamp(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; char string[256]; struct tm timestamp = { .tm_isdst = -1 }; unsigned char version; if (read_bytes(ctx, &version, sizeof(version)) != sizeof(version)) { retval = READSTAT_ERROR_READ; goto cleanup; } if ((retval = read_string(ctx, string, sizeof(string))) != READSTAT_OK) { /* creation date */ goto cleanup; } if (sscanf(string, "%04d%02d%02d", ×tamp.tm_year, ×tamp.tm_mon, ×tamp.tm_mday) != 3) { retval = READSTAT_ERROR_BAD_TIMESTAMP_STRING; goto cleanup; } if ((retval = read_string(ctx, string, sizeof(string))) != READSTAT_OK) { /* creation time */ goto cleanup; } if (sscanf(string, "%02d%02d%02d", ×tamp.tm_hour, ×tamp.tm_min, ×tamp.tm_sec) != 3) { retval = READSTAT_ERROR_BAD_TIMESTAMP_STRING; goto cleanup; } timestamp.tm_year -= 1900; timestamp.tm_mon--; ctx->timestamp = mktime(×tamp); ctx->version = ctx->byte2unicode[version] - 'A'; cleanup: return retval; } readstat_error_t handle_variables(por_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int i; int index_after_skipping = 0; for (i=0; ivar_count; i++) { char label_name_buf[256]; spss_varinfo_t *info = &ctx->varinfo[i]; info->index = i; ctx->variables[i] = spss_init_variable_for_info(info, index_after_skipping, ctx->converter); snprintf(label_name_buf, sizeof(label_name_buf), POR_LABEL_NAME_PREFIX "%d", info->labels_index); int cb_retval = READSTAT_HANDLER_OK; if (ctx->handle.variable) { cb_retval = ctx->handle.variable(i, ctx->variables[i], info->labels_index == -1 ? NULL : label_name_buf, ctx->user_ctx); } if (cb_retval == READSTAT_HANDLER_ABORT) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } if (cb_retval == READSTAT_HANDLER_SKIP_VARIABLE) { ctx->variables[i]->skip = 1; } else { index_after_skipping++; } } if (ctx->handle.fweight && ctx->fweight_name[0]) { for (i=0; ivar_count; i++) { spss_varinfo_t *info = &ctx->varinfo[i]; if (strcmp(info->name, ctx->fweight_name) == 0) { if (ctx->handle.fweight(ctx->variables[i], ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } break; } } } cleanup: return retval; } readstat_error_t readstat_parse_por(readstat_parser_t *parser, const char *path, void *user_ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = parser->io; unsigned char reverse_lookup[256]; char vanity[5][40]; char error_buf[1024]; por_ctx_t *ctx = por_ctx_init(); ctx->handle = parser->handlers; ctx->user_ctx = user_ctx; ctx->io = io; ctx->row_limit = parser->row_limit; if (parser->row_offset > 0) ctx->row_offset = parser->row_offset; if (parser->output_encoding) { if (strcmp(parser->output_encoding, "UTF-8") != 0) ctx->converter = iconv_open(parser->output_encoding, "UTF-8"); if (ctx->converter == (iconv_t)-1) { ctx->converter = NULL; retval = READSTAT_ERROR_UNSUPPORTED_CHARSET; goto cleanup; } } if (io->open(path, io->io_ctx) == -1) { retval = READSTAT_ERROR_OPEN; goto cleanup; } if ((ctx->file_size = io->seek(0, READSTAT_SEEK_END, io->io_ctx)) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->seek(0, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (read_bytes(ctx, vanity, sizeof(vanity)) != sizeof(vanity)) { retval = READSTAT_ERROR_READ; goto cleanup; } retval = readstat_convert(ctx->file_label, sizeof(ctx->file_label), vanity[1] + 20, 20, NULL); if (retval != READSTAT_OK) goto cleanup; if (read_bytes(ctx, reverse_lookup, sizeof(reverse_lookup)) != sizeof(reverse_lookup)) { retval = READSTAT_ERROR_READ; goto cleanup; } ctx->space = reverse_lookup[126]; int i; for (i=0; i<256; i++) { if (por_ascii_lookup[i]) { ctx->byte2unicode[reverse_lookup[i]] = por_ascii_lookup[i]; } else if (por_unicode_lookup[i]) { ctx->byte2unicode[reverse_lookup[i]] = por_unicode_lookup[i]; } } ctx->byte2unicode[reverse_lookup[64]] = por_unicode_lookup[64]; unsigned char check[8]; char tr_check[8]; if (read_bytes(ctx, check, sizeof(check)) != sizeof(check)) { retval = READSTAT_ERROR_READ; goto cleanup; } ssize_t encoded_len; if ((encoded_len = por_utf8_encode(check, sizeof(check), tr_check, sizeof(tr_check), ctx->byte2unicode)) == -1) { if (ctx->handle.error) { snprintf(error_buf, sizeof(error_buf), "Error converting check string: %.*s", (int)sizeof(check), check); ctx->handle.error(error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_CONVERT; goto cleanup; } if (strncmp("SPSSPORT", tr_check, encoded_len) != 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } ctx->var_offset = -1; char string[256]; retval = read_version_and_timestamp(ctx); if (retval != READSTAT_OK) goto cleanup; while (1) { uint16_t tr_tag = read_tag(ctx); switch (tr_tag) { case '1': /* product ID */ case '2': /* author ID */ case '3': /* sub-product ID */ retval = read_string(ctx, string, sizeof(string)); break; case '4': /* variable count */ retval = read_variable_count_record(ctx); break; case '5': /* precision */ retval = read_precision_record(ctx); break; case '6': /* case weight */ retval = read_case_weight_record(ctx); break; case '7': /* variable */ retval = read_variable_record(ctx); break; case '8': /* missing value */ retval = read_missing_value_record(ctx); break; case 'B': /* missing value range */ retval = read_missing_value_range_record(ctx); break; case '9': /* LO THRU x */ retval = read_missing_value_lo_range_record(ctx); break; case 'A': /* x THRU HI */ retval = read_missing_value_hi_range_record(ctx); break; case 'C': /* variable label */ retval = read_variable_label_record(ctx); break; case 'D': /* value label */ retval = read_value_label_record(ctx); break; case 'E': /* document record */ retval = read_document_record(ctx); break; case 'F': /* file data */ if (ctx->var_offset != ctx->var_count - 1) { retval = READSTAT_ERROR_COLUMN_COUNT_MISMATCH; goto cleanup; } retval = handle_variables(ctx); if (retval != READSTAT_OK) goto cleanup; if (ctx->handle.value) { retval = read_por_file_data(ctx); } goto cleanup; default: retval = READSTAT_ERROR_PARSE; goto cleanup; } if (retval != READSTAT_OK) break; } cleanup: io->close(io->io_ctx); por_ctx_free(ctx); return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_por_write.c0000644023477200000240000006461114574360757021461 0ustar00fajardoostaffs #include #include #include #include #include #include "../readstat.h" #include "../CKHashTable.h" #include "../readstat_writer.h" #include "readstat_spss.h" #include "readstat_por.h" #define POR_BASE30_PRECISION 50 typedef struct por_write_ctx_s { unsigned char *unicode2byte; size_t unicode2byte_len; } por_write_ctx_t; static inline char por_encode_base30_digit(uint64_t digit) { if (digit < 10) return '0' + digit; return 'A' + (digit - 10); } static int por_write_base30_integer(char *string, size_t string_len, uint64_t integer) { int start = 0; int end = 0; int offset = 0; while (integer) { string[offset++] = por_encode_base30_digit(integer % 30); integer /= 30; } end = offset; offset--; while (offset > start) { char tmp = string[start]; string[start] = string[offset]; string[offset] = tmp; offset--; start++; } return end; } static readstat_error_t por_finish(readstat_writer_t *writer) { return readstat_write_line_padding(writer, 'Z', 80, "\r\n"); } static readstat_error_t por_write_bytes(readstat_writer_t *writer, const void *bytes, size_t len) { return readstat_write_bytes_as_lines(writer, bytes, len, 80, "\r\n"); } static readstat_error_t por_write_string_n(readstat_writer_t *writer, por_write_ctx_t *ctx, const char *string, size_t input_len) { char error_buf[1024]; readstat_error_t retval = READSTAT_OK; char *por_string = malloc(input_len); ssize_t output_len = por_utf8_decode(string, input_len, por_string, input_len, ctx->unicode2byte, ctx->unicode2byte_len); if (output_len == -1) { if (writer->error_handler) { snprintf(error_buf, sizeof(error_buf), "Error converting string (length=%" PRId64 "): %.*s", (int64_t)input_len, (int)input_len, string); writer->error_handler(error_buf, writer->user_ctx); } retval = READSTAT_ERROR_CONVERT; goto cleanup; } retval = por_write_bytes(writer, por_string, output_len); cleanup: if (por_string) free(por_string); return retval; } static readstat_error_t por_write_tag(readstat_writer_t *writer, por_write_ctx_t *ctx, char tag) { char string[2]; string[0] = tag; string[1] = '\0'; return por_write_string_n(writer, ctx, string, 1); } static ssize_t por_write_double_to_buffer(char *string, size_t buffer_len, double value, long precision) { int offset = 0; if (isnan(value)) { string[offset++] = '*'; string[offset++] = '.'; } else if (isinf(value)) { if (value < 0.0) { string[offset++] = '-'; } string[offset++] = '1'; string[offset++] = '+'; string[offset++] = 'T'; string[offset++] = 'T'; string[offset++] = '/'; } else { long integers_printed = 0; double integer_part; double fraction = modf(fabs(value), &integer_part); int64_t integer = integer_part; int64_t exponent = 0; if (value < 0.0) { string[offset++] = '-'; } if (integer == 0) { string[offset++] = '0'; } else { while (fraction == 0 && integer != 0 && (integer % 30) == 0) { integer /= 30; exponent++; } integers_printed = por_write_base30_integer(&string[offset], buffer_len - offset, integer); offset += integers_printed; } /* should use exponents for efficiency, but this works */ if (fraction) { string[offset++] = '.'; } while (fraction && integers_printed < precision) { fraction = modf(fraction * 30, &integer_part); integer = integer_part; if (integer < 0) { return -1; } else { string[offset++] = por_encode_base30_digit(integer); } integers_printed++; } if (exponent) { string[offset++] = '+'; offset += por_write_base30_integer(&string[offset], buffer_len - offset, exponent); } string[offset++] = '/'; } string[offset] = '\0'; return offset; } static readstat_error_t por_write_double(readstat_writer_t *writer, por_write_ctx_t *ctx, double value) { char error_buf[1024]; char string[256]; ssize_t bytes_written = por_write_double_to_buffer(string, sizeof(string), value, POR_BASE30_PRECISION); if (bytes_written == -1) { if (writer->error_handler) { snprintf(error_buf, sizeof(error_buf), "Unable to encode number: %lf", value); writer->error_handler(error_buf, writer->user_ctx); } return READSTAT_ERROR_WRITE; } return por_write_string_n(writer, ctx, string, bytes_written); } static readstat_error_t por_write_string_field_n(readstat_writer_t *writer, por_write_ctx_t *ctx, const char *string, size_t len) { readstat_error_t error = por_write_double(writer, ctx, len); if (error != READSTAT_OK) return error; return por_write_string_n(writer, ctx, string, len); } static readstat_error_t por_write_string_field(readstat_writer_t *writer, por_write_ctx_t *ctx, const char *string) { return por_write_string_field_n(writer, ctx, string, strlen(string)); } static por_write_ctx_t *por_write_ctx_init() { por_write_ctx_t *ctx = calloc(1, sizeof(por_write_ctx_t)); uint16_t max_unicode = 0; int i; for (i=0; i max_unicode) max_unicode = por_unicode_lookup[i]; } ctx->unicode2byte = malloc(max_unicode+1); ctx->unicode2byte_len = max_unicode+1; for (i=0; iunicode2byte[por_unicode_lookup[i]] = por_ascii_lookup[i]; } if (por_ascii_lookup[i]) { ctx->unicode2byte[por_ascii_lookup[i]] = por_ascii_lookup[i]; } } return ctx; } static void por_write_ctx_free(por_write_ctx_t *ctx) { if (ctx->unicode2byte) free(ctx->unicode2byte); free(ctx); } static readstat_error_t por_emit_header(readstat_writer_t *writer, por_write_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; size_t file_label_len = strlen(writer->file_label); char vanity[5][40]; memset(vanity, '0', sizeof(vanity)); memcpy(vanity[1], "ASCII SPSS PORT FILE", 20); strncpy(vanity[1] + 20, writer->file_label, 20); if (file_label_len < 20) memset(vanity[1] + 20 + file_label_len, ' ', 20 - file_label_len); por_write_bytes(writer, vanity, sizeof(vanity)); char lookup[256]; int i; memset(lookup, '0', sizeof(lookup)); for (i=0; itimestamp); if (!timestamp) { retval = READSTAT_ERROR_BAD_TIMESTAMP_VALUE; goto cleanup; } if ((retval = por_write_tag(writer, ctx, 'A')) != READSTAT_OK) goto cleanup; char date[9]; snprintf(date, sizeof(date), "%04d%02d%02d", (unsigned int)(timestamp->tm_year + 1900) % 10000, (unsigned int)(timestamp->tm_mon + 1) % 100, (unsigned int)(timestamp->tm_mday) % 100); if ((retval = por_write_string_field(writer, ctx, date)) != READSTAT_OK) goto cleanup; char time[7]; snprintf(time, sizeof(time), "%02d%02d%02d", (unsigned int)timestamp->tm_hour % 100, (unsigned int)timestamp->tm_min % 100, (unsigned int)timestamp->tm_sec % 100); if ((retval = por_write_string_field(writer, ctx, time)) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t por_emit_identification_records(readstat_writer_t *writer, por_write_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; if ((retval = por_write_tag(writer, ctx, '1')) != READSTAT_OK) goto cleanup; if ((retval = por_write_string_field(writer, ctx, READSTAT_PRODUCT_NAME)) != READSTAT_OK) goto cleanup; if ((retval = por_write_tag(writer, ctx, '3')) != READSTAT_OK) goto cleanup; if ((retval = por_write_string_field(writer, ctx, READSTAT_PRODUCT_URL)) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t por_emit_variable_count_record(readstat_writer_t *writer, por_write_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; if ((retval = por_write_tag(writer, ctx, '4')) != READSTAT_OK) goto cleanup; if ((retval = por_write_double(writer, ctx, writer->variables_count)) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t por_emit_precision_record(readstat_writer_t *writer, por_write_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; if ((retval = por_write_tag(writer, ctx, '5')) != READSTAT_OK) goto cleanup; if ((retval = por_write_double(writer, ctx, POR_BASE30_PRECISION)) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t por_emit_case_weight_variable_record(readstat_writer_t *writer, por_write_ctx_t *ctx) { if (!writer->fweight_variable) return READSTAT_OK; readstat_error_t retval = READSTAT_OK; if ((retval = por_write_tag(writer, ctx, '6')) != READSTAT_OK) goto cleanup; if ((retval = por_write_string_field(writer, ctx, readstat_variable_get_name(writer->fweight_variable))) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t por_emit_format(readstat_writer_t *writer, por_write_ctx_t *ctx, spss_format_t *format) { readstat_error_t error = READSTAT_OK; if ((error = por_write_double(writer, ctx, format->type)) != READSTAT_OK) goto cleanup; if ((error = por_write_double(writer, ctx, format->width)) != READSTAT_OK) goto cleanup; if ((error = por_write_double(writer, ctx, format->decimal_places)) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t validate_variable_name(const char *name) { size_t len = strlen(name); if (len < 1 || len > 8) return READSTAT_ERROR_NAME_IS_TOO_LONG; int i; for (i=0; name[i]; i++) { if (name[i] >= 'A' && name[i] <= 'Z') continue; if (name[i] >= '0' && name[i] <= '9') continue; if (name[i] == '@' || name[i] == '#' || name[i] == '$') continue; if (name[i] == '_' || name[i] == '.') continue; return READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER; } if (!(name[0] >= 'A' && name[0] <= 'Z') && name[0] != '@') return READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER; return READSTAT_OK; } static readstat_error_t por_emit_variable_label_record(readstat_writer_t *writer, por_write_ctx_t *ctx, readstat_variable_t *r_variable) { const char *label = readstat_variable_get_label(r_variable); readstat_error_t retval = READSTAT_OK; if (!label) return READSTAT_OK; if ((retval = por_write_tag(writer, ctx, 'C')) != READSTAT_OK) goto cleanup; if ((retval = por_write_string_field(writer, ctx, label)) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t por_emit_missing_string_values_records(readstat_writer_t *writer, por_write_ctx_t *ctx, readstat_variable_t *r_variable) { readstat_error_t retval = READSTAT_OK; int n_missing_values = 0; int n_missing_ranges = readstat_variable_get_missing_ranges_count(r_variable); /* ranges */ int j; for (j=0; j 3) retval = READSTAT_ERROR_TOO_MANY_MISSING_VALUE_DEFINITIONS; cleanup: return retval; } static readstat_error_t por_emit_missing_double_values_records(readstat_writer_t *writer, por_write_ctx_t *ctx, readstat_variable_t *r_variable) { readstat_error_t retval = READSTAT_OK; int n_missing_values = 0; int n_missing_ranges = readstat_variable_get_missing_ranges_count(r_variable); /* ranges */ int j; for (j=0; j 3) retval = READSTAT_ERROR_TOO_MANY_MISSING_VALUE_DEFINITIONS; cleanup: return retval; } static readstat_error_t por_emit_missing_values_records(readstat_writer_t *writer, por_write_ctx_t *ctx, readstat_variable_t *r_variable) { if (r_variable->type == READSTAT_TYPE_DOUBLE) { return por_emit_missing_double_values_records(writer, ctx, r_variable); } return por_emit_missing_string_values_records(writer, ctx, r_variable); } static readstat_error_t por_emit_variable_records(readstat_writer_t *writer, por_write_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int i; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); const char *variable_name = readstat_variable_get_name(r_variable); spss_format_t print_format; if ((retval = por_write_tag(writer, ctx, '7')) != READSTAT_OK) break; retval = por_write_double(writer, ctx, (r_variable->type == READSTAT_TYPE_STRING) ? r_variable->user_width : 0); if (retval != READSTAT_OK) break; if ((retval = por_write_string_field(writer, ctx, variable_name)) != READSTAT_OK) break; if ((retval = spss_format_for_variable(r_variable, &print_format)) != READSTAT_OK) break; if ((retval = por_emit_format(writer, ctx, &print_format)) != READSTAT_OK) break; if ((retval = por_emit_format(writer, ctx, &print_format)) != READSTAT_OK) break; if ((retval = por_emit_missing_values_records(writer, ctx, r_variable)) != READSTAT_OK) break; if ((retval = por_emit_variable_label_record(writer, ctx, r_variable)) != READSTAT_OK) break; } return retval; } static readstat_error_t por_emit_value_label_records(readstat_writer_t *writer, por_write_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int i, j; for (i=0; ilabel_sets_count; i++) { readstat_label_set_t *r_label_set = readstat_get_label_set(writer, i); readstat_type_t user_type = r_label_set->type; if (r_label_set->value_labels_count == 0 || r_label_set->variables_count == 0) continue; if ((retval = por_write_tag(writer, ctx, 'D')) != READSTAT_OK) goto cleanup; if ((retval = por_write_double(writer, ctx, r_label_set->variables_count)) != READSTAT_OK) goto cleanup; for (j=0; jvariables_count; j++) { readstat_variable_t *r_variable = readstat_get_label_set_variable(r_label_set, j); if ((retval = por_write_string_field(writer, ctx, readstat_variable_get_name(r_variable))) != READSTAT_OK) goto cleanup; } if ((retval = por_write_double(writer, ctx, r_label_set->value_labels_count)) != READSTAT_OK) goto cleanup; for (j=0; jvalue_labels_count; j++) { readstat_value_label_t *r_value_label = readstat_get_value_label(r_label_set, j); if (user_type == READSTAT_TYPE_STRING) { retval = por_write_string_field_n(writer, ctx, r_value_label->string_key, r_value_label->string_key_len); } else if (user_type == READSTAT_TYPE_DOUBLE) { retval = por_write_double(writer, ctx, r_value_label->double_key); } else if (user_type == READSTAT_TYPE_INT32) { retval = por_write_double(writer, ctx, r_value_label->int32_key); } if (retval != READSTAT_OK) goto cleanup; if ((retval = por_write_string_field_n(writer, ctx, r_value_label->label, r_value_label->label_len)) != READSTAT_OK) goto cleanup; } } cleanup: return retval; } static readstat_error_t por_emit_document_record(readstat_writer_t *writer, por_write_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; if ((retval = por_write_tag(writer, ctx, 'E')) != READSTAT_OK) goto cleanup; if ((retval = por_write_double(writer, ctx, writer->notes_count)) != READSTAT_OK) goto cleanup; int i; for (i=0; inotes_count; i++) { size_t len = strlen(writer->notes[i]); if (len > SPSS_DOC_LINE_SIZE) { retval = READSTAT_ERROR_NOTE_IS_TOO_LONG; goto cleanup; } if ((retval = por_write_string_field_n(writer, ctx, writer->notes[i], len)) != READSTAT_OK) goto cleanup; } cleanup: return retval; } static readstat_error_t por_emit_data_tag(readstat_writer_t *writer, por_write_ctx_t *ctx) { return por_write_tag(writer, ctx, 'F'); } static readstat_error_t por_begin_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; por_write_ctx_t *ctx = por_write_ctx_init(); readstat_error_t retval = READSTAT_OK; if ((retval = por_emit_header(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_version_and_timestamp(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_identification_records(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_variable_count_record(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_precision_record(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_case_weight_variable_record(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_variable_records(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_value_label_records(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_document_record(writer, ctx)) != READSTAT_OK) goto cleanup; if ((retval = por_emit_data_tag(writer, ctx)) != READSTAT_OK) goto cleanup; cleanup: if (retval != READSTAT_OK) { por_write_ctx_free(ctx); } else { writer->module_ctx = ctx; } return retval; } static readstat_error_t por_end_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; readstat_error_t error = READSTAT_OK; if ((error = por_write_tag(writer, writer->module_ctx, 'Z')) != READSTAT_OK) goto cleanup; if ((error = por_finish(writer)) != READSTAT_OK) goto cleanup; cleanup: por_write_ctx_free(writer->module_ctx); return error; } static size_t por_variable_width(readstat_type_t type, size_t user_width) { if (type == READSTAT_TYPE_STRING) { return POR_BASE30_PRECISION + 4 + user_width; } return POR_BASE30_PRECISION + 4; // minus sign + period + plus/minus + slash } static readstat_error_t por_variable_ok(const readstat_variable_t *variable) { return validate_variable_name(readstat_variable_get_name(variable)); } static readstat_error_t por_write_double_value(void *row, const readstat_variable_t *var, double value) { if (por_write_double_to_buffer(row, POR_BASE30_PRECISION + 4, value, POR_BASE30_PRECISION) == -1) { return READSTAT_ERROR_WRITE; } return READSTAT_OK; } static readstat_error_t por_write_int8_value(void *row, const readstat_variable_t *var, int8_t value) { return por_write_double_value(row, var, value); } static readstat_error_t por_write_int16_value(void *row, const readstat_variable_t *var, int16_t value) { return por_write_double_value(row, var, value); } static readstat_error_t por_write_int32_value(void *row, const readstat_variable_t *var, int32_t value) { return por_write_double_value(row, var, value); } static readstat_error_t por_write_float_value(void *row, const readstat_variable_t *var, float value) { return por_write_double_value(row, var, value); } static readstat_error_t por_write_missing_number(void *row, const readstat_variable_t *var) { return por_write_double_value(row, var, NAN); } static readstat_error_t por_write_missing_string(void *row, const readstat_variable_t *var) { return por_write_double_value(row, var, 0); } static readstat_error_t por_write_string_value(void *row, const readstat_variable_t *var, const char *string) { size_t len = strlen(string); if (len == 0) { string = " "; len = 1; } size_t storage_width = readstat_variable_get_storage_width(var); if (len > storage_width) { len = storage_width; } ssize_t bytes_written = por_write_double_to_buffer(row, POR_BASE30_PRECISION + 4, len, POR_BASE30_PRECISION); if (bytes_written == -1) { return READSTAT_ERROR_WRITE; } strncpy(((char *)row) + bytes_written, string, len); return READSTAT_OK; } static readstat_error_t por_write_row(void *writer_ctx, void *row, size_t row_len) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; char *row_chars = (char *)row; int offset = 0, output = 0; for (offset=0; offsetmodule_ctx, row_chars, output); } static readstat_error_t por_metadata_ok(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; if (writer->compression != READSTAT_COMPRESS_NONE) return READSTAT_ERROR_UNSUPPORTED_COMPRESSION; return READSTAT_OK; } readstat_error_t readstat_begin_writing_por(readstat_writer_t *writer, void *user_ctx, long row_count) { writer->callbacks.metadata_ok = &por_metadata_ok; writer->callbacks.variable_width = &por_variable_width; writer->callbacks.variable_ok = &por_variable_ok; writer->callbacks.write_int8 = &por_write_int8_value; writer->callbacks.write_int16 = &por_write_int16_value; writer->callbacks.write_int32 = &por_write_int32_value; writer->callbacks.write_float = &por_write_float_value; writer->callbacks.write_double = &por_write_double_value; writer->callbacks.write_string = &por_write_string_value; writer->callbacks.write_missing_string = &por_write_missing_string; writer->callbacks.write_missing_number = &por_write_missing_number; writer->callbacks.begin_data = &por_begin_data; writer->callbacks.write_row = &por_write_row; writer->callbacks.end_data = &por_end_data; return readstat_begin_writing_file(writer, user_ctx, row_count); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav.c0000644023477200000240000000507014574360757020232 0ustar00fajardoostaffs// // sav.c // #include #include #include #include #include #include #include #include #include "../readstat.h" #include "../readstat_bits.h" #include "../readstat_iconv.h" #include "../readstat_malloc.h" #include "readstat_sav.h" #define SAV_VARINFO_INITIAL_CAPACITY 512 sav_ctx_t *sav_ctx_init(sav_file_header_record_t *header, readstat_io_t *io) { sav_ctx_t *ctx = readstat_calloc(1, sizeof(sav_ctx_t)); if (ctx == NULL) { return NULL; } if (memcmp(&header->rec_type, "$FL2", 4) == 0) { ctx->format_version = 2; } else if (memcmp(&header->rec_type, "$FL3", 4) == 0) { ctx->format_version = 3; } else { sav_ctx_free(ctx); return NULL; } ctx->bswap = !(header->layout_code == 2 || header->layout_code == 3); ctx->endianness = (machine_is_little_endian() ^ ctx->bswap) ? READSTAT_ENDIAN_LITTLE : READSTAT_ENDIAN_BIG; if (header->compression == 1 || byteswap4(header->compression) == 1) { ctx->compression = READSTAT_COMPRESS_ROWS; } else if (header->compression == 2 || byteswap4(header->compression) == 2) { ctx->compression = READSTAT_COMPRESS_BINARY; } ctx->record_count = ctx->bswap ? byteswap4(header->ncases) : header->ncases; ctx->fweight_index = ctx->bswap ? byteswap4(header->weight_index) : header->weight_index; ctx->missing_double = SAV_MISSING_DOUBLE; ctx->lowest_double = SAV_LOWEST_DOUBLE; ctx->highest_double = SAV_HIGHEST_DOUBLE; ctx->bias = ctx->bswap ? byteswap_double(header->bias) : header->bias; ctx->varinfo_capacity = SAV_VARINFO_INITIAL_CAPACITY; if ((ctx->varinfo = readstat_calloc(ctx->varinfo_capacity, sizeof(spss_varinfo_t *))) == NULL) { sav_ctx_free(ctx); return NULL; } ctx->io = io; return ctx; } void sav_ctx_free(sav_ctx_t *ctx) { if (ctx->varinfo) { int i; for (i=0; ivar_index; i++) { spss_varinfo_free(ctx->varinfo[i]); } free(ctx->varinfo); } if (ctx->variables) { int i; for (i=0; ivar_count; i++) { if (ctx->variables[i]) free(ctx->variables[i]); } free(ctx->variables); } if (ctx->raw_string) free(ctx->raw_string); if (ctx->utf8_string) free(ctx->utf8_string); if (ctx->converter) iconv_close(ctx->converter); if (ctx->variable_display_values) { free(ctx->variable_display_values); } free(ctx); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav.h0000644023477200000240000000771214574360757020244 0ustar00fajardoostaffs// // readstat_sav.h // #include "readstat_spss.h" #pragma pack(push, 1) // SAV files typedef struct sav_file_header_record_s { char rec_type[4]; char prod_name[60]; int32_t layout_code; int32_t nominal_case_size; int32_t compression; int32_t weight_index; int32_t ncases; double bias; /* TODO is this portable? */ char creation_date[9]; char creation_time[8]; char file_label[64]; char padding[3]; } sav_file_header_record_t; typedef struct sav_variable_record_s { int32_t type; int32_t has_var_label; int32_t n_missing_values; int32_t print; int32_t write; char name[8]; } sav_variable_record_t; typedef struct sav_info_record_header_s { int32_t rec_type; int32_t subtype; int32_t size; int32_t count; } sav_info_record_t; typedef struct sav_machine_integer_info_record_s { int32_t version_major; int32_t version_minor; int32_t version_revision; int32_t machine_code; int32_t floating_point_rep; int32_t compression_code; int32_t endianness; int32_t character_code; } sav_machine_integer_info_record_t; typedef struct sav_machine_floating_point_info_record_s { uint64_t sysmis; uint64_t highest; uint64_t lowest; } sav_machine_floating_point_info_record_t; typedef struct sav_dictionary_termination_record_s { int32_t rec_type; int32_t filler; } sav_dictionary_termination_record_t; #pragma pack(pop) typedef struct sav_ctx_s { readstat_callbacks_t handle; size_t file_size; readstat_io_t *io; void *user_ctx; spss_varinfo_t **varinfo; size_t varinfo_capacity; readstat_variable_t **variables; const char *input_encoding; const char *output_encoding; char file_label[4*64+1]; time_t timestamp; uint32_t *variable_display_values; size_t variable_display_values_count; iconv_t converter; int var_index; int var_offset; int var_count; int record_count; int row_limit; int row_offset; int current_row; int value_labels_count; int fweight_index; char *raw_string; size_t raw_string_len; char *utf8_string; size_t utf8_string_len; uint64_t missing_double; uint64_t lowest_double; uint64_t highest_double; double bias; int format_version; readstat_compress_t compression; readstat_endian_t endianness; unsigned int bswap:1; } sav_ctx_t; #define SAV_RECORD_TYPE_VARIABLE 2 #define SAV_RECORD_TYPE_VALUE_LABEL 3 #define SAV_RECORD_TYPE_VALUE_LABEL_VARIABLES 4 #define SAV_RECORD_TYPE_DOCUMENT 6 #define SAV_RECORD_TYPE_HAS_DATA 7 #define SAV_RECORD_TYPE_DICT_TERMINATION 999 #define SAV_RECORD_SUBTYPE_INTEGER_INFO 3 #define SAV_RECORD_SUBTYPE_FP_INFO 4 #define SAV_RECORD_SUBTYPE_PRODUCT_INFO 10 #define SAV_RECORD_SUBTYPE_VAR_DISPLAY 11 #define SAV_RECORD_SUBTYPE_LONG_VAR_NAME 13 #define SAV_RECORD_SUBTYPE_VERY_LONG_STR 14 #define SAV_RECORD_SUBTYPE_NUMBER_OF_CASES 16 #define SAV_RECORD_SUBTYPE_DATA_FILE_ATTRS 17 #define SAV_RECORD_SUBTYPE_VARIABLE_ATTRS 18 #define SAV_RECORD_SUBTYPE_CHAR_ENCODING 20 #define SAV_RECORD_SUBTYPE_LONG_STRING_VALUE_LABELS 21 #define SAV_RECORD_SUBTYPE_LONG_STRING_MISSING_VALUES 22 #define SAV_FLOATING_POINT_REP_IEEE 1 #define SAV_FLOATING_POINT_REP_IBM 2 #define SAV_FLOATING_POINT_REP_VAX 3 #define SAV_ENDIANNESS_BIG 1 #define SAV_ENDIANNESS_LITTLE 2 #define SAV_EIGHT_SPACES " " sav_ctx_t *sav_ctx_init(sav_file_header_record_t *header, readstat_io_t *io); void sav_ctx_free(sav_ctx_t *ctx); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav_compress.c0000644023477200000240000001132314574360757022143 0ustar00fajardoostaffs#include #include #include "../readstat.h" #include "../readstat_bits.h" #include "../readstat_iconv.h" #include "readstat_sav.h" #include "readstat_sav_compress.h" size_t sav_compressed_row_bound(size_t uncompressed_length) { return uncompressed_length + (uncompressed_length/8 + 8)/8*8; } size_t sav_compress_row(void *output_row, void *input_row, size_t input_len, readstat_writer_t *writer) { unsigned char *output = output_row; unsigned char *input = input_row; off_t input_offset = 0; off_t output_offset = 8; off_t control_offset = 0; int i; memset(&output[control_offset], 0, 8); for (i=0; ivariables_count; i++) { readstat_variable_t *variable = readstat_get_variable(writer, i); if (variable->type == READSTAT_TYPE_STRING) { size_t width = variable->storage_width; while (width > 0) { if (memcmp(&input[input_offset], SAV_EIGHT_SPACES, 8) == 0) { output[control_offset++] = 254; } else { output[control_offset++] = 253; memcpy(&output[output_offset], &input[input_offset], 8); output_offset += 8; } if (control_offset % 8 == 0) { control_offset = output_offset; memset(&output[control_offset], 0, 8); output_offset += 8; } input_offset += 8; width -= 8; } } else { uint64_t int_value; memcpy(&int_value, &input[input_offset], 8); if (int_value == SAV_MISSING_DOUBLE) { output[control_offset++] = 255; } else { double fp_value; memcpy(&fp_value, &input[input_offset], 8); if (fp_value > -100 && fp_value < 152 && (int)fp_value == fp_value) { output[control_offset++] = (int)fp_value + 100; } else { output[control_offset++] = 253; memcpy(&output[output_offset], &input[input_offset], 8); output_offset += 8; } } if (control_offset % 8 == 0) { control_offset = output_offset; memset(&output[control_offset], 0, 8); output_offset += 8; } input_offset += 8; } } if (writer->current_row + 1 == writer->row_count) output[control_offset] = 252; return output_offset; } void sav_decompress_row(struct sav_row_stream_s *state) { double fp_value; uint64_t missing_value = state->bswap ? byteswap8(state->missing_value) : state->missing_value; int i = 8 - state->i; while (1) { if (i == 8) { if (state->avail_in < 8) { state->status = SAV_ROW_STREAM_NEED_DATA; goto done; } memcpy(state->chunk, state->next_in, 8); state->next_in += 8; state->avail_in -= 8; i = 0; } while (i<8) { switch (state->chunk[i]) { case 0: break; case 252: state->status = SAV_ROW_STREAM_FINISHED_ALL; goto done; case 253: if (state->avail_in < 8) { state->status = SAV_ROW_STREAM_NEED_DATA; goto done; } memcpy(state->next_out, state->next_in, 8); state->next_out += 8; state->avail_out -= 8; state->next_in += 8; state->avail_in -= 8; break; case 254: memset(state->next_out, ' ', 8); state->next_out += 8; state->avail_out -= 8; break; case 255: memcpy(state->next_out, &missing_value, sizeof(uint64_t)); state->next_out += 8; state->avail_out -= 8; break; default: fp_value = state->chunk[i] - state->bias; fp_value = state->bswap ? byteswap_double(fp_value) : fp_value; memcpy(state->next_out, &fp_value, sizeof(double)); state->next_out += 8; state->avail_out -= 8; break; } i++; if (state->avail_out < 8) { state->status = SAV_ROW_STREAM_FINISHED_ROW; goto done; } } } done: state->i = 8 - i; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav_compress.h0000644023477200000240000000141014574360757022144 0ustar00fajardoostaffsenum sav_row_stream_status { SAV_ROW_STREAM_NEED_DATA, SAV_ROW_STREAM_HAVE_DATA, SAV_ROW_STREAM_FINISHED_ROW, SAV_ROW_STREAM_FINISHED_ALL }; struct sav_row_stream_s { const unsigned char *next_in; size_t avail_in; unsigned char *next_out; size_t avail_out; uint64_t missing_value; double bias; unsigned char chunk[8]; int i; int bswap; enum sav_row_stream_status status; }; size_t sav_compressed_row_bound(size_t uncompressed_length); size_t sav_compress_row(void *output_row, void *input_row, size_t input_len, readstat_writer_t *writer); void sav_decompress_row(struct sav_row_stream_s *state); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav_parse.c0000644023477200000240000005417614574360757021437 0ustar00fajardoostaffs#line 1 "src/spss/readstat_sav_parse.rl" #include #include #include "../readstat.h" #include "../readstat_malloc.h" #include "../readstat_strings.h" #include "readstat_sav.h" #include "readstat_sav_parse.h" #line 21 "src/spss/readstat_sav_parse.rl" typedef struct varlookup { char name[8*4+1]; int index; } varlookup_t; static int compare_key_varlookup(const void *elem1, const void *elem2) { const char *key = (const char *)elem1; const varlookup_t *v = (const varlookup_t *)elem2; return strcasecmp(key, v->name); } static int compare_varlookups(const void *elem1, const void *elem2) { const varlookup_t *v1 = (const varlookup_t *)elem1; const varlookup_t *v2 = (const varlookup_t *)elem2; return strcasecmp(v1->name, v2->name); } static int count_vars(sav_ctx_t *ctx) { int i; spss_varinfo_t *last_info = NULL; int var_count = 0; for (i=0; ivar_index; i++) { spss_varinfo_t *info = ctx->varinfo[i]; if (last_info == NULL || strcmp(info->name, last_info->name) != 0) { var_count++; } last_info = info; } return var_count; } static varlookup_t *build_lookup_table(int var_count, sav_ctx_t *ctx) { varlookup_t *table = readstat_malloc(var_count * sizeof(varlookup_t)); int offset = 0; int i; spss_varinfo_t *last_info = NULL; for (i=0; ivar_index; i++) { spss_varinfo_t *info = ctx->varinfo[i]; if (last_info == NULL || strcmp(info->name, last_info->name) != 0) { varlookup_t *entry = &table[offset++]; memcpy(entry->name, info->name, sizeof(info->name)); entry->index = info->index; } last_info = info; } qsort(table, var_count, sizeof(varlookup_t), &compare_varlookups); return table; } #line 68 "src/spss/readstat_sav_parse.c" static const signed char _sav_long_variable_parse_actions[] = { 0, 1, 1, 1, 5, 2, 2, 0, 3, 6, 4, 3, 0 }; static const short _sav_long_variable_parse_key_offsets[] = { 0, 0, 5, 19, 33, 47, 61, 75, 89, 103, 104, 108, 113, 118, 123, 128, 133, 138, 143, 148, 153, 158, 163, 168, 173, 178, 183, 188, 193, 198, 203, 208, 213, 218, 223, 228, 233, 238, 243, 248, 253, 258, 263, 268, 273, 278, 283, 288, 293, 298, 303, 308, 313, 318, 323, 328, 333, 338, 343, 348, 353, 358, 363, 368, 373, 378, 383, 388, 393, 398, 403, 408, 413, 418, 423, 428, 0 }; static const unsigned char _sav_long_variable_parse_trans_keys[] = { 255u, 0u, 63u, 91u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 61u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 255u, 0u, 63u, 91u, 127u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 127u, 255u, 0u, 31u, 9u, 0u }; static const signed char _sav_long_variable_parse_single_lengths[] = { 0, 1, 4, 4, 4, 4, 4, 4, 4, 1, 2, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 0 }; static const signed char _sav_long_variable_parse_range_lengths[] = { 0, 2, 5, 5, 5, 5, 5, 5, 5, 0, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }; static const short _sav_long_variable_parse_index_offsets[] = { 0, 0, 4, 14, 24, 34, 44, 54, 64, 74, 76, 80, 85, 89, 94, 99, 104, 109, 114, 119, 124, 129, 134, 139, 144, 149, 154, 159, 164, 169, 174, 179, 184, 189, 194, 199, 204, 209, 214, 219, 224, 229, 234, 239, 244, 249, 254, 259, 264, 269, 274, 279, 284, 289, 294, 299, 304, 309, 314, 319, 324, 329, 334, 339, 344, 349, 354, 359, 364, 369, 374, 379, 384, 389, 394, 399, 0 }; static const signed char _sav_long_variable_parse_cond_targs[] = { 0, 0, 0, 2, 0, 10, 0, 0, 0, 0, 0, 0, 0, 3, 0, 10, 0, 0, 0, 0, 0, 0, 0, 4, 0, 10, 0, 0, 0, 0, 0, 0, 0, 5, 0, 10, 0, 0, 0, 0, 0, 0, 0, 6, 0, 10, 0, 0, 0, 0, 0, 0, 0, 7, 0, 10, 0, 0, 0, 0, 0, 0, 0, 8, 0, 10, 0, 0, 0, 0, 0, 0, 0, 9, 10, 0, 0, 0, 0, 11, 12, 0, 0, 0, 13, 0, 0, 0, 2, 12, 0, 0, 0, 14, 12, 0, 0, 0, 15, 12, 0, 0, 0, 16, 12, 0, 0, 0, 17, 12, 0, 0, 0, 18, 12, 0, 0, 0, 19, 12, 0, 0, 0, 20, 12, 0, 0, 0, 21, 12, 0, 0, 0, 22, 12, 0, 0, 0, 23, 12, 0, 0, 0, 24, 12, 0, 0, 0, 25, 12, 0, 0, 0, 26, 12, 0, 0, 0, 27, 12, 0, 0, 0, 28, 12, 0, 0, 0, 29, 12, 0, 0, 0, 30, 12, 0, 0, 0, 31, 12, 0, 0, 0, 32, 12, 0, 0, 0, 33, 12, 0, 0, 0, 34, 12, 0, 0, 0, 35, 12, 0, 0, 0, 36, 12, 0, 0, 0, 37, 12, 0, 0, 0, 38, 12, 0, 0, 0, 39, 12, 0, 0, 0, 40, 12, 0, 0, 0, 41, 12, 0, 0, 0, 42, 12, 0, 0, 0, 43, 12, 0, 0, 0, 44, 12, 0, 0, 0, 45, 12, 0, 0, 0, 46, 12, 0, 0, 0, 47, 12, 0, 0, 0, 48, 12, 0, 0, 0, 49, 12, 0, 0, 0, 50, 12, 0, 0, 0, 51, 12, 0, 0, 0, 52, 12, 0, 0, 0, 53, 12, 0, 0, 0, 54, 12, 0, 0, 0, 55, 12, 0, 0, 0, 56, 12, 0, 0, 0, 57, 12, 0, 0, 0, 58, 12, 0, 0, 0, 59, 12, 0, 0, 0, 60, 12, 0, 0, 0, 61, 12, 0, 0, 0, 62, 12, 0, 0, 0, 63, 12, 0, 0, 0, 64, 12, 0, 0, 0, 65, 12, 0, 0, 0, 66, 12, 0, 0, 0, 67, 12, 0, 0, 0, 68, 12, 0, 0, 0, 69, 12, 0, 0, 0, 70, 12, 0, 0, 0, 71, 12, 0, 0, 0, 72, 12, 0, 0, 0, 73, 12, 0, 0, 0, 74, 12, 0, 0, 0, 75, 12, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 0 }; static const signed char _sav_long_variable_parse_cond_actions[] = { 0, 0, 0, 1, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 3, 8, 0, 0, 0, 0, 0, 0, 0, 1, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0 }; static const short _sav_long_variable_parse_eof_trans[] = { 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 0 }; static const int sav_long_variable_parse_start = 1; static const int sav_long_variable_parse_en_main = 1; #line 79 "src/spss/readstat_sav_parse.rl" readstat_error_t sav_parse_long_variable_names_record(void *data, int count, sav_ctx_t *ctx) { unsigned char *c_data = (unsigned char *)data; int var_count = count_vars(ctx); readstat_error_t retval = READSTAT_OK; char temp_key[8+1]; char temp_val[64+1]; unsigned char *str_start = NULL; size_t str_len = 0; char error_buf[8192]; unsigned char *p = c_data; unsigned char *pe = c_data + count; varlookup_t *table = build_lookup_table(var_count, ctx); unsigned char *eof = pe; int cs; #line 351 "src/spss/readstat_sav_parse.c" { cs = (int)sav_long_variable_parse_start; } #line 356 "src/spss/readstat_sav_parse.c" { int _klen; unsigned int _trans = 0; const unsigned char * _keys; const signed char * _acts; unsigned int _nacts; _resume: {} if ( p == pe && p != eof ) goto _out; if ( p == eof ) { if ( _sav_long_variable_parse_eof_trans[cs] > 0 ) { _trans = (unsigned int)_sav_long_variable_parse_eof_trans[cs] - 1; } } else { _keys = ( _sav_long_variable_parse_trans_keys + (_sav_long_variable_parse_key_offsets[cs])); _trans = (unsigned int)_sav_long_variable_parse_index_offsets[cs]; _klen = (int)_sav_long_variable_parse_single_lengths[cs]; if ( _klen > 0 ) { const unsigned char *_lower = _keys; const unsigned char *_upper = _keys + _klen - 1; const unsigned char *_mid; while ( 1 ) { if ( _upper < _lower ) { _keys += _klen; _trans += (unsigned int)_klen; break; } _mid = _lower + ((_upper-_lower) >> 1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 1; else if ( ( (*( p))) > (*( _mid)) ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } } _klen = (int)_sav_long_variable_parse_range_lengths[cs]; if ( _klen > 0 ) { const unsigned char *_lower = _keys; const unsigned char *_upper = _keys + (_klen<<1) - 2; const unsigned char *_mid; while ( 1 ) { if ( _upper < _lower ) { _trans += (unsigned int)_klen; break; } _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 2; else if ( ( (*( p))) > (*( _mid + 1)) ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); break; } } } _match: {} } cs = (int)_sav_long_variable_parse_cond_targs[_trans]; if ( _sav_long_variable_parse_cond_actions[_trans] != 0 ) { _acts = ( _sav_long_variable_parse_actions + (_sav_long_variable_parse_cond_actions[_trans])); _nacts = (unsigned int)(*( _acts)); _acts += 1; while ( _nacts > 0 ) { switch ( (*( _acts)) ) { case 0: { { #line 13 "src/spss/readstat_sav_parse.rl" memcpy(temp_key, str_start, str_len); temp_key[str_len] = '\0'; } #line 442 "src/spss/readstat_sav_parse.c" break; } case 1: { { #line 20 "src/spss/readstat_sav_parse.rl" str_start = p; } #line 451 "src/spss/readstat_sav_parse.c" break; } case 2: { { #line 20 "src/spss/readstat_sav_parse.rl" str_len = p - str_start; } #line 460 "src/spss/readstat_sav_parse.c" break; } case 3: { { #line 102 "src/spss/readstat_sav_parse.rl" varlookup_t *found = bsearch(temp_key, table, var_count, sizeof(varlookup_t), &compare_key_varlookup); if (found) { spss_varinfo_t *info = ctx->varinfo[found->index]; memcpy(info->longname, temp_val, str_len); info->longname[str_len] = '\0'; } else if (ctx->handle.error) { snprintf(error_buf, sizeof(error_buf), "Failed to find %s", temp_key); ctx->handle.error(error_buf, ctx->user_ctx); } } #line 479 "src/spss/readstat_sav_parse.c" break; } case 4: { { #line 114 "src/spss/readstat_sav_parse.rl" memcpy(temp_val, str_start, str_len); temp_val[str_len] = '\0'; } #line 491 "src/spss/readstat_sav_parse.c" break; } case 5: { { #line 119 "src/spss/readstat_sav_parse.rl" str_start = p; } #line 500 "src/spss/readstat_sav_parse.c" break; } case 6: { { #line 119 "src/spss/readstat_sav_parse.rl" str_len = p - str_start; } #line 509 "src/spss/readstat_sav_parse.c" break; } } _nacts -= 1; _acts += 1; } } if ( p == eof ) { if ( cs >= 11 ) goto _out; } else { if ( cs != 0 ) { p += 1; goto _resume; } } _out: {} } #line 127 "src/spss/readstat_sav_parse.rl" if (cs < #line 537 "src/spss/readstat_sav_parse.c" 11 #line 129 "src/spss/readstat_sav_parse.rl" || p != pe) { if (ctx->handle.error) { snprintf(error_buf, sizeof(error_buf), "Error parsing string \"%.*s\" around byte #%ld/%d, character %c", count, (char *)data, (long)(p - c_data), count, *p); ctx->handle.error(error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_PARSE; } if (table) free(table); /* suppress warning */ (void)sav_long_variable_parse_en_main; return retval; } #line 560 "src/spss/readstat_sav_parse.c" static const signed char _sav_very_long_string_parse_actions[] = { 0, 1, 1, 1, 3, 1, 4, 2, 2, 0, 2, 5, 4, 0 }; static const signed char _sav_very_long_string_parse_key_offsets[] = { 0, 0, 5, 19, 33, 47, 61, 75, 89, 103, 104, 106, 110, 112, 0 }; static const unsigned char _sav_very_long_string_parse_trans_keys[] = { 255u, 0u, 63u, 91u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 47u, 61u, 96u, 255u, 0u, 34u, 37u, 45u, 58u, 63u, 91u, 94u, 123u, 127u, 61u, 48u, 57u, 0u, 9u, 48u, 57u, 0u, 9u, 255u, 0u, 63u, 91u, 127u, 0u }; static const signed char _sav_very_long_string_parse_single_lengths[] = { 0, 1, 4, 4, 4, 4, 4, 4, 4, 1, 0, 2, 2, 1, 0 }; static const signed char _sav_very_long_string_parse_range_lengths[] = { 0, 2, 5, 5, 5, 5, 5, 5, 5, 0, 1, 1, 0, 2, 0 }; static const signed char _sav_very_long_string_parse_index_offsets[] = { 0, 0, 4, 14, 24, 34, 44, 54, 64, 74, 76, 78, 82, 85, 0 }; static const signed char _sav_very_long_string_parse_cond_targs[] = { 0, 0, 0, 2, 0, 10, 0, 0, 0, 0, 0, 0, 0, 3, 0, 10, 0, 0, 0, 0, 0, 0, 0, 4, 0, 10, 0, 0, 0, 0, 0, 0, 0, 5, 0, 10, 0, 0, 0, 0, 0, 0, 0, 6, 0, 10, 0, 0, 0, 0, 0, 0, 0, 7, 0, 10, 0, 0, 0, 0, 0, 0, 0, 8, 0, 10, 0, 0, 0, 0, 0, 0, 0, 9, 10, 0, 11, 0, 12, 13, 11, 0, 12, 13, 0, 0, 0, 0, 2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0 }; static const signed char _sav_very_long_string_parse_cond_actions[] = { 0, 0, 0, 1, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 10, 0, 3, 3, 5, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0 }; static const signed char _sav_very_long_string_parse_eof_trans[] = { 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 0 }; static const int sav_very_long_string_parse_start = 1; static const int sav_very_long_string_parse_en_main = 1; #line 153 "src/spss/readstat_sav_parse.rl" readstat_error_t sav_parse_very_long_string_record(void *data, int count, sav_ctx_t *ctx) { unsigned char *c_data = (unsigned char *)data; int var_count = count_vars(ctx); readstat_error_t retval = READSTAT_OK; char temp_key[8*4+1]; unsigned int temp_val = 0; unsigned char *str_start = NULL; size_t str_len = 0; size_t error_buf_len = 1024 + count; char *error_buf = NULL; unsigned char *p = c_data; unsigned char *pe = c_data + count; unsigned char *eof = pe; varlookup_t *table = NULL; int cs; error_buf = readstat_malloc(error_buf_len); table = build_lookup_table(var_count, ctx); #line 672 "src/spss/readstat_sav_parse.c" { cs = (int)sav_very_long_string_parse_start; } #line 677 "src/spss/readstat_sav_parse.c" { int _klen; unsigned int _trans = 0; const unsigned char * _keys; const signed char * _acts; unsigned int _nacts; _resume: {} if ( p == pe && p != eof ) goto _out; if ( p == eof ) { if ( _sav_very_long_string_parse_eof_trans[cs] > 0 ) { _trans = (unsigned int)_sav_very_long_string_parse_eof_trans[cs] - 1; } } else { _keys = ( _sav_very_long_string_parse_trans_keys + (_sav_very_long_string_parse_key_offsets[cs])); _trans = (unsigned int)_sav_very_long_string_parse_index_offsets[cs]; _klen = (int)_sav_very_long_string_parse_single_lengths[cs]; if ( _klen > 0 ) { const unsigned char *_lower = _keys; const unsigned char *_upper = _keys + _klen - 1; const unsigned char *_mid; while ( 1 ) { if ( _upper < _lower ) { _keys += _klen; _trans += (unsigned int)_klen; break; } _mid = _lower + ((_upper-_lower) >> 1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 1; else if ( ( (*( p))) > (*( _mid)) ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } } _klen = (int)_sav_very_long_string_parse_range_lengths[cs]; if ( _klen > 0 ) { const unsigned char *_lower = _keys; const unsigned char *_upper = _keys + (_klen<<1) - 2; const unsigned char *_mid; while ( 1 ) { if ( _upper < _lower ) { _trans += (unsigned int)_klen; break; } _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 2; else if ( ( (*( p))) > (*( _mid + 1)) ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); break; } } } _match: {} } cs = (int)_sav_very_long_string_parse_cond_targs[_trans]; if ( _sav_very_long_string_parse_cond_actions[_trans] != 0 ) { _acts = ( _sav_very_long_string_parse_actions + (_sav_very_long_string_parse_cond_actions[_trans])); _nacts = (unsigned int)(*( _acts)); _acts += 1; while ( _nacts > 0 ) { switch ( (*( _acts)) ) { case 0: { { #line 13 "src/spss/readstat_sav_parse.rl" memcpy(temp_key, str_start, str_len); temp_key[str_len] = '\0'; } #line 763 "src/spss/readstat_sav_parse.c" break; } case 1: { { #line 20 "src/spss/readstat_sav_parse.rl" str_start = p; } #line 772 "src/spss/readstat_sav_parse.c" break; } case 2: { { #line 20 "src/spss/readstat_sav_parse.rl" str_len = p - str_start; } #line 781 "src/spss/readstat_sav_parse.c" break; } case 3: { { #line 178 "src/spss/readstat_sav_parse.rl" varlookup_t *found = bsearch(temp_key, table, var_count, sizeof(varlookup_t), &compare_key_varlookup); if (found) { ctx->varinfo[found->index]->string_length = temp_val; ctx->varinfo[found->index]->write_format.width = temp_val; ctx->varinfo[found->index]->print_format.width = temp_val; } } #line 797 "src/spss/readstat_sav_parse.c" break; } case 4: { { #line 187 "src/spss/readstat_sav_parse.rl" if ((( (*( p)))) != '\0') { unsigned char digit = (( (*( p)))) - '0'; if (temp_val <= (UINT_MAX - digit) / 10) { temp_val = 10 * temp_val + digit; } else { {p += 1; goto _out; } } } } #line 815 "src/spss/readstat_sav_parse.c" break; } case 5: { { #line 198 "src/spss/readstat_sav_parse.rl" temp_val = 0; } #line 824 "src/spss/readstat_sav_parse.c" break; } } _nacts -= 1; _acts += 1; } } if ( p == eof ) { if ( cs >= 11 ) goto _out; } else { if ( cs != 0 ) { p += 1; goto _resume; } } _out: {} } #line 206 "src/spss/readstat_sav_parse.rl" if (cs < #line 852 "src/spss/readstat_sav_parse.c" 11 #line 208 "src/spss/readstat_sav_parse.rl" || p != pe) { if (ctx->handle.error) { snprintf(error_buf, error_buf_len, "Parsed %ld of %ld bytes. Remaining bytes: %.*s", (long)(p - c_data), (long)(pe - c_data), (int)(pe - p), p); ctx->handle.error(error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_PARSE; } if (table) free(table); if (error_buf) free(error_buf); /* suppress warning */ (void)sav_very_long_string_parse_en_main; return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav_parse.h0000644023477200000240000000032114574360757021423 0ustar00fajardoostaffs// // sav_parse.h // readstat_error_t sav_parse_long_variable_names_record(void *data, int count, sav_ctx_t *ctx); readstat_error_t sav_parse_very_long_string_record(void *data, int count, sav_ctx_t *ctx); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav_parse_timestamp.c0000644023477200000240000003655514574360757023523 0ustar00fajardoostaffs#line 1 "src/spss/readstat_sav_parse_timestamp.rl" #include #include "../readstat.h" #include "../readstat_iconv.h" #include "readstat_sav.h" #include "readstat_sav_parse_timestamp.h" #line 12 "src/spss/readstat_sav_parse_timestamp.c" static const signed char _sav_time_parse_actions[] = { 0, 1, 0, 1, 2, 1, 3, 1, 4, 1, 5, 2, 1, 0, 0 }; static const signed char _sav_time_parse_key_offsets[] = { 0, 0, 3, 5, 6, 9, 11, 12, 15, 17, 19, 21, 23, 0 }; static const char _sav_time_parse_trans_keys[] = { 32, 48, 57, 48, 57, 58, 32, 48, 57, 48, 57, 58, 32, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 0 }; static const signed char _sav_time_parse_single_lengths[] = { 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0 }; static const signed char _sav_time_parse_range_lengths[] = { 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0 }; static const signed char _sav_time_parse_index_offsets[] = { 0, 0, 3, 5, 7, 10, 12, 14, 17, 19, 21, 23, 25, 0 }; static const signed char _sav_time_parse_cond_targs[] = { 2, 11, 0, 3, 0, 4, 0, 5, 10, 0, 6, 0, 7, 0, 8, 9, 0, 12, 0, 12, 0, 6, 0, 3, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0 }; static const signed char _sav_time_parse_cond_actions[] = { 0, 3, 0, 11, 0, 5, 0, 0, 3, 0, 11, 0, 7, 0, 0, 3, 0, 11, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0 }; static const signed char _sav_time_parse_eof_trans[] = { 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0 }; static const int sav_time_parse_start = 1; static const int sav_time_parse_en_main = 1; #line 12 "src/spss/readstat_sav_parse_timestamp.rl" readstat_error_t sav_parse_time(const char *data, size_t len, struct tm *timestamp, readstat_error_handler error_cb, void *user_ctx) { readstat_error_t retval = READSTAT_OK; char error_buf[8192]; const char *p = data; const char *pe = p + len; const char *eof = pe; int cs; int temp_val = 0; #line 83 "src/spss/readstat_sav_parse_timestamp.c" { cs = (int)sav_time_parse_start; } #line 88 "src/spss/readstat_sav_parse_timestamp.c" { int _klen; unsigned int _trans = 0; const char * _keys; const signed char * _acts; unsigned int _nacts; _resume: {} if ( p == pe && p != eof ) goto _out; if ( p == eof ) { if ( _sav_time_parse_eof_trans[cs] > 0 ) { _trans = (unsigned int)_sav_time_parse_eof_trans[cs] - 1; } } else { _keys = ( _sav_time_parse_trans_keys + (_sav_time_parse_key_offsets[cs])); _trans = (unsigned int)_sav_time_parse_index_offsets[cs]; _klen = (int)_sav_time_parse_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + _klen - 1; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _keys += _klen; _trans += (unsigned int)_klen; break; } _mid = _lower + ((_upper-_lower) >> 1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 1; else if ( ( (*( p))) > (*( _mid)) ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } } _klen = (int)_sav_time_parse_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + (_klen<<1) - 2; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _trans += (unsigned int)_klen; break; } _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 2; else if ( ( (*( p))) > (*( _mid + 1)) ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); break; } } } _match: {} } cs = (int)_sav_time_parse_cond_targs[_trans]; if ( _sav_time_parse_cond_actions[_trans] != 0 ) { _acts = ( _sav_time_parse_actions + (_sav_time_parse_cond_actions[_trans])); _nacts = (unsigned int)(*( _acts)); _acts += 1; while ( _nacts > 0 ) { switch ( (*( _acts)) ) { case 0: { { #line 24 "src/spss/readstat_sav_parse_timestamp.rl" temp_val = 10 * temp_val + ((( (*( p)))) - '0'); } #line 173 "src/spss/readstat_sav_parse_timestamp.c" break; } case 1: { { #line 28 "src/spss/readstat_sav_parse_timestamp.rl" temp_val = 0; } #line 182 "src/spss/readstat_sav_parse_timestamp.c" break; } case 2: { { #line 28 "src/spss/readstat_sav_parse_timestamp.rl" temp_val = (( (*( p)))) - '0'; } #line 191 "src/spss/readstat_sav_parse_timestamp.c" break; } case 3: { { #line 30 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_hour = temp_val; } #line 200 "src/spss/readstat_sav_parse_timestamp.c" break; } case 4: { { #line 32 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_min = temp_val; } #line 209 "src/spss/readstat_sav_parse_timestamp.c" break; } case 5: { { #line 34 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_sec = temp_val; } #line 218 "src/spss/readstat_sav_parse_timestamp.c" break; } } _nacts -= 1; _acts += 1; } } if ( p == eof ) { if ( cs >= 12 ) goto _out; } else { if ( cs != 0 ) { p += 1; goto _resume; } } _out: {} } #line 40 "src/spss/readstat_sav_parse_timestamp.rl" if (cs < #line 246 "src/spss/readstat_sav_parse_timestamp.c" 12 #line 42 "src/spss/readstat_sav_parse_timestamp.rl" || p != pe) { if (error_cb) { snprintf(error_buf, sizeof(error_buf), "Invalid time string (length=%d): %.*s", (int)len, (int)len, data); error_cb(error_buf, user_ctx); } retval = READSTAT_ERROR_BAD_TIMESTAMP_STRING; } (void)sav_time_parse_en_main; return retval; } #line 264 "src/spss/readstat_sav_parse_timestamp.c" static const signed char _sav_date_parse_actions[] = { 0, 1, 0, 1, 1, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 2, 2, 0, 0 }; static const signed char _sav_date_parse_key_offsets[] = { 0, 0, 3, 6, 8, 16, 20, 21, 23, 26, 29, 30, 32, 33, 34, 36, 37, 39, 40, 42, 43, 45, 46, 50, 51, 53, 55, 57, 59, 60, 62, 64, 66, 68, 70, 72, 74, 75, 77, 78, 80, 81, 83, 84, 86, 87, 89, 90, 0 }; static const char _sav_date_parse_trans_keys[] = { 32, 48, 57, 32, 48, 57, 32, 45, 65, 68, 70, 74, 77, 78, 79, 83, 80, 85, 112, 117, 82, 32, 45, 32, 48, 57, 32, 48, 57, 71, 32, 45, 114, 103, 69, 101, 67, 32, 45, 99, 69, 101, 66, 32, 45, 98, 65, 85, 97, 117, 78, 32, 45, 76, 78, 32, 45, 32, 45, 110, 108, 110, 65, 97, 82, 89, 32, 45, 32, 45, 114, 121, 79, 111, 86, 32, 45, 118, 67, 99, 84, 32, 45, 116, 69, 101, 80, 32, 45, 112, 0 }; static const signed char _sav_date_parse_single_lengths[] = { 0, 1, 1, 2, 8, 4, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 4, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0, 0 }; static const signed char _sav_date_parse_range_lengths[] = { 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; static const short _sav_date_parse_index_offsets[] = { 0, 0, 3, 6, 9, 18, 23, 25, 28, 31, 34, 36, 39, 41, 43, 46, 48, 51, 53, 56, 58, 61, 63, 68, 70, 73, 76, 79, 82, 84, 87, 90, 93, 96, 99, 102, 105, 107, 110, 112, 115, 117, 120, 122, 125, 127, 130, 132, 0 }; static const signed char _sav_date_parse_cond_targs[] = { 2, 2, 0, 3, 3, 0, 4, 4, 0, 5, 14, 18, 22, 30, 35, 39, 43, 0, 6, 10, 12, 13, 0, 7, 0, 8, 8, 0, 9, 9, 0, 47, 47, 0, 11, 0, 8, 8, 0, 7, 0, 11, 0, 15, 17, 0, 16, 0, 8, 8, 0, 16, 0, 19, 21, 0, 20, 0, 8, 8, 0, 20, 0, 23, 25, 28, 29, 0, 24, 0, 8, 8, 0, 26, 27, 0, 8, 8, 0, 8, 8, 0, 24, 0, 26, 27, 0, 31, 34, 0, 32, 33, 0, 8, 8, 0, 8, 8, 0, 32, 33, 0, 36, 38, 0, 37, 0, 8, 8, 0, 37, 0, 40, 42, 0, 41, 0, 8, 8, 0, 41, 0, 44, 46, 0, 45, 0, 8, 8, 0, 45, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 0 }; static const signed char _sav_date_parse_cond_actions[] = { 31, 31, 0, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13, 0, 31, 31, 0, 1, 1, 0, 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 29, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 0, 0, 0, 0, 19, 19, 0, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 0, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 27, 0, 0, 0, 0, 0, 0, 0, 0, 25, 25, 0, 0, 0, 0, 0, 0, 0, 0, 23, 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0 }; static const short _sav_date_parse_eof_trans[] = { 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 0 }; static const int sav_date_parse_start = 1; static const int sav_date_parse_en_main = 1; #line 59 "src/spss/readstat_sav_parse_timestamp.rl" readstat_error_t sav_parse_date(const char *data, size_t len, struct tm *timestamp, readstat_error_handler error_cb, void *user_ctx) { readstat_error_t retval = READSTAT_OK; char error_buf[8192]; const char *p = data; const char *pe = p + len; const char *eof = pe; int cs; int temp_val = 0; #line 408 "src/spss/readstat_sav_parse_timestamp.c" { cs = (int)sav_date_parse_start; } #line 413 "src/spss/readstat_sav_parse_timestamp.c" { int _klen; unsigned int _trans = 0; const char * _keys; const signed char * _acts; unsigned int _nacts; _resume: {} if ( p == pe && p != eof ) goto _out; if ( p == eof ) { if ( _sav_date_parse_eof_trans[cs] > 0 ) { _trans = (unsigned int)_sav_date_parse_eof_trans[cs] - 1; } } else { _keys = ( _sav_date_parse_trans_keys + (_sav_date_parse_key_offsets[cs])); _trans = (unsigned int)_sav_date_parse_index_offsets[cs]; _klen = (int)_sav_date_parse_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + _klen - 1; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _keys += _klen; _trans += (unsigned int)_klen; break; } _mid = _lower + ((_upper-_lower) >> 1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 1; else if ( ( (*( p))) > (*( _mid)) ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } } _klen = (int)_sav_date_parse_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + (_klen<<1) - 2; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _trans += (unsigned int)_klen; break; } _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 2; else if ( ( (*( p))) > (*( _mid + 1)) ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); break; } } } _match: {} } cs = (int)_sav_date_parse_cond_targs[_trans]; if ( _sav_date_parse_cond_actions[_trans] != 0 ) { _acts = ( _sav_date_parse_actions + (_sav_date_parse_cond_actions[_trans])); _nacts = (unsigned int)(*( _acts)); _acts += 1; while ( _nacts > 0 ) { switch ( (*( _acts)) ) { case 0: { { #line 71 "src/spss/readstat_sav_parse_timestamp.rl" char digit = ((( (*( p)))) - '0'); if (digit >= 0 && digit <= 9) { temp_val = 10 * temp_val + digit; } } #line 501 "src/spss/readstat_sav_parse_timestamp.c" break; } case 1: { { #line 78 "src/spss/readstat_sav_parse_timestamp.rl" if (temp_val < 70) { timestamp->tm_year = 100 + temp_val; } else { timestamp->tm_year = temp_val; } } #line 516 "src/spss/readstat_sav_parse_timestamp.c" break; } case 2: { { #line 87 "src/spss/readstat_sav_parse_timestamp.rl" temp_val = 0; } #line 525 "src/spss/readstat_sav_parse_timestamp.c" break; } case 3: { { #line 89 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mday = temp_val; } #line 534 "src/spss/readstat_sav_parse_timestamp.c" break; } case 4: { { #line 94 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 0; } #line 543 "src/spss/readstat_sav_parse_timestamp.c" break; } case 5: { { #line 95 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 1; } #line 552 "src/spss/readstat_sav_parse_timestamp.c" break; } case 6: { { #line 96 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 2; } #line 561 "src/spss/readstat_sav_parse_timestamp.c" break; } case 7: { { #line 97 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 3; } #line 570 "src/spss/readstat_sav_parse_timestamp.c" break; } case 8: { { #line 98 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 4; } #line 579 "src/spss/readstat_sav_parse_timestamp.c" break; } case 9: { { #line 99 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 5; } #line 588 "src/spss/readstat_sav_parse_timestamp.c" break; } case 10: { { #line 100 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 6; } #line 597 "src/spss/readstat_sav_parse_timestamp.c" break; } case 11: { { #line 101 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 7; } #line 606 "src/spss/readstat_sav_parse_timestamp.c" break; } case 12: { { #line 102 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 8; } #line 615 "src/spss/readstat_sav_parse_timestamp.c" break; } case 13: { { #line 103 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 9; } #line 624 "src/spss/readstat_sav_parse_timestamp.c" break; } case 14: { { #line 104 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 10; } #line 633 "src/spss/readstat_sav_parse_timestamp.c" break; } case 15: { { #line 105 "src/spss/readstat_sav_parse_timestamp.rl" timestamp->tm_mon = 11; } #line 642 "src/spss/readstat_sav_parse_timestamp.c" break; } } _nacts -= 1; _acts += 1; } } if ( p == eof ) { if ( cs >= 47 ) goto _out; } else { if ( cs != 0 ) { p += 1; goto _resume; } } _out: {} } #line 112 "src/spss/readstat_sav_parse_timestamp.rl" if (cs < #line 670 "src/spss/readstat_sav_parse_timestamp.c" 47 #line 114 "src/spss/readstat_sav_parse_timestamp.rl" || p != pe) { if (error_cb) { snprintf(error_buf, sizeof(error_buf), "Invalid date string (length=%d): %.*s", (int)len, (int)len, data); error_cb(error_buf, user_ctx); } retval = READSTAT_ERROR_BAD_TIMESTAMP_STRING; } (void)sav_date_parse_en_main; return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav_parse_timestamp.h0000644023477200000240000000043514574360757023514 0ustar00fajardoostaffs readstat_error_t sav_parse_time(const char *data, size_t len, struct tm *timestamp, readstat_error_handler error_cb, void *user_ctx); readstat_error_t sav_parse_date(const char *data, size_t len, struct tm *timestamp, readstat_error_handler error_cb, void *user_ctx); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav_read.c0000644023477200000240000016205614574360757021235 0ustar00fajardoostaffs #include #include #include #include #include #include #include #include #include #include "../readstat.h" #include "../readstat_bits.h" #include "../readstat_iconv.h" #include "../readstat_convert.h" #include "../readstat_malloc.h" #include "readstat_sav.h" #include "readstat_sav_compress.h" #include "readstat_sav_parse.h" #include "readstat_sav_parse_timestamp.h" #if HAVE_ZLIB #include "readstat_zsav_read.h" #endif #define DATA_BUFFER_SIZE 65536 #define VERY_LONG_STRING_MAX_LENGTH INT_MAX /* Others defined in table below */ /* See http://msdn.microsoft.com/en-us/library/dd317756(VS.85).aspx */ static readstat_charset_entry_t _charset_table[] = { { .code = 1, .name = "EBCDIC-US" }, { .code = 2, .name = "WINDOWS-1252" }, /* supposed to be ASCII, but some files are miscoded */ { .code = 3, .name = "WINDOWS-1252" }, { .code = 4, .name = "DEC-KANJI" }, { .code = 437, .name = "CP437" }, { .code = 708, .name = "ASMO-708" }, { .code = 737, .name = "CP737" }, { .code = 775, .name = "CP775" }, { .code = 850, .name = "CP850" }, { .code = 852, .name = "CP852" }, { .code = 855, .name = "CP855" }, { .code = 857, .name = "CP857" }, { .code = 858, .name = "CP858" }, { .code = 860, .name = "CP860" }, { .code = 861, .name = "CP861" }, { .code = 862, .name = "CP862" }, { .code = 863, .name = "CP863" }, { .code = 864, .name = "CP864" }, { .code = 865, .name = "CP865" }, { .code = 866, .name = "CP866" }, { .code = 869, .name = "CP869" }, { .code = 874, .name = "CP874" }, { .code = 932, .name = "CP932" }, { .code = 936, .name = "CP936" }, { .code = 949, .name = "CP949" }, { .code = 950, .name = "BIG-5" }, { .code = 1200, .name = "UTF-16LE" }, { .code = 1201, .name = "UTF-16BE" }, { .code = 1250, .name = "WINDOWS-1250" }, { .code = 1251, .name = "WINDOWS-1251" }, { .code = 1252, .name = "WINDOWS-1252" }, { .code = 1253, .name = "WINDOWS-1253" }, { .code = 1254, .name = "WINDOWS-1254" }, { .code = 1255, .name = "WINDOWS-1255" }, { .code = 1256, .name = "WINDOWS-1256" }, { .code = 1257, .name = "WINDOWS-1257" }, { .code = 1258, .name = "WINDOWS-1258" }, { .code = 1361, .name = "CP1361" }, { .code = 10000, .name = "MACROMAN" }, { .code = 10004, .name = "MACARABIC" }, { .code = 10005, .name = "MACHEBREW" }, { .code = 10006, .name = "MACGREEK" }, { .code = 10007, .name = "MACCYRILLIC" }, { .code = 10010, .name = "MACROMANIA" }, { .code = 10017, .name = "MACUKRAINE" }, { .code = 10021, .name = "MACTHAI" }, { .code = 10029, .name = "MACCENTRALEUROPE" }, { .code = 10079, .name = "MACICELAND" }, { .code = 10081, .name = "MACTURKISH" }, { .code = 10082, .name = "MACCROATIAN" }, { .code = 12000, .name = "UTF-32LE" }, { .code = 12001, .name = "UTF-32BE" }, { .code = 20127, .name = "US-ASCII" }, { .code = 20866, .name = "KOI8-R" }, { .code = 20932, .name = "EUC-JP" }, { .code = 21866, .name = "KOI8-U" }, { .code = 28591, .name = "ISO-8859-1" }, { .code = 28592, .name = "ISO-8859-2" }, { .code = 28593, .name = "ISO-8859-3" }, { .code = 28594, .name = "ISO-8859-4" }, { .code = 28595, .name = "ISO-8859-5" }, { .code = 28596, .name = "ISO-8859-6" }, { .code = 28597, .name = "ISO-8859-7" }, { .code = 28598, .name = "ISO-8859-8" }, { .code = 28599, .name = "ISO-8859-9" }, { .code = 28603, .name = "ISO-8859-13" }, { .code = 28605, .name = "ISO-8859-15" }, { .code = 50220, .name = "ISO-2022-JP" }, { .code = 50221, .name = "ISO-2022-JP" }, // same as above? { .code = 50222, .name = "ISO-2022-JP" }, // same as above? { .code = 50225, .name = "ISO-2022-KR" }, { .code = 50229, .name = "ISO-2022-CN" }, { .code = 51932, .name = "EUC-JP" }, { .code = 51936, .name = "GBK" }, { .code = 51949, .name = "EUC-KR" }, { .code = 52936, .name = "HZ-GB-2312" }, { .code = 54936, .name = "GB18030" }, { .code = 65000, .name = "UTF-7" }, { .code = 65001, .name = "UTF-8" } }; #define SAV_LABEL_NAME_PREFIX "labels" typedef struct value_label_s { char raw_value[8]; char utf8_string_value[8*4+1]; readstat_value_t final_value; char *label; } value_label_t; static readstat_error_t sav_update_progress(sav_ctx_t *ctx); static readstat_error_t sav_read_data(sav_ctx_t *ctx); static readstat_error_t sav_read_compressed_data(sav_ctx_t *ctx, readstat_error_t (*row_handler)(unsigned char *, size_t, sav_ctx_t *)); static readstat_error_t sav_read_uncompressed_data(sav_ctx_t *ctx, readstat_error_t (*row_handler)(unsigned char *, size_t, sav_ctx_t *)); static readstat_error_t sav_skip_variable_record(sav_ctx_t *ctx); static readstat_error_t sav_read_variable_record(sav_ctx_t *ctx); static readstat_error_t sav_skip_document_record(sav_ctx_t *ctx); static readstat_error_t sav_read_document_record(sav_ctx_t *ctx); static readstat_error_t sav_skip_value_label_record(sav_ctx_t *ctx); static readstat_error_t sav_read_value_label_record(sav_ctx_t *ctx); static readstat_error_t sav_read_dictionary_termination_record(sav_ctx_t *ctx); static readstat_error_t sav_parse_machine_floating_point_record(const void *data, size_t size, size_t count, sav_ctx_t *ctx); static readstat_error_t sav_store_variable_display_parameter_record(const void *data, size_t size, size_t count, sav_ctx_t *ctx); static readstat_error_t sav_parse_variable_display_parameter_record(sav_ctx_t *ctx); static readstat_error_t sav_parse_machine_integer_info_record(const void *data, size_t data_len, sav_ctx_t *ctx); static readstat_error_t sav_parse_long_string_value_labels_record(const void *data, size_t size, size_t count, sav_ctx_t *ctx); static readstat_error_t sav_parse_long_string_missing_values_record(const void *data, size_t size, size_t count, sav_ctx_t *ctx); static void sav_tag_missing_double(readstat_value_t *value, sav_ctx_t *ctx) { double fp_value = value->v.double_value; uint64_t long_value = 0; memcpy(&long_value, &fp_value, 8); if (long_value == ctx->missing_double) value->is_system_missing = 1; if (long_value == ctx->lowest_double) value->is_system_missing = 1; if (long_value == ctx->highest_double) value->is_system_missing = 1; if (isnan(fp_value)) value->is_system_missing = 1; } static readstat_error_t sav_update_progress(sav_ctx_t *ctx) { readstat_io_t *io = ctx->io; return io->update(ctx->file_size, ctx->handle.progress, ctx->user_ctx, io->io_ctx); } static readstat_error_t sav_skip_variable_record(sav_ctx_t *ctx) { sav_variable_record_t variable; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; if (io->read(&variable, sizeof(sav_variable_record_t), io->io_ctx) < sizeof(sav_variable_record_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (variable.has_var_label) { uint32_t label_len; if (io->read(&label_len, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } label_len = ctx->bswap ? byteswap4(label_len) : label_len; uint32_t label_capacity = (label_len + 3) / 4 * 4; if (io->seek(label_capacity, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } } if (variable.n_missing_values) { int n_missing_values = ctx->bswap ? byteswap4(variable.n_missing_values) : variable.n_missing_values; if (io->seek(abs(n_missing_values) * sizeof(double), READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } } cleanup: return retval; } static readstat_error_t sav_read_variable_label(spss_varinfo_t *info, sav_ctx_t *ctx) { readstat_io_t *io = ctx->io; readstat_error_t retval = READSTAT_OK; uint32_t label_len, label_capacity; size_t out_label_len; char *label_buf = NULL; if (io->read(&label_len, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } label_len = ctx->bswap ? byteswap4(label_len) : label_len; if (label_len == 0) goto cleanup; label_capacity = (label_len + 3) / 4 * 4; if ((label_buf = readstat_malloc(label_capacity)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } out_label_len = (size_t)label_len*4+1; if ((info->label = readstat_malloc(out_label_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (io->read(label_buf, label_capacity, io->io_ctx) < label_capacity) { retval = READSTAT_ERROR_READ; goto cleanup; } retval = readstat_convert(info->label, out_label_len, label_buf, label_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; cleanup: if (label_buf) free(label_buf); if (retval != READSTAT_OK) { if (info->label) { free(info->label); info->label = NULL; } } return retval; } static readstat_error_t sav_read_variable_missing_double_values(spss_varinfo_t *info, sav_ctx_t *ctx) { readstat_io_t *io = ctx->io; int i; readstat_error_t retval = READSTAT_OK; if (io->read(info->missing_double_values, info->n_missing_values * sizeof(double), io->io_ctx) < info->n_missing_values * sizeof(double)) { retval = READSTAT_ERROR_READ; goto cleanup; } for (i=0; in_missing_values; i++) { if (ctx->bswap) { info->missing_double_values[i] = byteswap_double(info->missing_double_values[i]); } uint64_t long_value = 0; memcpy(&long_value, &info->missing_double_values[i], 8); if (long_value == ctx->missing_double) info->missing_double_values[i] = NAN; if (long_value == ctx->lowest_double) info->missing_double_values[i] = -HUGE_VAL; if (long_value == ctx->highest_double) info->missing_double_values[i] = HUGE_VAL; } cleanup: return retval; } static readstat_error_t sav_read_variable_missing_string_values(spss_varinfo_t *info, sav_ctx_t *ctx) { readstat_io_t *io = ctx->io; int i; readstat_error_t retval = READSTAT_OK; for (i=0; in_missing_values; i++) { char missing_value[8]; if (io->read(missing_value, sizeof(missing_value), io->io_ctx) < sizeof(missing_value)) { retval = READSTAT_ERROR_READ; goto cleanup; } retval = readstat_convert(info->missing_string_values[i], sizeof(info->missing_string_values[0]), missing_value, sizeof(missing_value), ctx->converter); if (retval != READSTAT_OK) goto cleanup; } cleanup: return retval; } static readstat_error_t sav_read_variable_missing_values(spss_varinfo_t *info, sav_ctx_t *ctx) { if (info->n_missing_values > 3 || info->n_missing_values < -3) { return READSTAT_ERROR_PARSE; } if (info->n_missing_values < 0) { info->missing_range = 1; info->n_missing_values = abs(info->n_missing_values); } else { info->missing_range = 0; } if (info->type == READSTAT_TYPE_DOUBLE) { return sav_read_variable_missing_double_values(info, ctx); } return sav_read_variable_missing_string_values(info, ctx); } static readstat_error_t sav_read_variable_record(sav_ctx_t *ctx) { readstat_io_t *io = ctx->io; sav_variable_record_t variable = { 0 }; spss_varinfo_t *info = NULL; readstat_error_t retval = READSTAT_OK; if (ctx->var_index == ctx->varinfo_capacity) { if ((ctx->varinfo = readstat_realloc(ctx->varinfo, (ctx->varinfo_capacity *= 2) * sizeof(spss_varinfo_t *))) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } } if (io->read(&variable, sizeof(sav_variable_record_t), io->io_ctx) < sizeof(sav_variable_record_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } variable.print = ctx->bswap ? byteswap4(variable.print) : variable.print; variable.write = ctx->bswap ? byteswap4(variable.write) : variable.write; int32_t type = ctx->bswap ? byteswap4(variable.type) : variable.type; if (type < 0) { if (ctx->var_index == 0) { return READSTAT_ERROR_PARSE; } ctx->var_offset++; ctx->varinfo[ctx->var_index-1]->width++; return 0; } if ((info = readstat_calloc(1, sizeof(spss_varinfo_t))) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } info->width = 1; info->n_segments = 1; info->index = ctx->var_index; info->offset = ctx->var_offset; info->labels_index = -1; retval = readstat_convert(info->name, sizeof(info->name), variable.name, sizeof(variable.name), NULL); if (retval != READSTAT_OK) goto cleanup; retval = readstat_convert(info->longname, sizeof(info->longname), variable.name, sizeof(variable.name), NULL); if (retval != READSTAT_OK) goto cleanup; info->print_format.decimal_places = (variable.print & 0x000000FF); info->print_format.width = (variable.print & 0x0000FF00) >> 8; info->print_format.type = (variable.print & 0x00FF0000) >> 16; info->write_format.decimal_places = (variable.write & 0x000000FF); info->write_format.width = (variable.write & 0x0000FF00) >> 8; info->write_format.type = (variable.write & 0x00FF0000) >> 16; if (type > 0 || info->print_format.type == SPSS_FORMAT_TYPE_A || info->write_format.type == SPSS_FORMAT_TYPE_A) { info->type = READSTAT_TYPE_STRING; } else { info->type = READSTAT_TYPE_DOUBLE; } if (variable.has_var_label) { if ((retval = sav_read_variable_label(info, ctx)) != READSTAT_OK) { goto cleanup; } } if (variable.n_missing_values) { info->n_missing_values = ctx->bswap ? byteswap4(variable.n_missing_values) : variable.n_missing_values; if ((retval = sav_read_variable_missing_values(info, ctx)) != READSTAT_OK) { goto cleanup; } } ctx->varinfo[ctx->var_index] = info; ctx->var_index++; ctx->var_offset++; cleanup: if (retval != READSTAT_OK) { spss_varinfo_free(info); } return retval; } static readstat_error_t sav_skip_value_label_record(sav_ctx_t *ctx) { uint32_t label_count; uint32_t rec_type; uint32_t var_count; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; if (io->read(&label_count, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) label_count = byteswap4(label_count); int i; for (i=0; iseek(8, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->read(&unpadded_len, 1, io->io_ctx) < 1) { retval = READSTAT_ERROR_READ; goto cleanup; } padded_len = (unpadded_len + 8) / 8 * 8 - 1; if (io->seek(padded_len, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } } if (io->read(&rec_type, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) rec_type = byteswap4(rec_type); if (rec_type != 4) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (io->read(&var_count, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) var_count = byteswap4(var_count); if (io->seek(var_count * sizeof(uint32_t), READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } cleanup: return retval; } static readstat_error_t sav_submit_value_labels(value_label_t *value_labels, int32_t label_count, readstat_type_t value_type, sav_ctx_t *ctx) { char label_name_buf[256]; readstat_error_t retval = READSTAT_OK; int32_t i; snprintf(label_name_buf, sizeof(label_name_buf), SAV_LABEL_NAME_PREFIX "%d", ctx->value_labels_count); for (i=0; ihandle.value_label(label_name_buf, vlabel->final_value, vlabel->label, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } cleanup: return retval; } static readstat_error_t sav_read_value_label_record(sav_ctx_t *ctx) { uint32_t label_count; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; uint32_t *vars = NULL; uint32_t var_count; int32_t rec_type; readstat_type_t value_type = READSTAT_TYPE_STRING; char label_buf[256]; value_label_t *value_labels = NULL; if (io->read(&label_count, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) label_count = byteswap4(label_count); if (label_count && (value_labels = readstat_calloc(label_count, sizeof(value_label_t))) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } int i; for (i=0; iread(vlabel->raw_value, 8, io->io_ctx) < 8) { retval = READSTAT_ERROR_READ; goto cleanup; } if (io->read(&unpadded_label_len, 1, io->io_ctx) < 1) { retval = READSTAT_ERROR_READ; goto cleanup; } padded_label_len = (unpadded_label_len + 8) / 8 * 8 - 1; if (io->read(label_buf, padded_label_len, io->io_ctx) < padded_label_len) { retval = READSTAT_ERROR_READ; goto cleanup; } utf8_label_len = padded_label_len*4+1; if ((vlabel->label = readstat_malloc(utf8_label_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } retval = readstat_convert(vlabel->label, utf8_label_len, label_buf, padded_label_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; } if (io->read(&rec_type, sizeof(int32_t), io->io_ctx) < sizeof(int32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) rec_type = byteswap4(rec_type); if (rec_type != 4) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (io->read(&var_count, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) var_count = byteswap4(var_count); if (var_count && (vars = readstat_malloc(var_count * sizeof(uint32_t))) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (io->read(vars, var_count * sizeof(uint32_t), io->io_ctx) < var_count * sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } for (i=0; ibswap) var_offset = byteswap4(var_offset); var_offset--; // Why subtract 1???? spss_varinfo_t **var = bsearch(&var_offset, ctx->varinfo, ctx->var_index, sizeof(spss_varinfo_t *), &spss_varinfo_compare); if (var) { (*var)->labels_index = ctx->value_labels_count; value_type = (*var)->type; } } for (i=0; ifinal_value.type = value_type; if (value_type == READSTAT_TYPE_DOUBLE) { memcpy(&val_d, vlabel->raw_value, 8); if (ctx->bswap) val_d = byteswap_double(val_d); vlabel->final_value.v.double_value = val_d; sav_tag_missing_double(&vlabel->final_value, ctx); } else { retval = readstat_convert(vlabel->utf8_string_value, sizeof(vlabel->utf8_string_value), vlabel->raw_value, 8, ctx->converter); if (retval != READSTAT_OK) break; vlabel->final_value.v.string_value = vlabel->utf8_string_value; } } if (ctx->handle.value_label) { sav_submit_value_labels(value_labels, label_count, value_type, ctx); } ctx->value_labels_count++; cleanup: if (vars) free(vars); if (value_labels) { for (i=0; ilabel) free(vlabel->label); } free(value_labels); } return retval; } static readstat_error_t sav_skip_document_record(sav_ctx_t *ctx) { uint32_t n_lines; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; if (io->read(&n_lines, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) n_lines = byteswap4(n_lines); if (io->seek(n_lines * SPSS_DOC_LINE_SIZE, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } cleanup: return retval; } static readstat_error_t sav_read_document_record(sav_ctx_t *ctx) { if (!ctx->handle.note) return sav_skip_document_record(ctx); uint32_t n_lines; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; if (io->read(&n_lines, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) n_lines = byteswap4(n_lines); char raw_buffer[SPSS_DOC_LINE_SIZE]; char utf8_buffer[4*SPSS_DOC_LINE_SIZE+1]; int i; for (i=0; iread(raw_buffer, SPSS_DOC_LINE_SIZE, io->io_ctx) < SPSS_DOC_LINE_SIZE) { retval = READSTAT_ERROR_READ; goto cleanup; } retval = readstat_convert(utf8_buffer, sizeof(utf8_buffer), raw_buffer, sizeof(raw_buffer), ctx->converter); if (retval != READSTAT_OK) goto cleanup; if (ctx->handle.note(i, utf8_buffer, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } cleanup: return retval; } static readstat_error_t sav_read_dictionary_termination_record(sav_ctx_t *ctx) { int32_t filler; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; if (io->read(&filler, sizeof(int32_t), io->io_ctx) < sizeof(int32_t)) { retval = READSTAT_ERROR_READ; } return retval; } static readstat_error_t sav_process_row(unsigned char *buffer, size_t buffer_len, sav_ctx_t *ctx) { if (ctx->row_offset) { ctx->row_offset--; return READSTAT_OK; } readstat_error_t retval = READSTAT_OK; double fp_value; int offset = 0; readstat_off_t data_offset = 0; size_t raw_str_used = 0; int segment_offset = 0; int var_index = 0, col = 0; int raw_str_is_utf8 = ctx->input_encoding && !strcmp(ctx->input_encoding, "UTF-8"); while (data_offset < buffer_len && col < ctx->var_index && var_index < ctx->var_index) { spss_varinfo_t *col_info = ctx->varinfo[col]; spss_varinfo_t *var_info = ctx->varinfo[var_index]; readstat_value_t value = { .type = var_info->type }; if (offset > 31) { retval = READSTAT_ERROR_PARSE; goto done; } if (var_info->type == READSTAT_TYPE_STRING) { if (raw_str_used + 8 <= ctx->raw_string_len) { if (raw_str_is_utf8) { /* Skip null bytes, see https://github.com/tidyverse/haven/issues/560 */ char c; for (int i=0; i<8; i++) if ((c = buffer[data_offset+i])) ctx->raw_string[raw_str_used++] = c; } else { memcpy(ctx->raw_string + raw_str_used, &buffer[data_offset], 8); raw_str_used += 8; } } if (++offset == col_info->width) { if (++segment_offset < var_info->n_segments) { raw_str_used--; } offset = 0; col++; } if (segment_offset == var_info->n_segments) { if (!ctx->variables[var_info->index]->skip) { retval = readstat_convert(ctx->utf8_string, ctx->utf8_string_len, ctx->raw_string, raw_str_used, ctx->converter); if (retval != READSTAT_OK) goto done; value.v.string_value = ctx->utf8_string; if (ctx->handle.value(ctx->current_row, ctx->variables[var_info->index], value, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto done; } } raw_str_used = 0; segment_offset = 0; var_index += var_info->n_segments; } } else if (var_info->type == READSTAT_TYPE_DOUBLE) { if (!ctx->variables[var_info->index]->skip) { memcpy(&fp_value, &buffer[data_offset], 8); if (ctx->bswap) { fp_value = byteswap_double(fp_value); } value.v.double_value = fp_value; sav_tag_missing_double(&value, ctx); if (ctx->handle.value(ctx->current_row, ctx->variables[var_info->index], value, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto done; } } var_index += var_info->n_segments; col++; } data_offset += 8; } ctx->current_row++; done: return retval; } static readstat_error_t sav_read_data(sav_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; size_t longest_string = 256; int i; for (i=0; ivar_index;) { spss_varinfo_t *info = ctx->varinfo[i]; if (info->string_length > longest_string) { longest_string = info->string_length; } i += info->n_segments; } ctx->raw_string_len = longest_string + sizeof(SAV_EIGHT_SPACES)-2; ctx->raw_string = readstat_malloc(ctx->raw_string_len); ctx->utf8_string_len = 4*longest_string+1 + sizeof(SAV_EIGHT_SPACES)-2; ctx->utf8_string = readstat_malloc(ctx->utf8_string_len); if (ctx->raw_string == NULL || ctx->utf8_string == NULL) { retval = READSTAT_ERROR_MALLOC; goto done; } if (ctx->compression == READSTAT_COMPRESS_ROWS) { retval = sav_read_compressed_data(ctx, &sav_process_row); } else if (ctx->compression == READSTAT_COMPRESS_BINARY) { #if HAVE_ZLIB retval = zsav_read_compressed_data(ctx, &sav_process_row); #else retval = READSTAT_ERROR_UNSUPPORTED_COMPRESSION; #endif } else { retval = sav_read_uncompressed_data(ctx, &sav_process_row); } if (retval != READSTAT_OK) goto done; if (ctx->record_count >= 0 && ctx->current_row != ctx->row_limit) { retval = READSTAT_ERROR_ROW_COUNT_MISMATCH; } done: return retval; } static readstat_error_t sav_read_uncompressed_data(sav_ctx_t *ctx, readstat_error_t (*row_handler)(unsigned char *, size_t, sav_ctx_t *)) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; unsigned char *buffer = NULL; size_t bytes_read = 0; size_t buffer_len = ctx->var_offset * 8; buffer = readstat_malloc(buffer_len); if (ctx->row_offset) { if (io->seek(buffer_len * ctx->row_offset, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto done; } ctx->row_offset = 0; } while (ctx->row_limit == -1 || ctx->current_row < ctx->row_limit) { retval = sav_update_progress(ctx); if (retval != READSTAT_OK) goto done; if ((bytes_read = io->read(buffer, buffer_len, io->io_ctx)) != buffer_len) goto done; retval = row_handler(buffer, buffer_len, ctx); if (retval != READSTAT_OK) goto done; } done: if (buffer) free(buffer); return retval; } static readstat_error_t sav_read_compressed_data(sav_ctx_t *ctx, readstat_error_t (*row_handler)(unsigned char *, size_t, sav_ctx_t *)) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; readstat_off_t data_offset = 0; unsigned char buffer[DATA_BUFFER_SIZE]; int buffer_used = 0; size_t uncompressed_row_len = ctx->var_offset * 8; readstat_off_t uncompressed_offset = 0; unsigned char *uncompressed_row = NULL; struct sav_row_stream_s state = { .missing_value = ctx->missing_double, .bias = ctx->bias, .bswap = ctx->bswap }; if (uncompressed_row_len && (uncompressed_row = readstat_malloc(uncompressed_row_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto done; } while (1) { retval = sav_update_progress(ctx); if (retval != READSTAT_OK) goto done; buffer_used = io->read(buffer, sizeof(buffer), io->io_ctx); if (buffer_used == -1 || buffer_used == 0 || (buffer_used % 8) != 0) goto done; state.status = SAV_ROW_STREAM_HAVE_DATA; data_offset = 0; while (state.status != SAV_ROW_STREAM_NEED_DATA) { state.next_in = &buffer[data_offset]; state.avail_in = buffer_used - data_offset; state.next_out = &uncompressed_row[uncompressed_offset]; state.avail_out = uncompressed_row_len - uncompressed_offset; sav_decompress_row(&state); uncompressed_offset = uncompressed_row_len - state.avail_out; data_offset = buffer_used - state.avail_in; if (state.status == SAV_ROW_STREAM_FINISHED_ROW) { retval = row_handler(uncompressed_row, uncompressed_row_len, ctx); if (retval != READSTAT_OK) goto done; uncompressed_offset = 0; } if (state.status == SAV_ROW_STREAM_FINISHED_ALL) goto done; if (ctx->row_limit > 0 && ctx->current_row == ctx->row_limit) goto done; } } done: if (uncompressed_row) free(uncompressed_row); return retval; } static readstat_error_t sav_parse_machine_integer_info_record(const void *data, size_t data_len, sav_ctx_t *ctx) { if (data_len != 32) return READSTAT_ERROR_PARSE; const char *src_charset = NULL; const char *dst_charset = ctx->output_encoding; sav_machine_integer_info_record_t record; memcpy(&record, data, data_len); if (ctx->bswap) { record.character_code = byteswap4(record.character_code); } if (ctx->input_encoding) { src_charset = ctx->input_encoding; } else { int i; for (i=0; ihandle.error) { char error_buf[1024]; snprintf(error_buf, sizeof(error_buf), "Unsupported character set: %d\n", record.character_code); ctx->handle.error(error_buf, ctx->user_ctx); } return READSTAT_ERROR_UNSUPPORTED_CHARSET; } ctx->input_encoding = src_charset; } if (src_charset && dst_charset) { // You might be tempted to skip the charset conversion when src_charset // and dst_charset are the same. However, some versions of SPSS insert // illegally truncated strings (e.g. the last character is three bytes // but the field only has room for two bytes). So to prevent the client // from receiving an invalid byte sequence, we ram everything through // our iconv machinery. iconv_t converter = iconv_open(dst_charset, src_charset); if (converter == (iconv_t)-1) { return READSTAT_ERROR_UNSUPPORTED_CHARSET; } if (ctx->converter) { iconv_close(ctx->converter); } ctx->converter = converter; } return READSTAT_OK; } static readstat_error_t sav_parse_machine_floating_point_record(const void *data, size_t size, size_t count, sav_ctx_t *ctx) { if (size != 8 || count != 3) return READSTAT_ERROR_PARSE; sav_machine_floating_point_info_record_t fp_info; memcpy(&fp_info, data, sizeof(sav_machine_floating_point_info_record_t)); ctx->missing_double = ctx->bswap ? byteswap8(fp_info.sysmis) : fp_info.sysmis; ctx->highest_double = ctx->bswap ? byteswap8(fp_info.highest) : fp_info.highest; ctx->lowest_double = ctx->bswap ? byteswap8(fp_info.lowest) : fp_info.lowest; return READSTAT_OK; } /* We don't yet know how many real variables there are, so store the values in the record * and make sense of them later. */ static readstat_error_t sav_store_variable_display_parameter_record(const void *data, size_t size, size_t count, sav_ctx_t *ctx) { if (size != 4) return READSTAT_ERROR_PARSE; const uint32_t *data_ptr = data; int i; ctx->variable_display_values = readstat_realloc(ctx->variable_display_values, count * sizeof(uint32_t)); if (count > 0 && ctx->variable_display_values == NULL) return READSTAT_ERROR_MALLOC; ctx->variable_display_values_count = count; for (i=0; ivariable_display_values[i] = ctx->bswap ? byteswap4(data_ptr[i]) : data_ptr[i]; } return READSTAT_OK; } static readstat_error_t sav_parse_variable_display_parameter_record(sav_ctx_t *ctx) { if (!ctx->variable_display_values) return READSTAT_OK; int i; long count = ctx->variable_display_values_count; if (count != 2 * ctx->var_index && count != 3 * ctx->var_index) { return READSTAT_ERROR_PARSE; } int has_display_width = ctx->var_index > 0 && (count / ctx->var_index == 3); int offset = 0; for (i=0; ivar_index;) { spss_varinfo_t *info = ctx->varinfo[i]; offset = (2 + has_display_width)*i; info->measure = spss_measure_to_readstat_measure(ctx->variable_display_values[offset++]); if (has_display_width) { info->display_width = ctx->variable_display_values[offset++]; } info->alignment = spss_alignment_to_readstat_alignment(ctx->variable_display_values[offset++]); i += info->n_segments; } return READSTAT_OK; } static readstat_error_t sav_read_pascal_string(char *buf, size_t buf_len, const char **inout_data_ptr, size_t data_ptr_len, sav_ctx_t *ctx) { const char *data_ptr = *inout_data_ptr; const char *data_end = data_ptr + data_ptr_len; readstat_error_t retval = READSTAT_OK; uint32_t var_name_len = 0; if (data_ptr + sizeof(uint32_t) > data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } memcpy(&var_name_len, data_ptr, sizeof(uint32_t)); if (ctx->bswap) var_name_len = byteswap4(var_name_len); data_ptr += sizeof(uint32_t); if (data_ptr + var_name_len > data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } retval = readstat_convert(buf, buf_len, data_ptr, var_name_len, NULL); if (retval != READSTAT_OK) goto cleanup; data_ptr += var_name_len; cleanup: *inout_data_ptr = data_ptr; return retval; } static readstat_error_t sav_parse_long_string_value_labels_record(const void *data, size_t size, size_t count, sav_ctx_t *ctx) { if (!ctx->handle.value_label) return READSTAT_OK; if (size != 1) return READSTAT_ERROR_PARSE; readstat_error_t retval = READSTAT_OK; uint32_t label_count = 0; uint32_t i = 0; const char *data_ptr = data; const char *data_end = data_ptr + count; char var_name_buf[256+1]; // unconverted char label_name_buf[256]; char *value_buffer = NULL; char *label_buffer = NULL; while (data_ptr < data_end) { memset(label_name_buf, '\0', sizeof(label_name_buf)); retval = sav_read_pascal_string(var_name_buf, sizeof(var_name_buf), &data_ptr, data_end - data_ptr, ctx); if (retval != READSTAT_OK) goto cleanup; for (i=0; ivar_index;) { spss_varinfo_t *info = ctx->varinfo[i]; if (strcmp(var_name_buf, info->longname) == 0) { info->labels_index = ctx->value_labels_count++; snprintf(label_name_buf, sizeof(label_name_buf), SAV_LABEL_NAME_PREFIX "%d", info->labels_index); break; } i += info->n_segments; } if (label_name_buf[0] == '\0') { retval = READSTAT_ERROR_PARSE; goto cleanup; } data_ptr += sizeof(uint32_t); if (data_ptr + sizeof(uint32_t) > data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } memcpy(&label_count, data_ptr, sizeof(uint32_t)); if (ctx->bswap) label_count = byteswap4(label_count); data_ptr += sizeof(uint32_t); for (i=0; i data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } memcpy(&value_len, data_ptr, sizeof(uint32_t)); if (ctx->bswap) value_len = byteswap4(value_len); data_ptr += sizeof(uint32_t); value_buffer_len = value_len*4+1; value_buffer = readstat_realloc(value_buffer, value_buffer_len); if (value_buffer == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (data_ptr + value_len > data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } retval = readstat_convert(value_buffer, value_buffer_len, data_ptr, value_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; data_ptr += value_len; if (data_ptr + sizeof(uint32_t) > data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } memcpy(&label_len, data_ptr, sizeof(uint32_t)); if (ctx->bswap) label_len = byteswap4(label_len); data_ptr += sizeof(uint32_t); label_buffer_len = label_len*4+1; label_buffer = readstat_realloc(label_buffer, label_buffer_len); if (label_buffer == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (data_ptr + label_len > data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } retval = readstat_convert(label_buffer, label_buffer_len, data_ptr, label_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; data_ptr += label_len; readstat_value_t value = { .type = READSTAT_TYPE_STRING }; value.v.string_value = value_buffer; if (ctx->handle.value_label(label_name_buf, value, label_buffer, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } } if (data_ptr != data_end) { retval = READSTAT_ERROR_PARSE; } cleanup: if (value_buffer) free(value_buffer); if (label_buffer) free(label_buffer); return retval; } static readstat_error_t sav_parse_long_string_missing_values_record(const void *data, size_t size, size_t count, sav_ctx_t *ctx) { if (size != 1) return READSTAT_ERROR_PARSE; readstat_error_t retval = READSTAT_OK; uint32_t i = 0, j = 0; const char *data_ptr = data; const char *data_end = data_ptr + count; char var_name_buf[256+1]; while (data_ptr < data_end) { retval = sav_read_pascal_string(var_name_buf, sizeof(var_name_buf), &data_ptr, data_end - data_ptr, ctx); if (retval != READSTAT_OK) goto cleanup; if (data_ptr == data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } char n_missing_values = *data_ptr++; if (n_missing_values < 1 || n_missing_values > 3) { retval = READSTAT_ERROR_PARSE; goto cleanup; } for (i=0; ivar_index;) { spss_varinfo_t *info = ctx->varinfo[i]; if (strcmp(var_name_buf, info->longname) == 0) { info->n_missing_values = n_missing_values; uint32_t var_name_len = 0; if (data_ptr + sizeof(uint32_t) > data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } memcpy(&var_name_len, data_ptr, sizeof(uint32_t)); if (ctx->bswap) var_name_len = byteswap4(var_name_len); data_ptr += sizeof(uint32_t); for (j=0; j data_end) { retval = READSTAT_ERROR_PARSE; goto cleanup; } retval = readstat_convert(info->missing_string_values[j], sizeof(info->missing_string_values[0]), data_ptr, var_name_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; data_ptr += var_name_len; } break; } i += info->n_segments; } if (i == ctx->var_index) { retval = READSTAT_ERROR_PARSE; goto cleanup; } } if (data_ptr != data_end) { retval = READSTAT_ERROR_PARSE; } cleanup: return retval; } static readstat_error_t sav_parse_records_pass1(sav_ctx_t *ctx) { char data_buf[4096]; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; while (1) { uint32_t rec_type; uint32_t extra_info[3]; size_t data_len = 0; int i; int done = 0; if (io->read(&rec_type, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) { rec_type = byteswap4(rec_type); } switch (rec_type) { case SAV_RECORD_TYPE_VARIABLE: retval = sav_skip_variable_record(ctx); if (retval != READSTAT_OK) goto cleanup; break; case SAV_RECORD_TYPE_VALUE_LABEL: retval = sav_skip_value_label_record(ctx); if (retval != READSTAT_OK) goto cleanup; break; case SAV_RECORD_TYPE_DOCUMENT: retval = sav_skip_document_record(ctx); if (retval != READSTAT_OK) goto cleanup; break; case SAV_RECORD_TYPE_DICT_TERMINATION: done = 1; break; case SAV_RECORD_TYPE_HAS_DATA: if (io->read(extra_info, sizeof(extra_info), io->io_ctx) < sizeof(extra_info)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) { for (i=0; i<3; i++) extra_info[i] = byteswap4(extra_info[i]); } uint32_t subtype = extra_info[0]; size_t size = extra_info[1]; size_t count = extra_info[2]; data_len = size * count; if (subtype == SAV_RECORD_SUBTYPE_INTEGER_INFO) { if (data_len > sizeof(data_buf)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (io->read(data_buf, data_len, io->io_ctx) < data_len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } retval = sav_parse_machine_integer_info_record(data_buf, data_len, ctx); if (retval != READSTAT_OK) goto cleanup; } else { if (io->seek(data_len, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } } break; default: retval = READSTAT_ERROR_PARSE; goto cleanup; break; } if (done) break; } cleanup: return retval; } static readstat_error_t sav_parse_records_pass2(sav_ctx_t *ctx) { void *data_buf = NULL; size_t data_buf_capacity = 4096; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; if ((data_buf = readstat_malloc(data_buf_capacity)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } while (1) { uint32_t rec_type; uint32_t extra_info[3]; size_t data_len = 0; int i; int done = 0; if (io->read(&rec_type, sizeof(uint32_t), io->io_ctx) < sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) { rec_type = byteswap4(rec_type); } switch (rec_type) { case SAV_RECORD_TYPE_VARIABLE: if ((retval = sav_read_variable_record(ctx)) != READSTAT_OK) goto cleanup; break; case SAV_RECORD_TYPE_VALUE_LABEL: if ((retval = sav_read_value_label_record(ctx)) != READSTAT_OK) goto cleanup; break; case SAV_RECORD_TYPE_DOCUMENT: if ((retval = sav_read_document_record(ctx)) != READSTAT_OK) goto cleanup; break; case SAV_RECORD_TYPE_DICT_TERMINATION: if ((retval = sav_read_dictionary_termination_record(ctx)) != READSTAT_OK) goto cleanup; done = 1; break; case SAV_RECORD_TYPE_HAS_DATA: if (io->read(extra_info, sizeof(extra_info), io->io_ctx) < sizeof(extra_info)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (ctx->bswap) { for (i=0; i<3; i++) extra_info[i] = byteswap4(extra_info[i]); } uint32_t subtype = extra_info[0]; size_t size = extra_info[1]; size_t count = extra_info[2]; data_len = size * count; if (data_buf_capacity < data_len) { if ((data_buf = readstat_realloc(data_buf, data_buf_capacity = data_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } } if (data_len == 0 || io->read(data_buf, data_len, io->io_ctx) < data_len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } switch (subtype) { case SAV_RECORD_SUBTYPE_INTEGER_INFO: /* parsed in pass 1 */ break; case SAV_RECORD_SUBTYPE_FP_INFO: retval = sav_parse_machine_floating_point_record(data_buf, size, count, ctx); if (retval != READSTAT_OK) goto cleanup; break; case SAV_RECORD_SUBTYPE_VAR_DISPLAY: retval = sav_store_variable_display_parameter_record(data_buf, size, count, ctx); if (retval != READSTAT_OK) goto cleanup; break; case SAV_RECORD_SUBTYPE_LONG_VAR_NAME: retval = sav_parse_long_variable_names_record(data_buf, count, ctx); if (retval != READSTAT_OK) goto cleanup; break; case SAV_RECORD_SUBTYPE_VERY_LONG_STR: retval = sav_parse_very_long_string_record(data_buf, count, ctx); if (retval != READSTAT_OK) goto cleanup; break; case SAV_RECORD_SUBTYPE_LONG_STRING_VALUE_LABELS: retval = sav_parse_long_string_value_labels_record(data_buf, size, count, ctx); if (retval != READSTAT_OK) goto cleanup; break; case SAV_RECORD_SUBTYPE_LONG_STRING_MISSING_VALUES: retval = sav_parse_long_string_missing_values_record(data_buf, size, count, ctx); if (retval != READSTAT_OK) goto cleanup; break; default: /* misc. info */ break; } break; default: retval = READSTAT_ERROR_PARSE; goto cleanup; break; } if (done) break; } cleanup: if (data_buf) free(data_buf); return retval; } static readstat_error_t sav_set_n_segments_and_var_count(sav_ctx_t *ctx) { int i; ctx->var_count = 0; for (i=0; ivar_index;) { spss_varinfo_t *info = ctx->varinfo[i]; if (info->string_length > VERY_LONG_STRING_MAX_LENGTH) return READSTAT_ERROR_PARSE; if (info->string_length) { info->n_segments = (info->string_length + 251) / 252; } info->index = ctx->var_count++; i += info->n_segments; } ctx->variables = readstat_calloc(ctx->var_count, sizeof(readstat_variable_t *)); return READSTAT_OK; } static readstat_error_t sav_handle_variables(sav_ctx_t *ctx) { int i; int index_after_skipping = 0; readstat_error_t retval = READSTAT_OK; if (!ctx->handle.variable) return retval; for (i=0; ivar_index;) { char label_name_buf[256]; spss_varinfo_t *info = ctx->varinfo[i]; ctx->variables[info->index] = spss_init_variable_for_info(info, index_after_skipping, ctx->converter); snprintf(label_name_buf, sizeof(label_name_buf), SAV_LABEL_NAME_PREFIX "%d", info->labels_index); int cb_retval = ctx->handle.variable(info->index, ctx->variables[info->index], info->labels_index == -1 ? NULL : label_name_buf, ctx->user_ctx); if (cb_retval == READSTAT_HANDLER_ABORT) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } if (cb_retval == READSTAT_HANDLER_SKIP_VARIABLE) { ctx->variables[info->index]->skip = 1; } else { index_after_skipping++; } i += info->n_segments; } cleanup: return retval; } static readstat_error_t sav_handle_fweight(sav_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int i; if (ctx->handle.fweight && ctx->fweight_index >= 0) { for (i=0; ivar_index;) { spss_varinfo_t *info = ctx->varinfo[i]; if (info->offset == ctx->fweight_index - 1) { if (ctx->handle.fweight(ctx->variables[info->index], ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } break; } i += info->n_segments; } } cleanup: return retval; } readstat_error_t sav_parse_timestamp(sav_ctx_t *ctx, sav_file_header_record_t *header) { readstat_error_t retval = READSTAT_OK; struct tm timestamp = { .tm_isdst = -1 }; if ((retval = sav_parse_time(header->creation_time, sizeof(header->creation_time), ×tamp, ctx->handle.error, ctx->user_ctx)) != READSTAT_OK) goto cleanup; if ((retval = sav_parse_date(header->creation_date, sizeof(header->creation_date), ×tamp, ctx->handle.error, ctx->user_ctx)) != READSTAT_OK) goto cleanup; ctx->timestamp = mktime(×tamp); cleanup: return retval; } readstat_error_t readstat_parse_sav(readstat_parser_t *parser, const char *path, void *user_ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = parser->io; sav_file_header_record_t header; sav_ctx_t *ctx = NULL; size_t file_size = 0; if (io->open(path, io->io_ctx) == -1) { return READSTAT_ERROR_OPEN; } file_size = io->seek(0, READSTAT_SEEK_END, io->io_ctx); if (file_size == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->seek(0, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->read(&header, sizeof(sav_file_header_record_t), io->io_ctx) < sizeof(sav_file_header_record_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } ctx = sav_ctx_init(&header, io); if (ctx == NULL) { retval = READSTAT_ERROR_PARSE; goto cleanup; } ctx->handle = parser->handlers; ctx->input_encoding = parser->input_encoding; ctx->output_encoding = parser->output_encoding; ctx->user_ctx = user_ctx; ctx->file_size = file_size; if (parser->row_offset > 0) ctx->row_offset = parser->row_offset; if (ctx->record_count >= 0) { int record_count_after_skipping = ctx->record_count - ctx->row_offset; if (record_count_after_skipping < 0) { record_count_after_skipping = 0; ctx->row_offset = ctx->record_count; } ctx->row_limit = record_count_after_skipping; if (parser->row_limit > 0 && parser->row_limit < record_count_after_skipping) ctx->row_limit = parser->row_limit; } else if (parser->row_limit > 0) { ctx->row_limit = parser->row_limit; } /* ignore errors */ sav_parse_timestamp(ctx, &header); if ((retval = sav_parse_records_pass1(ctx)) != READSTAT_OK) goto cleanup; if (io->seek(sizeof(sav_file_header_record_t), READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if ((retval = sav_update_progress(ctx)) != READSTAT_OK) goto cleanup; if ((retval = sav_parse_records_pass2(ctx)) != READSTAT_OK) goto cleanup; if ((retval = sav_set_n_segments_and_var_count(ctx)) != READSTAT_OK) goto cleanup; if (ctx->var_count == 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (ctx->handle.metadata) { readstat_metadata_t metadata = { .row_count = ctx->record_count < 0 ? -1 : ctx->row_limit, .var_count = ctx->var_count, .file_encoding = ctx->input_encoding, .file_format_version = ctx->format_version, .creation_time = ctx->timestamp, .modified_time = ctx->timestamp, .compression = ctx->compression, .endianness = ctx->endianness }; if ((retval = readstat_convert(ctx->file_label, sizeof(ctx->file_label), header.file_label, sizeof(header.file_label), ctx->converter)) != READSTAT_OK) goto cleanup; metadata.file_label = ctx->file_label; if (ctx->handle.metadata(&metadata, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } if ((retval = sav_parse_variable_display_parameter_record(ctx)) != READSTAT_OK) goto cleanup; if ((retval = sav_handle_variables(ctx)) != READSTAT_OK) goto cleanup; if ((retval = sav_handle_fweight(ctx)) != READSTAT_OK) goto cleanup; if (ctx->handle.value) { retval = sav_read_data(ctx); } cleanup: io->close(io->io_ctx); if (ctx) sav_ctx_free(ctx); return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_sav_write.c0000644023477200000240000014535414574360757021456 0ustar00fajardoostaffs #include #include #include #include #include #include #include #include #include #include "../readstat.h" #include "../readstat_iconv.h" #include "../readstat_bits.h" #include "../readstat_malloc.h" #include "../readstat_writer.h" #include "../CKHashTable.h" #include "readstat_sav.h" #include "readstat_sav_compress.h" #include "readstat_spss_parse.h" #if HAVE_ZLIB #include #include "readstat_zsav_compress.h" #include "readstat_zsav_write.h" #endif #define MAX_STRING_SIZE 255 #define MAX_LABEL_SIZE 256 #define MAX_VALUE_LABEL_SIZE 120 typedef struct sav_varnames_s { char shortname[9]; char stem[6]; } sav_varnames_t; static long readstat_label_set_number_short_variables(readstat_label_set_t *r_label_set) { long count = 0; int j; for (j=0; jvariables_count; j++) { readstat_variable_t *r_variable = readstat_get_label_set_variable(r_label_set, j); if (r_variable->storage_width <= 8) { count++; } } return count; } static int readstat_label_set_needs_short_value_labels_record(readstat_label_set_t *r_label_set) { return readstat_label_set_number_short_variables(r_label_set) > 0; } static int readstat_label_set_needs_long_value_labels_record(readstat_label_set_t *r_label_set) { return readstat_label_set_number_short_variables(r_label_set) < r_label_set->variables_count; } static int32_t sav_encode_format(spss_format_t *spss_format) { uint8_t width = spss_format->width > 0xff ? 0xff : spss_format->width; return ((spss_format->type << 16) | (width << 8) | spss_format->decimal_places); } static readstat_error_t sav_encode_base_variable_format(readstat_variable_t *r_variable, int32_t *out_code) { spss_format_t spss_format; readstat_error_t retval = spss_format_for_variable(r_variable, &spss_format); if (retval == READSTAT_OK && out_code) *out_code = sav_encode_format(&spss_format); return retval; } static readstat_error_t sav_encode_ghost_variable_format(readstat_variable_t *r_variable, size_t user_width, int32_t *out_code) { spss_format_t spss_format; readstat_error_t retval = spss_format_for_variable(r_variable, &spss_format); spss_format.width = user_width; if (retval == READSTAT_OK && out_code) *out_code = sav_encode_format(&spss_format); return retval; } static size_t sav_format_variable_name(char *output, size_t output_len, sav_varnames_t *varnames) { snprintf(output, output_len, "%s", varnames->shortname); return strlen(output); } static size_t sav_format_ghost_variable_name(char *output, size_t output_len, sav_varnames_t *varnames, unsigned int segment) { snprintf(output, output_len, "%s", varnames->stem); size_t len = strlen(output); int letter = segment % 36; if (letter < 10) { output[len++] = '0' + letter; } else { output[len++] = 'A' + (letter - 10); } return len; } static int sav_variable_segments(readstat_type_t type, size_t user_width) { if (type == READSTAT_TYPE_STRING && user_width > MAX_STRING_SIZE) { return (user_width + 251) / 252; } return 1; } static readstat_error_t sav_emit_header(readstat_writer_t *writer) { sav_file_header_record_t header = { { 0 } }; readstat_error_t retval = READSTAT_OK; time_t now = writer->timestamp; struct tm *time_s = localtime(&now); /* There are portability issues with strftime so hack something up */ char months[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; char creation_date[sizeof(header.creation_date)+1] = { 0 }; char creation_time[sizeof(header.creation_time)+1] = { 0 }; if (!time_s) { retval = READSTAT_ERROR_BAD_TIMESTAMP_VALUE; goto cleanup; } memcpy(header.rec_type, "$FL2", sizeof("$FL2")-1); if (writer->compression == READSTAT_COMPRESS_BINARY) { header.rec_type[3] = '3'; } memset(header.prod_name, ' ', sizeof(header.prod_name)); memcpy(header.prod_name, "@(#) SPSS DATA FILE - " READSTAT_PRODUCT_URL, sizeof("@(#) SPSS DATA FILE - " READSTAT_PRODUCT_URL)-1); header.layout_code = 2; header.nominal_case_size = writer->row_len / 8; if (writer->compression == READSTAT_COMPRESS_ROWS) { header.compression = 1; } else if (writer->compression == READSTAT_COMPRESS_BINARY) { header.compression = 2; } if (writer->fweight_variable) { int32_t dictionary_index = 1 + writer->fweight_variable->offset / 8; header.weight_index = dictionary_index; } else { header.weight_index = 0; } header.ncases = writer->row_count; header.bias = 100.0; snprintf(creation_date, sizeof(creation_date), "%02d %3.3s %02d", (unsigned int)time_s->tm_mday % 100, months[time_s->tm_mon], (unsigned int)time_s->tm_year % 100); memcpy(header.creation_date, creation_date, sizeof(header.creation_date)); snprintf(creation_time, sizeof(creation_time), "%02d:%02d:%02d", (unsigned int)time_s->tm_hour % 100, (unsigned int)time_s->tm_min % 100, (unsigned int)time_s->tm_sec % 100); memcpy(header.creation_time, creation_time, sizeof(header.creation_time)); memset(header.file_label, ' ', sizeof(header.file_label)); size_t file_label_len = strlen(writer->file_label); if (file_label_len > sizeof(header.file_label)) file_label_len = sizeof(header.file_label); if (writer->file_label[0]) memcpy(header.file_label, writer->file_label, file_label_len); retval = readstat_write_bytes(writer, &header, sizeof(header)); cleanup: return retval; } static readstat_error_t sav_emit_variable_label(readstat_writer_t *writer, readstat_variable_t *r_variable) { readstat_error_t retval = READSTAT_OK; const char *title_data = r_variable->label; size_t title_data_len = strlen(title_data); if (title_data_len > 0) { char padded_label[MAX_LABEL_SIZE]; uint32_t label_len = title_data_len; if (label_len > sizeof(padded_label)) label_len = sizeof(padded_label); retval = readstat_write_bytes(writer, &label_len, sizeof(label_len)); if (retval != READSTAT_OK) goto cleanup; strncpy(padded_label, title_data, (label_len + 3) / 4 * 4); retval = readstat_write_bytes(writer, padded_label, (label_len + 3) / 4 * 4); if (retval != READSTAT_OK) goto cleanup; } cleanup: return retval; } static int sav_n_missing_double_values(readstat_variable_t *r_variable) { int n_missing_ranges = readstat_variable_get_missing_ranges_count(r_variable); int n_missing_values = n_missing_ranges; int has_missing_range = 0; int j; for (j=0; j 3) { return READSTAT_ERROR_TOO_MANY_MISSING_VALUE_DEFINITIONS; } if (out_n_missing_values) *out_n_missing_values = n_missing_values; return READSTAT_OK; } static readstat_error_t sav_emit_variable_missing_string_values(readstat_writer_t *writer, readstat_variable_t *r_variable) { readstat_error_t retval = READSTAT_OK; int n_missing_values = 0; int n_missing_ranges = readstat_variable_get_missing_ranges_count(r_variable); /* ranges */ int j; for (j=0; jtype == READSTAT_TYPE_STRING) { variable.type = r_variable->user_width > MAX_STRING_SIZE ? MAX_STRING_SIZE : r_variable->user_width; } variable.has_var_label = (r_variable->label[0] != '\0'); retval = sav_n_missing_values(&variable.n_missing_values, r_variable); if (retval != READSTAT_OK) goto cleanup; retval = sav_encode_base_variable_format(r_variable, &variable.print); if (retval != READSTAT_OK) goto cleanup; variable.write = variable.print; memset(variable.name, ' ', sizeof(variable.name)); if (name_data_len > 0 && name_data_len <= sizeof(variable.name)) memcpy(variable.name, name_data, name_data_len); retval = readstat_write_bytes(writer, &variable, sizeof(variable)); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_variable_label(writer, r_variable); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_variable_missing_values(writer, r_variable); if (retval != READSTAT_OK) goto cleanup; int extra_fields = r_variable->storage_width / 8 - 1; if (extra_fields > 31) extra_fields = 31; retval = sav_emit_blank_variable_records(writer, extra_fields); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t sav_emit_ghost_variable_record(readstat_writer_t *writer, readstat_variable_t *r_variable, sav_varnames_t *varnames, int segment, size_t user_width) { readstat_error_t retval = READSTAT_OK; int32_t rec_type = SAV_RECORD_TYPE_VARIABLE; sav_variable_record_t variable = { 0 }; char name_data[9]; size_t name_len = sav_format_ghost_variable_name(name_data, sizeof(name_data), varnames, segment); retval = readstat_write_bytes(writer, &rec_type, sizeof(rec_type)); if (retval != READSTAT_OK) goto cleanup; variable.type = user_width; retval = sav_encode_ghost_variable_format(r_variable, user_width, &variable.print); if (retval != READSTAT_OK) goto cleanup; variable.write = variable.print; memset(variable.name, ' ', sizeof(variable.name)); if (name_len > 0 && name_len <= sizeof(variable.name)) memcpy(variable.name, name_data, name_len); retval = readstat_write_bytes(writer, &variable, sizeof(variable)); if (retval != READSTAT_OK) goto cleanup; int extra_fields = (user_width + 7) / 8 - 1; if (extra_fields > 31) extra_fields = 31; retval = sav_emit_blank_variable_records(writer, extra_fields); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t sav_emit_full_variable_record(readstat_writer_t *writer, readstat_variable_t *r_variable, sav_varnames_t *varnames) { readstat_error_t retval = READSTAT_OK; retval = sav_emit_base_variable_record(writer, r_variable, varnames); if (retval != READSTAT_OK) goto cleanup; int n_segments = sav_variable_segments(r_variable->type, r_variable->user_width); int i; for (i=1; iuser_width - (n_segments - 1) * 252); } retval = sav_emit_ghost_variable_record(writer, r_variable, varnames, i, storage_size); if (retval != READSTAT_OK) goto cleanup; } cleanup: return retval; } static readstat_error_t sav_emit_variable_records(readstat_writer_t *writer, sav_varnames_t *varnames) { readstat_error_t retval = READSTAT_OK; int i; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); retval = sav_emit_full_variable_record(writer, r_variable, &varnames[i]); if (retval != READSTAT_OK) goto cleanup; } cleanup: return retval; } static readstat_error_t sav_emit_value_label_records(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; int i, j; for (i=0; ilabel_sets_count; i++) { readstat_label_set_t *r_label_set = readstat_get_label_set(writer, i); if (!readstat_label_set_needs_short_value_labels_record(r_label_set)) continue; readstat_type_t user_type = r_label_set->type; int32_t label_count = r_label_set->value_labels_count; int32_t rec_type = 0; if (label_count) { rec_type = SAV_RECORD_TYPE_VALUE_LABEL; retval = readstat_write_bytes(writer, &rec_type, sizeof(rec_type)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &label_count, sizeof(label_count)); if (retval != READSTAT_OK) goto cleanup; for (j=0; jstring_key_len; if (key_len > sizeof(value)) key_len = sizeof(value); memset(value, ' ', sizeof(value)); memcpy(value, r_value_label->string_key, key_len); } else if (user_type == READSTAT_TYPE_DOUBLE) { double num_val = r_value_label->double_key; memcpy(value, &num_val, sizeof(double)); } else if (user_type == READSTAT_TYPE_INT32) { double num_val = r_value_label->int32_key; memcpy(value, &num_val, sizeof(double)); } retval = readstat_write_bytes(writer, value, sizeof(value)); const char *label_data = r_value_label->label; uint8_t label_len = MAX_VALUE_LABEL_SIZE; if (label_len > r_value_label->label_len) label_len = r_value_label->label_len; retval = readstat_write_bytes(writer, &label_len, sizeof(label_len)); if (retval != READSTAT_OK) goto cleanup; char label[MAX_VALUE_LABEL_SIZE+8]; memset(label, ' ', sizeof(label)); memcpy(label, label_data, label_len); retval = readstat_write_bytes(writer, label, (label_len + sizeof(label_len) + 7) / 8 * 8 - sizeof(label_len)); if (retval != READSTAT_OK) goto cleanup; } rec_type = SAV_RECORD_TYPE_VALUE_LABEL_VARIABLES; int32_t var_count = readstat_label_set_number_short_variables(r_label_set); retval = readstat_write_bytes(writer, &rec_type, sizeof(rec_type)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &var_count, sizeof(var_count)); if (retval != READSTAT_OK) goto cleanup; for (j=0; jvariables_count; j++) { readstat_variable_t *r_variable = readstat_get_label_set_variable(r_label_set, j); if (r_variable->storage_width > 8) continue; int32_t dictionary_index = 1 + r_variable->offset / 8; retval = readstat_write_bytes(writer, &dictionary_index, sizeof(dictionary_index)); if (retval != READSTAT_OK) goto cleanup; } } } cleanup: return retval; } static readstat_error_t sav_emit_document_record(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; int32_t rec_type = SAV_RECORD_TYPE_DOCUMENT; int32_t n_lines = writer->notes_count; if (n_lines == 0) goto cleanup; retval = readstat_write_bytes(writer, &rec_type, sizeof(rec_type)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &n_lines, sizeof(n_lines)); if (retval != READSTAT_OK) goto cleanup; int i; for (i=0; inotes_count; i++) { size_t len = strlen(writer->notes[i]); if (len > SPSS_DOC_LINE_SIZE) { retval = READSTAT_ERROR_NOTE_IS_TOO_LONG; goto cleanup; } retval = readstat_write_bytes(writer, writer->notes[i], len); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_spaces(writer, SPSS_DOC_LINE_SIZE - len); if (retval != READSTAT_OK) goto cleanup; } cleanup: return retval; } static readstat_error_t sav_emit_integer_info_record(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; sav_info_record_t info_header = { .rec_type = SAV_RECORD_TYPE_HAS_DATA, .subtype = SAV_RECORD_SUBTYPE_INTEGER_INFO, .size = 4, .count = 8 }; sav_machine_integer_info_record_t machine_info = { .version_major = 20, .version_minor = 0, .version_revision = 0, .machine_code = -1, .floating_point_rep = SAV_FLOATING_POINT_REP_IEEE, .compression_code = 1, .endianness = machine_is_little_endian() ? SAV_ENDIANNESS_LITTLE : SAV_ENDIANNESS_BIG, .character_code = 65001 // UTF-8 }; retval = readstat_write_bytes(writer, &info_header, sizeof(info_header)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &machine_info, sizeof(machine_info)); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t sav_emit_floating_point_info_record(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; sav_info_record_t info_header = { .rec_type = SAV_RECORD_TYPE_HAS_DATA, .subtype = SAV_RECORD_SUBTYPE_FP_INFO, .size = 8, .count = 3 }; retval = readstat_write_bytes(writer, &info_header, sizeof(info_header)); if (retval != READSTAT_OK) goto cleanup; sav_machine_floating_point_info_record_t fp_info = {0}; fp_info.sysmis = SAV_MISSING_DOUBLE; fp_info.highest = SAV_HIGHEST_DOUBLE; fp_info.lowest = SAV_LOWEST_DOUBLE; retval = readstat_write_bytes(writer, &fp_info, sizeof(fp_info)); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t sav_emit_variable_display_record(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; int i; sav_info_record_t info_header = { .rec_type = SAV_RECORD_TYPE_HAS_DATA, .subtype = SAV_RECORD_SUBTYPE_VAR_DISPLAY, .size = sizeof(int32_t) }; int total_segments = 0; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); total_segments += sav_variable_segments(r_variable->type, r_variable->user_width); } info_header.count = 3 * total_segments; retval = readstat_write_bytes(writer, &info_header, sizeof(info_header)); if (retval != READSTAT_OK) goto cleanup; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); readstat_measure_t measure = readstat_variable_get_measure(r_variable); int32_t sav_measure = spss_measure_from_readstat_measure(measure); int32_t sav_display_width = readstat_variable_get_display_width(r_variable); if (sav_display_width <= 0) sav_display_width = 8; readstat_alignment_t alignment = readstat_variable_get_alignment(r_variable); int32_t sav_alignment = spss_alignment_from_readstat_alignment(alignment); int n_segments = sav_variable_segments(r_variable->type, r_variable->user_width); while (n_segments--) { retval = readstat_write_bytes(writer, &sav_measure, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &sav_display_width, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &sav_alignment, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; } } cleanup: return retval; } static readstat_error_t sav_emit_long_var_name_record(readstat_writer_t *writer, sav_varnames_t *varnames) { readstat_error_t retval = READSTAT_OK; int i; sav_info_record_t info_header = { .rec_type = SAV_RECORD_TYPE_HAS_DATA, .subtype = SAV_RECORD_SUBTYPE_LONG_VAR_NAME, .size = 1, .count = 0 }; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); char name_data[9]; size_t name_data_len = sav_format_variable_name(name_data, sizeof(name_data), &varnames[i]); const char *title_data = r_variable->name; size_t title_data_len = strlen(title_data); if (title_data_len > 0 && name_data_len > 0) { if (title_data_len > 64) title_data_len = 64; info_header.count += name_data_len; info_header.count += sizeof("=")-1; info_header.count += title_data_len; info_header.count += sizeof("\x09")-1; } } if (info_header.count > 0) { info_header.count--; /* no trailing 0x09 */ retval = readstat_write_bytes(writer, &info_header, sizeof(info_header)); if (retval != READSTAT_OK) goto cleanup; int is_first = 1; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); char name_data[9]; sav_format_variable_name(name_data, sizeof(name_data), &varnames[i]); const char *title_data = r_variable->name; size_t title_data_len = strlen(title_data); char kv_separator = '='; char tuple_separator = 0x09; if (title_data_len > 0) { if (title_data_len > 64) title_data_len = 64; if (!is_first) { retval = readstat_write_bytes(writer, &tuple_separator, sizeof(tuple_separator)); if (retval != READSTAT_OK) goto cleanup; } retval = readstat_write_string(writer, name_data); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &kv_separator, sizeof(kv_separator)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, title_data, title_data_len); if (retval != READSTAT_OK) goto cleanup; is_first = 0; } } } cleanup: return retval; } static readstat_error_t sav_emit_very_long_string_record(readstat_writer_t *writer, sav_varnames_t *varnames) { readstat_error_t retval = READSTAT_OK; int i; char tuple_separator[2] = { 0x00, 0x09 }; sav_info_record_t info_header = { .rec_type = SAV_RECORD_TYPE_HAS_DATA, .subtype = SAV_RECORD_SUBTYPE_VERY_LONG_STR, .size = 1, .count = 0 }; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); if (r_variable->user_width <= MAX_STRING_SIZE) continue; char name_data[9]; sav_format_variable_name(name_data, sizeof(name_data), &varnames[i]); char kv_data[8+1+5+1]; snprintf(kv_data, sizeof(kv_data), "%.8s=%d", name_data, (unsigned int)r_variable->user_width % 100000); info_header.count += strlen(kv_data) + sizeof(tuple_separator); } if (info_header.count == 0) return READSTAT_OK; retval = readstat_write_bytes(writer, &info_header, sizeof(info_header)); if (retval != READSTAT_OK) goto cleanup; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); if (r_variable->user_width <= MAX_STRING_SIZE) continue; char name_data[9]; sav_format_variable_name(name_data, sizeof(name_data), &varnames[i]); char kv_data[8+1+5+1]; snprintf(kv_data, sizeof(kv_data), "%.8s=%d", name_data, (unsigned int)r_variable->user_width % 100000); retval = readstat_write_string(writer, kv_data); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, tuple_separator, sizeof(tuple_separator)); if (retval != READSTAT_OK) goto cleanup; } cleanup: return retval; } static readstat_error_t sav_emit_long_string_value_labels_record(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; int i, j, k; char *space_buffer = NULL; sav_info_record_t info_header = { .rec_type = SAV_RECORD_TYPE_HAS_DATA, .subtype = SAV_RECORD_SUBTYPE_LONG_STRING_VALUE_LABELS, .size = 1, .count = 0 }; for (i=0; ilabel_sets_count; i++) { readstat_label_set_t *r_label_set = readstat_get_label_set(writer, i); if (!readstat_label_set_needs_long_value_labels_record(r_label_set)) continue; int32_t label_count = r_label_set->value_labels_count; int32_t var_count = r_label_set->variables_count; for (k=0; kname); int32_t storage_width = readstat_variable_get_storage_width(r_variable); if (storage_width <= 8) continue; info_header.count += sizeof(int32_t); // name length info_header.count += name_len; info_header.count += sizeof(int32_t); // variable width info_header.count += sizeof(int32_t); // label count for (j=0; jlabel_len; if (label_len > MAX_VALUE_LABEL_SIZE) label_len = MAX_VALUE_LABEL_SIZE; info_header.count += sizeof(int32_t); // value length info_header.count += storage_width; info_header.count += sizeof(int32_t); // label length info_header.count += label_len; } } } if (info_header.count == 0) goto cleanup; retval = readstat_write_bytes(writer, &info_header, sizeof(info_header)); if (retval != READSTAT_OK) goto cleanup; for (i=0; ilabel_sets_count; i++) { readstat_label_set_t *r_label_set = readstat_get_label_set(writer, i); if (!readstat_label_set_needs_long_value_labels_record(r_label_set)) continue; int32_t label_count = r_label_set->value_labels_count; int32_t var_count = r_label_set->variables_count; for (k=0; kname); int32_t storage_width = readstat_variable_get_storage_width(r_variable); if (storage_width <= 8) continue; space_buffer = realloc(space_buffer, storage_width); memset(space_buffer, ' ', storage_width); retval = readstat_write_bytes(writer, &name_len, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, r_variable->name, name_len); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &storage_width, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &label_count, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; for (j=0; jstring_key_len; int32_t label_len = r_value_label->label_len; if (label_len > MAX_VALUE_LABEL_SIZE) label_len = MAX_VALUE_LABEL_SIZE; retval = readstat_write_bytes(writer, &storage_width, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, r_value_label->string_key, value_len); if (retval != READSTAT_OK) goto cleanup; if (value_len < storage_width) { retval = readstat_write_bytes(writer, space_buffer, storage_width - value_len); if (retval != READSTAT_OK) goto cleanup; } retval = readstat_write_bytes(writer, &label_len, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, r_value_label->label, label_len); if (retval != READSTAT_OK) goto cleanup; } } } cleanup: if (space_buffer) free(space_buffer); return retval; } static readstat_error_t sav_emit_long_string_missing_values_record(readstat_writer_t *writer) { readstat_error_t retval = READSTAT_OK; int j, k; sav_info_record_t info_header = { .rec_type = SAV_RECORD_TYPE_HAS_DATA, .subtype = SAV_RECORD_SUBTYPE_LONG_STRING_MISSING_VALUES, .size = 1, .count = 0 }; int32_t var_count = writer->variables_count; for (k=0; kname); int32_t storage_width = readstat_variable_get_storage_width(r_variable); if (storage_width <= 8) continue; int n_missing_values = 0; for (j=0; jname); int8_t n_missing_values = 0; int32_t storage_width = readstat_variable_get_storage_width(r_variable); if (storage_width <= 8) continue; for (j=0; jname, name_len); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &n_missing_values, sizeof(int8_t)); if (retval != READSTAT_OK) goto cleanup; uint32_t value_len = 8; retval = readstat_write_bytes(writer, &value_len, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; for (j=0; jrow_count; retval = readstat_write_bytes(writer, &info_header, sizeof(sav_info_record_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &one, sizeof(uint64_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &ncases, sizeof(uint64_t)); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t sav_emit_termination_record(readstat_writer_t *writer) { sav_dictionary_termination_record_t termination_record = { .rec_type = SAV_RECORD_TYPE_DICT_TERMINATION }; return readstat_write_bytes(writer, &termination_record, sizeof(termination_record)); } static readstat_error_t sav_write_int8(void *row, const readstat_variable_t *var, int8_t value) { double dval = value; memcpy(row, &dval, sizeof(double)); return READSTAT_OK; } static readstat_error_t sav_write_int16(void *row, const readstat_variable_t *var, int16_t value) { double dval = value; memcpy(row, &dval, sizeof(double)); return READSTAT_OK; } static readstat_error_t sav_write_int32(void *row, const readstat_variable_t *var, int32_t value) { double dval = value; memcpy(row, &dval, sizeof(double)); return READSTAT_OK; } static readstat_error_t sav_write_float(void *row, const readstat_variable_t *var, float value) { double dval = value; memcpy(row, &dval, sizeof(double)); return READSTAT_OK; } static readstat_error_t sav_write_double(void *row, const readstat_variable_t *var, double value) { double dval = value; memcpy(row, &dval, sizeof(double)); return READSTAT_OK; } static readstat_error_t sav_write_string(void *row, const readstat_variable_t *var, const char *value) { memset(row, ' ', var->storage_width); if (value != NULL && value[0] != '\0') { size_t value_len = strlen(value); off_t row_offset = 0; off_t val_offset = 0; unsigned char *row_bytes = (unsigned char *)row; if (value_len > var->storage_width) return READSTAT_ERROR_STRING_VALUE_IS_TOO_LONG; while (value_len - val_offset > 255) { memcpy(&row_bytes[row_offset], &value[val_offset], 255); row_offset += 256; val_offset += 255; } memcpy(&row_bytes[row_offset], &value[val_offset], value_len - val_offset); } return READSTAT_OK; } static readstat_error_t sav_write_missing_string(void *row, const readstat_variable_t *var) { memset(row, ' ', var->storage_width); return READSTAT_OK; } static readstat_error_t sav_write_missing_number(void *row, const readstat_variable_t *var) { uint64_t missing_val = SAV_MISSING_DOUBLE; memcpy(row, &missing_val, sizeof(uint64_t)); return READSTAT_OK; } static size_t sav_variable_width(readstat_type_t type, size_t user_width) { if (type == READSTAT_TYPE_STRING) { if (user_width > MAX_STRING_SIZE) { size_t n_segments = sav_variable_segments(type, user_width); size_t last_segment_width = ((user_width - (n_segments - 1) * 252) + 7)/8*8; return (n_segments-1)*256 + last_segment_width; } if (user_width == 0) { return 8; } return (user_width + 7) / 8 * 8; } return 8; } static readstat_error_t sav_validate_name_chars(const char *name, int unicode) { /* TODO check Unicode class */ int j; for (j=0; name[j]; j++) { if (name[j] == ' ') return READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER; if (((unsigned char)name[j] < 0x80 || !unicode) && name[j] != '@' && name[j] != '.' && name[j] != '_' && name[j] != '$' && name[j] != '#' && !(name[j] >= 'a' && name[j] <= 'z') && !(name[j] >= 'A' && name[j] <= 'Z') && !(name[j] >= '0' && name[j] <= '9')) { return READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER; } } char first_char = name[0]; if (((unsigned char)first_char < 0x80 || !unicode) && first_char != '@' && !(first_char >= 'a' && first_char <= 'z') && !(first_char >= 'A' && first_char <= 'Z')) { return READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER; } return READSTAT_OK; } static readstat_error_t sav_validate_name_unreserved(const char *name) { if (strcmp(name, "ALL") == 0 || strcmp(name, "AND") == 0 || strcmp(name, "BY") == 0 || strcmp(name, "EQ") == 0 || strcmp(name, "GE") == 0 || strcmp(name, "GT") == 0 || strcmp(name, "GT") == 0 || strcmp(name, "LE") == 0 || strcmp(name, "LT") == 0 || strcmp(name, "NE") == 0 || strcmp(name, "NOT") == 0 || strcmp(name, "OR") == 0 || strcmp(name, "TO") == 0 || strcmp(name, "WITH") == 0) return READSTAT_ERROR_NAME_IS_RESERVED_WORD; return READSTAT_OK; } static readstat_error_t sav_validate_name_length(size_t name_len) { if (name_len > 64) return READSTAT_ERROR_NAME_IS_TOO_LONG; if (name_len == 0) return READSTAT_ERROR_NAME_IS_ZERO_LENGTH; return READSTAT_OK; } static readstat_error_t sav_variable_ok(const readstat_variable_t *variable) { readstat_error_t error = READSTAT_OK; error = sav_validate_name_length(strlen(variable->name)); if (error != READSTAT_OK) return error; error = sav_validate_name_unreserved(variable->name); if (error != READSTAT_OK) return error; return sav_validate_name_chars(variable->name, 1); } static sav_varnames_t *sav_varnames_init(readstat_writer_t *writer) { sav_varnames_t *varnames = calloc(writer->variables_count, sizeof(sav_varnames_t)); ck_hash_table_t *table = ck_hash_table_init(writer->variables_count, 8); int i, k; for (i=0; ivariables_count; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); const char *name = r_variable->name; char *shortname = varnames[i].shortname; char *stem = varnames[i].stem; snprintf(shortname, sizeof(varnames[0].shortname), "%.8s", name); for (k=0; shortname[k]; k++) { // upcase shortname[k] = toupper(shortname[k]); } if (ck_str_hash_lookup(shortname, table)) { snprintf(shortname, sizeof(varnames[0].shortname), "V%d_A", ((unsigned int)i+1)%100000); } ck_str_hash_insert(shortname, r_variable, table); if (r_variable->user_width <= MAX_STRING_SIZE) continue; snprintf(stem, sizeof(varnames[0].stem), "%.5s", shortname); // conflict resolution? } ck_hash_table_free(table); return varnames; } static readstat_error_t sav_begin_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; readstat_error_t retval = READSTAT_OK; if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; sav_varnames_t *varnames = sav_varnames_init(writer); retval = sav_emit_header(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_variable_records(writer, varnames); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_value_label_records(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_document_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_integer_info_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_floating_point_info_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_variable_display_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_long_var_name_record(writer, varnames); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_very_long_string_record(writer, varnames); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_long_string_value_labels_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_long_string_missing_values_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_number_of_cases_record(writer); if (retval != READSTAT_OK) goto cleanup; retval = sav_emit_termination_record(writer); if (retval != READSTAT_OK) goto cleanup; cleanup: free(varnames); if (retval == READSTAT_OK) { size_t row_bound = sav_compressed_row_bound(writer->row_len); if (writer->compression == READSTAT_COMPRESS_ROWS) { writer->module_ctx = readstat_malloc(row_bound); #if HAVE_ZLIB } else if (writer->compression == READSTAT_COMPRESS_BINARY) { writer->module_ctx = zsav_ctx_init(row_bound, writer->bytes_written); #endif } } return retval; } static readstat_error_t sav_write_compressed_row(void *writer_ctx, void *row, size_t len) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; unsigned char *output = writer->module_ctx; size_t output_offset = sav_compress_row(output, row, len, writer); return readstat_write_bytes(writer, output, output_offset); } static readstat_error_t sav_metadata_ok(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; if (writer->version == 2 && writer->compression == READSTAT_COMPRESS_BINARY) return READSTAT_ERROR_UNSUPPORTED_COMPRESSION; if (writer->version != 2 && writer->version != 3) return READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION; return READSTAT_OK; } readstat_error_t readstat_begin_writing_sav(readstat_writer_t *writer, void *user_ctx, long row_count) { writer->callbacks.metadata_ok = &sav_metadata_ok; writer->callbacks.variable_width = &sav_variable_width; writer->callbacks.variable_ok = &sav_variable_ok; writer->callbacks.write_int8 = &sav_write_int8; writer->callbacks.write_int16 = &sav_write_int16; writer->callbacks.write_int32 = &sav_write_int32; writer->callbacks.write_float = &sav_write_float; writer->callbacks.write_double = &sav_write_double; writer->callbacks.write_string = &sav_write_string; writer->callbacks.write_missing_string = &sav_write_missing_string; writer->callbacks.write_missing_number = &sav_write_missing_number; writer->callbacks.begin_data = &sav_begin_data; if (writer->version == 3) { writer->compression = READSTAT_COMPRESS_BINARY; } else if (writer->version == 0) { writer->version = (writer->compression == READSTAT_COMPRESS_BINARY) ? 3 : 2; } if (writer->compression == READSTAT_COMPRESS_ROWS) { writer->callbacks.write_row = &sav_write_compressed_row; writer->callbacks.module_ctx_free = &free; #if HAVE_ZLIB } else if (writer->compression == READSTAT_COMPRESS_BINARY) { writer->callbacks.write_row = &zsav_write_compressed_row; writer->callbacks.end_data = &zsav_end_data; writer->callbacks.module_ctx_free = (readstat_module_ctx_free_callback)&zsav_ctx_free; #endif } else if (writer->compression == READSTAT_COMPRESS_NONE) { /* void */ } else { return READSTAT_ERROR_UNSUPPORTED_COMPRESSION; } return readstat_begin_writing_file(writer, user_ctx, row_count); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_spss.c0000644023477200000240000002151314574360757020431 0ustar00fajardoostaffs #include #include #include "../readstat.h" #include "../readstat_iconv.h" #include "../readstat_convert.h" #include "readstat_spss.h" #include "readstat_spss_parse.h" static char spss_type_strings[][16] = { [SPSS_FORMAT_TYPE_A] = "A", [SPSS_FORMAT_TYPE_AHEX] = "AHEX", [SPSS_FORMAT_TYPE_COMMA] = "COMMA", [SPSS_FORMAT_TYPE_DOLLAR] = "DOLLAR", [SPSS_FORMAT_TYPE_F] = "F", [SPSS_FORMAT_TYPE_IB] = "IB", [SPSS_FORMAT_TYPE_PIBHEX] = "PIBHEX", [SPSS_FORMAT_TYPE_P] = "P", [SPSS_FORMAT_TYPE_PIB] = "PIB", [SPSS_FORMAT_TYPE_PK] = "PK", [SPSS_FORMAT_TYPE_RB] = "RB", [SPSS_FORMAT_TYPE_RBHEX] = "RBHEX", [SPSS_FORMAT_TYPE_Z] = "Z", [SPSS_FORMAT_TYPE_N] = "N", [SPSS_FORMAT_TYPE_E] = "E", [SPSS_FORMAT_TYPE_DATE] = "DATE", [SPSS_FORMAT_TYPE_TIME] = "TIME", [SPSS_FORMAT_TYPE_DATETIME] = "DATETIME", [SPSS_FORMAT_TYPE_ADATE] = "ADATE", [SPSS_FORMAT_TYPE_JDATE] = "JDATE", [SPSS_FORMAT_TYPE_DTIME] = "DTIME", [SPSS_FORMAT_TYPE_WKDAY] = "WKDAY", [SPSS_FORMAT_TYPE_MONTH] = "MONTH", [SPSS_FORMAT_TYPE_MOYR] = "MOYR", [SPSS_FORMAT_TYPE_QYR] = "QYR", [SPSS_FORMAT_TYPE_WKYR] = "WKYR", [SPSS_FORMAT_TYPE_PCT] = "PCT", [SPSS_FORMAT_TYPE_DOT] = "DOT", [SPSS_FORMAT_TYPE_CCA] = "CCA", [SPSS_FORMAT_TYPE_CCB] = "CCB", [SPSS_FORMAT_TYPE_CCC] = "CCC", [SPSS_FORMAT_TYPE_CCD] = "CCD", [SPSS_FORMAT_TYPE_CCE] = "CCE", [SPSS_FORMAT_TYPE_EDATE] = "EDATE", [SPSS_FORMAT_TYPE_SDATE] = "SDATE", [SPSS_FORMAT_TYPE_MTIME] = "MTIME", [SPSS_FORMAT_TYPE_YMDHMS] = "YMDHMS", }; int spss_format(char *buffer, size_t len, spss_format_t *format) { if (format->type < 0 || format->type >= sizeof(spss_type_strings)/sizeof(spss_type_strings[0]) || spss_type_strings[format->type][0] == '\0') { return 0; } char *string = spss_type_strings[format->type]; if (format->decimal_places || format->type == SPSS_FORMAT_TYPE_F) { snprintf(buffer, len, "%s%d.%d", string, format->width, format->decimal_places); } else if (format->width) { snprintf(buffer, len, "%s%d", string, format->width); } else { snprintf(buffer, len, "%s", string); } return 1; } int spss_varinfo_compare(const void *elem1, const void *elem2) { int offset = *(int *)elem1; const spss_varinfo_t *v = *(const spss_varinfo_t **)elem2; if (offset < v->offset) return -1; return (offset > v->offset); } void spss_varinfo_free(spss_varinfo_t *info) { if (info) { if (info->label) free(info->label); free(info); } } uint64_t spss_64bit_value(readstat_value_t value) { double dval = readstat_double_value(value); uint64_t special_val; memcpy(&special_val, &dval, sizeof(double)); if (isinf(dval)) { if (dval < 0.0) { special_val = SAV_LOWEST_DOUBLE; } else { special_val = SAV_HIGHEST_DOUBLE; } } else if (isnan(dval)) { special_val = SAV_MISSING_DOUBLE; } return special_val; } static readstat_value_t spss_boxed_double_value(double fp_value) { readstat_value_t value = { .type = READSTAT_TYPE_DOUBLE, .v = { .double_value = fp_value }, .is_system_missing = isnan(fp_value) }; return value; } static readstat_value_t spss_boxed_string_value(const char *string) { readstat_value_t value = { .type = READSTAT_TYPE_STRING, .v = { .string_value = string } }; return value; } static readstat_value_t spss_boxed_missing_value(spss_varinfo_t *info, int i) { if (info->type == READSTAT_TYPE_DOUBLE) { return spss_boxed_double_value(info->missing_double_values[i]); } return spss_boxed_string_value(info->missing_string_values[i]); } readstat_missingness_t spss_missingness_for_info(spss_varinfo_t *info) { readstat_missingness_t missingness; memset(&missingness, '\0', sizeof(readstat_missingness_t)); if (info->missing_range) { missingness.missing_ranges_count++; missingness.missing_ranges[0] = spss_boxed_missing_value(info, 0); missingness.missing_ranges[1] = spss_boxed_missing_value(info, 1); if (info->n_missing_values == 3) { missingness.missing_ranges_count++; missingness.missing_ranges[2] = missingness.missing_ranges[3] = spss_boxed_missing_value(info, 2); } } else if (info->n_missing_values > 0) { missingness.missing_ranges_count = info->n_missing_values; int i=0; for (i=0; in_missing_values; i++) { missingness.missing_ranges[2*i] = missingness.missing_ranges[2*i+1] = spss_boxed_missing_value(info, i); } } return missingness; } readstat_variable_t *spss_init_variable_for_info(spss_varinfo_t *info, int index_after_skipping, iconv_t converter) { readstat_variable_t *variable = calloc(1, sizeof(readstat_variable_t)); variable->index = info->index; variable->index_after_skipping = index_after_skipping; variable->type = info->type; if (info->string_length) { variable->storage_width = info->string_length; } else { variable->storage_width = 8 * info->width; } if (info->longname[0]) { readstat_convert(variable->name, sizeof(variable->name), info->longname, sizeof(info->longname), converter); } else { readstat_convert(variable->name, sizeof(variable->name), info->name, sizeof(info->name), converter); } if (info->label) { snprintf(variable->label, sizeof(variable->label), "%s", info->label); } spss_format(variable->format, sizeof(variable->format), &info->print_format); variable->missingness = spss_missingness_for_info(info); variable->measure = info->measure; if (info->display_width) { variable->display_width = info->display_width; } else { variable->display_width = info->print_format.width; } return variable; } uint32_t spss_measure_from_readstat_measure(readstat_measure_t measure) { uint32_t sav_measure = SAV_MEASURE_UNKNOWN; if (measure == READSTAT_MEASURE_NOMINAL) { sav_measure = SAV_MEASURE_NOMINAL; } else if (measure == READSTAT_MEASURE_ORDINAL) { sav_measure = SAV_MEASURE_ORDINAL; } else if (measure == READSTAT_MEASURE_SCALE) { sav_measure = SAV_MEASURE_SCALE; } return sav_measure; } readstat_measure_t spss_measure_to_readstat_measure(uint32_t sav_measure) { if (sav_measure == SAV_MEASURE_NOMINAL) return READSTAT_MEASURE_NOMINAL; if (sav_measure == SAV_MEASURE_ORDINAL) return READSTAT_MEASURE_ORDINAL; if (sav_measure == SAV_MEASURE_SCALE) return READSTAT_MEASURE_SCALE; return READSTAT_MEASURE_UNKNOWN; } uint32_t spss_alignment_from_readstat_alignment(readstat_alignment_t alignment) { uint32_t sav_alignment = 0; if (alignment == READSTAT_ALIGNMENT_LEFT) { sav_alignment = SAV_ALIGNMENT_LEFT; } else if (alignment == READSTAT_ALIGNMENT_CENTER) { sav_alignment = SAV_ALIGNMENT_CENTER; } else if (alignment == READSTAT_ALIGNMENT_RIGHT) { sav_alignment = SAV_ALIGNMENT_RIGHT; } return sav_alignment; } readstat_alignment_t spss_alignment_to_readstat_alignment(uint32_t sav_alignment) { if (sav_alignment == SAV_ALIGNMENT_LEFT) return READSTAT_ALIGNMENT_LEFT; if (sav_alignment == SAV_ALIGNMENT_CENTER) return READSTAT_ALIGNMENT_CENTER; if (sav_alignment == SAV_ALIGNMENT_RIGHT) return READSTAT_ALIGNMENT_RIGHT; return READSTAT_ALIGNMENT_UNKNOWN; } readstat_error_t spss_format_for_variable(readstat_variable_t *r_variable, spss_format_t *spss_format) { readstat_error_t retval = READSTAT_OK; memset(spss_format, 0, sizeof(spss_format_t)); if (r_variable->type == READSTAT_TYPE_STRING) { spss_format->type = SPSS_FORMAT_TYPE_A; if (r_variable->display_width) { spss_format->width = r_variable->display_width; } else if (r_variable->user_width) { spss_format->width = r_variable->user_width; } else { spss_format->width = r_variable->storage_width; } } else { spss_format->type = SPSS_FORMAT_TYPE_F; if (r_variable->display_width) { spss_format->width = r_variable->display_width; } else { spss_format->width = 8; } if (r_variable->type == READSTAT_TYPE_DOUBLE || r_variable->type == READSTAT_TYPE_FLOAT) { spss_format->decimal_places = 2; } } if (r_variable->format[0]) { spss_format->decimal_places = 0; const char *fmt = r_variable->format; if (spss_parse_format(fmt, strlen(fmt), spss_format) != READSTAT_OK) { retval = READSTAT_ERROR_BAD_FORMAT_STRING; goto cleanup; } } cleanup: return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_spss.h0000644023477200000240000000761714574360757020447 0ustar00fajardoostaffs #define SPSS_FORMAT_TYPE_A 1 #define SPSS_FORMAT_TYPE_AHEX 2 #define SPSS_FORMAT_TYPE_COMMA 3 #define SPSS_FORMAT_TYPE_DOLLAR 4 #define SPSS_FORMAT_TYPE_F 5 #define SPSS_FORMAT_TYPE_IB 6 #define SPSS_FORMAT_TYPE_PIBHEX 7 #define SPSS_FORMAT_TYPE_P 8 #define SPSS_FORMAT_TYPE_PIB 9 #define SPSS_FORMAT_TYPE_PK 10 #define SPSS_FORMAT_TYPE_RB 11 #define SPSS_FORMAT_TYPE_RBHEX 12 #define SPSS_FORMAT_TYPE_Z 15 #define SPSS_FORMAT_TYPE_N 16 #define SPSS_FORMAT_TYPE_E 17 #define SPSS_FORMAT_TYPE_DATE 20 #define SPSS_FORMAT_TYPE_TIME 21 #define SPSS_FORMAT_TYPE_DATETIME 22 #define SPSS_FORMAT_TYPE_ADATE 23 #define SPSS_FORMAT_TYPE_JDATE 24 #define SPSS_FORMAT_TYPE_DTIME 25 #define SPSS_FORMAT_TYPE_WKDAY 26 #define SPSS_FORMAT_TYPE_MONTH 27 #define SPSS_FORMAT_TYPE_MOYR 28 #define SPSS_FORMAT_TYPE_QYR 29 #define SPSS_FORMAT_TYPE_WKYR 30 #define SPSS_FORMAT_TYPE_PCT 31 #define SPSS_FORMAT_TYPE_DOT 32 #define SPSS_FORMAT_TYPE_CCA 33 #define SPSS_FORMAT_TYPE_CCB 34 #define SPSS_FORMAT_TYPE_CCC 35 #define SPSS_FORMAT_TYPE_CCD 36 #define SPSS_FORMAT_TYPE_CCE 37 #define SPSS_FORMAT_TYPE_EDATE 38 #define SPSS_FORMAT_TYPE_SDATE 39 #define SPSS_FORMAT_TYPE_MTIME 40 #define SPSS_FORMAT_TYPE_YMDHMS 41 #define SPSS_DOC_LINE_SIZE 80 #define SAV_HIGHEST_DOUBLE 0x7FEFFFFFFFFFFFFFUL #define SAV_MISSING_DOUBLE 0xFFEFFFFFFFFFFFFFUL #define SAV_LOWEST_DOUBLE 0xFFEFFFFFFFFFFFFEUL #define SAV_MEASURE_UNKNOWN 0 #define SAV_MEASURE_NOMINAL 1 #define SAV_MEASURE_ORDINAL 2 #define SAV_MEASURE_SCALE 3 #define SAV_ALIGNMENT_LEFT 0 #define SAV_ALIGNMENT_RIGHT 1 #define SAV_ALIGNMENT_CENTER 2 #include typedef struct spss_format_s { int type; int width; int decimal_places; } spss_format_t; // The reason some fields are stored unconverted is that some versions of SPSS // store truncated UTF-8 in the fields, and also use the truncated strings for // internal logic (such as matching names). If we convert them too early, the // last character of a truncated string will be dropped, and some of the column // information won't be found (e.g. in the key=value long variable record). typedef struct spss_varinfo_s { readstat_type_t type; int labels_index; int index; int offset; int width; unsigned int string_length; spss_format_t print_format; spss_format_t write_format; int n_segments; int n_missing_values; int missing_range; double missing_double_values[3]; char missing_string_values[3][8*4+1]; // stored UTF-8 char name[8+1]; // stored UNCONVERTED char longname[64+1]; // stored UNCONVERTED char *label; // stored UTF-8 readstat_measure_t measure; readstat_alignment_t alignment; int display_width; } spss_varinfo_t; int spss_format(char *buffer, size_t len, spss_format_t *format); int spss_varinfo_compare(const void *elem1, const void *elem2); void spss_varinfo_free(spss_varinfo_t *info); readstat_missingness_t spss_missingness_for_info(spss_varinfo_t *info); readstat_variable_t *spss_init_variable_for_info(spss_varinfo_t *info, int index_after_skipping, iconv_t converter); uint64_t spss_64bit_value(readstat_value_t value); uint32_t spss_measure_from_readstat_measure(readstat_measure_t measure); readstat_measure_t spss_measure_to_readstat_measure(uint32_t sav_measure); uint32_t spss_alignment_from_readstat_alignment(readstat_alignment_t alignment); readstat_alignment_t spss_alignment_to_readstat_alignment(uint32_t sav_alignment); readstat_error_t spss_format_for_variable(readstat_variable_t *r_variable, spss_format_t *spss_format); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_spss_parse.c0000644023477200000240000004606214574360757021631 0ustar00fajardoostaffs#line 1 "src/spss/readstat_spss_parse.rl" #include #include "../readstat.h" #include "readstat_spss.h" #include "readstat_spss_parse.h" #line 11 "src/spss/readstat_spss_parse.c" static const signed char _spss_format_parser_actions[] = { 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20, 1, 21, 1, 22, 1, 23, 1, 24, 1, 25, 1, 26, 1, 27, 1, 28, 1, 29, 1, 30, 1, 31, 1, 32, 1, 33, 1, 34, 1, 35, 1, 36, 1, 37, 1, 38, 1, 39, 1, 40, 2, 0, 1, 3, 4, 0, 1, 3, 5, 0, 1, 3, 6, 0, 1, 3, 7, 0, 1, 3, 8, 0, 1, 3, 9, 0, 1, 3, 10, 0, 1, 3, 11, 0, 1, 3, 12, 0, 1, 3, 13, 0, 1, 3, 14, 0, 1, 3, 15, 0, 1, 3, 16, 0, 1, 3, 17, 0, 1, 3, 18, 0, 1, 3, 19, 0, 1, 3, 20, 0, 1, 3, 21, 0, 1, 3, 22, 0, 1, 3, 23, 0, 1, 3, 24, 0, 1, 3, 25, 0, 1, 3, 26, 0, 1, 3, 27, 0, 1, 3, 28, 0, 1, 3, 29, 0, 1, 3, 30, 0, 1, 3, 31, 0, 1, 3, 32, 0, 1, 3, 33, 0, 1, 3, 34, 0, 1, 3, 35, 0, 1, 3, 36, 0, 1, 3, 37, 0, 1, 3, 38, 0, 1, 3, 39, 0, 1, 3, 40, 0, 1, 0 }; static const short _spss_format_parser_key_offsets[] = { 0, 0, 34, 36, 38, 40, 42, 44, 46, 50, 60, 62, 64, 66, 72, 74, 76, 78, 80, 82, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 118, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 172, 174, 176, 178, 180, 182, 184, 186, 188, 194, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 219, 221, 223, 225, 227, 231, 233, 235, 237, 239, 241, 243, 245, 247, 255, 257, 261, 263, 265, 267, 271, 273, 275, 277, 279, 281, 283, 0 }; static const char _spss_format_parser_trans_keys[] = { 65, 67, 68, 69, 70, 73, 74, 77, 78, 80, 81, 82, 83, 84, 87, 89, 90, 97, 99, 100, 101, 102, 105, 106, 109, 110, 112, 113, 114, 115, 116, 119, 121, 122, 48, 57, 65, 97, 84, 116, 69, 101, 69, 101, 88, 120, 67, 79, 99, 111, 65, 66, 67, 68, 69, 97, 98, 99, 100, 101, 77, 109, 77, 109, 65, 97, 65, 79, 84, 97, 111, 116, 84, 116, 69, 101, 73, 105, 77, 109, 69, 101, 76, 84, 108, 116, 76, 108, 65, 97, 82, 114, 73, 105, 77, 109, 69, 101, 65, 97, 84, 116, 69, 101, 66, 98, 68, 100, 65, 97, 84, 116, 69, 101, 79, 84, 111, 116, 78, 89, 110, 121, 84, 116, 72, 104, 82, 114, 73, 105, 77, 109, 69, 101, 84, 116, 66, 98, 69, 101, 88, 120, 89, 121, 82, 114, 66, 98, 69, 101, 88, 120, 68, 100, 65, 97, 84, 116, 69, 101, 73, 105, 77, 109, 69, 101, 75, 107, 68, 89, 100, 121, 65, 97, 89, 121, 82, 114, 77, 109, 68, 100, 72, 104, 77, 109, 83, 115, 68, 72, 100, 104, 48, 57, 46, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 84, 116, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 68, 100, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 67, 73, 75, 99, 105, 107, 48, 57, 48, 57, 72, 104, 48, 57, 48, 57, 48, 57, 48, 57, 72, 104, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 48, 57, 0 }; static const signed char _spss_format_parser_single_lengths[] = { 0, 34, 0, 2, 2, 2, 2, 2, 4, 10, 2, 2, 2, 6, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0 }; static const signed char _spss_format_parser_range_lengths[] = { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }; static const short _spss_format_parser_index_offsets[] = { 0, 0, 35, 37, 40, 43, 46, 49, 52, 57, 68, 71, 74, 77, 84, 87, 90, 93, 96, 99, 104, 107, 110, 113, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 151, 156, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 189, 192, 195, 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 230, 233, 236, 239, 242, 245, 248, 251, 254, 260, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 285, 287, 289, 291, 293, 297, 299, 301, 303, 305, 307, 309, 311, 313, 321, 323, 327, 329, 331, 333, 337, 339, 341, 343, 345, 347, 349, 0 }; static const signed char _spss_format_parser_cond_targs[] = { 68, 8, 13, 84, 86, 29, 30, 34, 92, 93, 46, 48, 51, 55, 58, 63, 106, 68, 8, 13, 84, 86, 29, 30, 34, 92, 93, 46, 48, 51, 55, 58, 63, 106, 0, 70, 0, 4, 4, 0, 5, 5, 0, 71, 71, 0, 7, 7, 0, 72, 72, 0, 9, 10, 9, 10, 0, 73, 74, 75, 76, 77, 73, 74, 75, 76, 77, 0, 11, 11, 0, 12, 12, 0, 78, 78, 0, 14, 19, 23, 14, 19, 23, 0, 15, 15, 0, 79, 79, 0, 17, 17, 0, 18, 18, 0, 80, 80, 0, 20, 82, 20, 82, 0, 21, 21, 0, 22, 22, 0, 81, 81, 0, 24, 24, 0, 25, 25, 0, 83, 83, 0, 27, 27, 0, 28, 28, 0, 85, 85, 0, 87, 87, 0, 31, 31, 0, 32, 32, 0, 33, 33, 0, 88, 88, 0, 35, 39, 35, 39, 0, 36, 38, 36, 38, 0, 37, 37, 0, 89, 89, 0, 90, 90, 0, 40, 40, 0, 41, 41, 0, 91, 91, 0, 94, 94, 0, 95, 95, 0, 45, 45, 0, 96, 96, 0, 47, 47, 0, 98, 98, 0, 99, 99, 0, 50, 50, 0, 100, 100, 0, 52, 52, 0, 53, 53, 0, 54, 54, 0, 101, 101, 0, 56, 56, 0, 57, 57, 0, 102, 102, 0, 59, 59, 0, 60, 62, 60, 62, 0, 61, 61, 0, 103, 103, 0, 104, 104, 0, 64, 64, 0, 65, 65, 0, 66, 66, 0, 67, 67, 0, 105, 105, 0, 3, 6, 3, 6, 69, 0, 2, 69, 0, 70, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 16, 16, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 26, 26, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 42, 43, 97, 42, 43, 97, 69, 0, 69, 0, 44, 44, 69, 0, 69, 0, 69, 0, 69, 0, 49, 49, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 69, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 0 }; static const short _spss_format_parser_cond_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 0, 3, 1, 0, 1, 0, 160, 0, 88, 0, 204, 0, 208, 0, 212, 0, 216, 0, 220, 0, 92, 0, 0, 0, 144, 0, 152, 0, 96, 0, 200, 0, 168, 0, 0, 0, 140, 0, 224, 0, 100, 0, 104, 0, 164, 0, 180, 0, 184, 0, 172, 0, 136, 0, 0, 0, 0, 0, 0, 0, 112, 0, 196, 0, 0, 0, 116, 0, 108, 0, 120, 0, 188, 0, 0, 0, 124, 0, 128, 0, 228, 0, 148, 0, 176, 0, 192, 0, 156, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 5, 45, 9, 67, 69, 71, 73, 75, 11, 37, 41, 13, 65, 49, 35, 77, 15, 17, 47, 55, 57, 51, 33, 21, 63, 23, 19, 25, 59, 27, 29, 79, 39, 53, 61, 43, 31, 0 }; static const short _spss_format_parser_eof_trans[] = { 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 0 }; static const int spss_format_parser_start = 1; static const int spss_format_parser_en_main = 1; #line 11 "src/spss/readstat_spss_parse.rl" // For minimum width information see // https://www.ibm.com/support/knowledgecenter/SSLVMB_sub/statistics_reference_project_ddita/spss/base/syn_date_and_time_date_time_formats.html readstat_error_t spss_parse_format(const char *data, int count, spss_format_t *fmt) { unsigned char *p = (unsigned char *)data; unsigned char *pe = (unsigned char *)data + count; unsigned char *eof = pe; int cs; unsigned int integer = 0; #line 310 "src/spss/readstat_spss_parse.c" { cs = (int)spss_format_parser_start; } #line 315 "src/spss/readstat_spss_parse.c" { int _klen; unsigned int _trans = 0; const char * _keys; const signed char * _acts; unsigned int _nacts; _resume: {} if ( p == pe && p != eof ) goto _out; if ( p == eof ) { if ( _spss_format_parser_eof_trans[cs] > 0 ) { _trans = (unsigned int)_spss_format_parser_eof_trans[cs] - 1; } } else { _keys = ( _spss_format_parser_trans_keys + (_spss_format_parser_key_offsets[cs])); _trans = (unsigned int)_spss_format_parser_index_offsets[cs]; _klen = (int)_spss_format_parser_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + _klen - 1; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _keys += _klen; _trans += (unsigned int)_klen; break; } _mid = _lower + ((_upper-_lower) >> 1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 1; else if ( ( (*( p))) > (*( _mid)) ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } } _klen = (int)_spss_format_parser_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + (_klen<<1) - 2; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _trans += (unsigned int)_klen; break; } _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 2; else if ( ( (*( p))) > (*( _mid + 1)) ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); break; } } } _match: {} } cs = (int)_spss_format_parser_cond_targs[_trans]; if ( _spss_format_parser_cond_actions[_trans] != 0 ) { _acts = ( _spss_format_parser_actions + (_spss_format_parser_cond_actions[_trans])); _nacts = (unsigned int)(*( _acts)); _acts += 1; while ( _nacts > 0 ) { switch ( (*( _acts)) ) { case 0: { { #line 24 "src/spss/readstat_spss_parse.rl" integer = 0; } #line 400 "src/spss/readstat_spss_parse.c" break; } case 1: { { #line 28 "src/spss/readstat_spss_parse.rl" integer = 10 * integer + ((( (*( p)))) - '0'); } #line 411 "src/spss/readstat_spss_parse.c" break; } case 2: { { #line 32 "src/spss/readstat_spss_parse.rl" fmt->width = integer; } #line 422 "src/spss/readstat_spss_parse.c" break; } case 3: { { #line 36 "src/spss/readstat_spss_parse.rl" fmt->decimal_places = integer; } #line 433 "src/spss/readstat_spss_parse.c" break; } case 4: { { #line 40 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_A; } #line 442 "src/spss/readstat_spss_parse.c" break; } case 5: { { #line 41 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_AHEX; } #line 451 "src/spss/readstat_spss_parse.c" break; } case 6: { { #line 42 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_COMMA; } #line 460 "src/spss/readstat_spss_parse.c" break; } case 7: { { #line 43 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_DOLLAR; } #line 469 "src/spss/readstat_spss_parse.c" break; } case 8: { { #line 44 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_F; } #line 478 "src/spss/readstat_spss_parse.c" break; } case 9: { { #line 45 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_IB; } #line 487 "src/spss/readstat_spss_parse.c" break; } case 10: { { #line 46 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_PIBHEX; } #line 496 "src/spss/readstat_spss_parse.c" break; } case 11: { { #line 47 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_P; } #line 505 "src/spss/readstat_spss_parse.c" break; } case 12: { { #line 48 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_PIB; } #line 514 "src/spss/readstat_spss_parse.c" break; } case 13: { { #line 49 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_PK; } #line 523 "src/spss/readstat_spss_parse.c" break; } case 14: { { #line 50 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_RB; } #line 532 "src/spss/readstat_spss_parse.c" break; } case 15: { { #line 51 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_RBHEX; } #line 541 "src/spss/readstat_spss_parse.c" break; } case 16: { { #line 52 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_Z; } #line 550 "src/spss/readstat_spss_parse.c" break; } case 17: { { #line 53 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_N; } #line 559 "src/spss/readstat_spss_parse.c" break; } case 18: { { #line 54 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_E; } #line 568 "src/spss/readstat_spss_parse.c" break; } case 19: { { #line 55 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_DATE; fmt->width = 11; } #line 577 "src/spss/readstat_spss_parse.c" break; } case 20: { { #line 56 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_TIME; } #line 586 "src/spss/readstat_spss_parse.c" break; } case 21: { { #line 57 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_DATETIME; fmt->width = 20; } #line 595 "src/spss/readstat_spss_parse.c" break; } case 22: { { #line 58 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_YMDHMS; fmt->width = 19; } #line 604 "src/spss/readstat_spss_parse.c" break; } case 23: { { #line 59 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_ADATE; fmt->width = 10; } #line 613 "src/spss/readstat_spss_parse.c" break; } case 24: { { #line 60 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_JDATE; } #line 622 "src/spss/readstat_spss_parse.c" break; } case 25: { { #line 61 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_DTIME; fmt->width = 23; } #line 631 "src/spss/readstat_spss_parse.c" break; } case 26: { { #line 62 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_MTIME; } #line 640 "src/spss/readstat_spss_parse.c" break; } case 27: { { #line 63 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_WKDAY; } #line 649 "src/spss/readstat_spss_parse.c" break; } case 28: { { #line 64 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_MONTH; } #line 658 "src/spss/readstat_spss_parse.c" break; } case 29: { { #line 65 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_MOYR; } #line 667 "src/spss/readstat_spss_parse.c" break; } case 30: { { #line 66 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_QYR; } #line 676 "src/spss/readstat_spss_parse.c" break; } case 31: { { #line 67 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_WKYR; fmt->width = 10; } #line 685 "src/spss/readstat_spss_parse.c" break; } case 32: { { #line 68 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_PCT; } #line 694 "src/spss/readstat_spss_parse.c" break; } case 33: { { #line 69 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_DOT; } #line 703 "src/spss/readstat_spss_parse.c" break; } case 34: { { #line 70 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_CCA; } #line 712 "src/spss/readstat_spss_parse.c" break; } case 35: { { #line 71 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_CCB; } #line 721 "src/spss/readstat_spss_parse.c" break; } case 36: { { #line 72 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_CCC; } #line 730 "src/spss/readstat_spss_parse.c" break; } case 37: { { #line 73 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_CCD; } #line 739 "src/spss/readstat_spss_parse.c" break; } case 38: { { #line 74 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_CCE; } #line 748 "src/spss/readstat_spss_parse.c" break; } case 39: { { #line 75 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_EDATE; fmt->width = 10; } #line 757 "src/spss/readstat_spss_parse.c" break; } case 40: { { #line 76 "src/spss/readstat_spss_parse.rl" fmt->type = SPSS_FORMAT_TYPE_SDATE; fmt->width = 10; } #line 766 "src/spss/readstat_spss_parse.c" break; } } _nacts -= 1; _acts += 1; } } if ( p == eof ) { if ( cs >= 68 ) goto _out; } else { if ( cs != 0 ) { p += 1; goto _resume; } } _out: {} } #line 89 "src/spss/readstat_spss_parse.rl" /* suppress warning */ (void)spss_format_parser_en_main; if (cs < #line 797 "src/spss/readstat_spss_parse.c" 68 #line 94 "src/spss/readstat_spss_parse.rl" || p != eof) { return READSTAT_ERROR_PARSE; } return READSTAT_OK; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_spss_parse.h0000644023477200000240000000012614574360757021625 0ustar00fajardoostaffs readstat_error_t spss_parse_format(const char *data, int count, spss_format_t *fmt); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_zsav_compress.c0000644023477200000240000000651314574360757022342 0ustar00fajardoostaffs #include #include #include #include "readstat_zsav_compress.h" zsav_ctx_t *zsav_ctx_init(size_t max_row_len, int64_t offset) { zsav_ctx_t *ctx = calloc(1, sizeof(zsav_ctx_t)); ctx->buffer = malloc(max_row_len); ctx->blocks_capacity = 10; ctx->blocks = calloc(ctx->blocks_capacity, sizeof(zsav_block_t *)); ctx->uncompressed_block_size = 0x3FF000; ctx->zheader_ofs = offset; ctx->compression_level = Z_DEFAULT_COMPRESSION; return ctx; } void zsav_ctx_free(zsav_ctx_t *ctx) { int i; for (i=0; iblocks_count; i++) { zsav_block_t *block = ctx->blocks[i]; deflateEnd(&block->stream); free(block->compressed_data); free(block); } free(ctx->blocks); free(ctx->buffer); free(ctx); } zsav_block_t *zsav_add_block(zsav_ctx_t *ctx) { zsav_block_t *block = NULL; if (ctx->blocks_count == ctx->blocks_capacity) { ctx->blocks = realloc(ctx->blocks, (ctx->blocks_capacity *= 2 ) * sizeof(zsav_block_t *)); } block = calloc(1, sizeof(zsav_block_t)); ctx->blocks[ctx->blocks_count++] = block; deflateInit(&block->stream, ctx->compression_level); block->compressed_data_capacity = deflateBound(&block->stream, ctx->uncompressed_block_size); block->compressed_data = malloc(block->compressed_data_capacity); return block; } zsav_block_t *zsav_current_block(zsav_ctx_t *ctx) { if (ctx->blocks_count == 0) return NULL; return ctx->blocks[ctx->blocks_count-1]; } int zsav_compress_row(void *input, size_t input_len, int finish, zsav_ctx_t *ctx) { off_t row_off = 0; unsigned char *row_buffer = input; size_t row_len = input_len; zsav_block_t *block = zsav_current_block(ctx); int deflate_status = Z_OK; if (block == NULL) { block = zsav_add_block(ctx); } block->stream.next_in = row_buffer; block->stream.avail_in = row_len; block->stream.next_out = &block->compressed_data[block->compressed_size]; block->stream.avail_out = block->compressed_data_capacity - block->compressed_size; /* If the row won't fit into this block, keep writing and flushing * until the remainder fits. */ while (row_len - row_off > ctx->uncompressed_block_size - block->uncompressed_size) { block->stream.avail_in = ctx->uncompressed_block_size - block->uncompressed_size; row_off += ctx->uncompressed_block_size - block->uncompressed_size; if ((deflate_status = deflate(&block->stream, Z_FINISH)) != Z_STREAM_END) { goto cleanup; } block->compressed_size = block->compressed_data_capacity - block->stream.avail_out; block->uncompressed_size = ctx->uncompressed_block_size - block->stream.avail_in; block = zsav_add_block(ctx); block->stream.next_in = &row_buffer[row_off]; block->stream.avail_in = row_len - row_off; block->stream.next_out = block->compressed_data; block->stream.avail_out = block->compressed_data_capacity; } /* Now the rest of the row will fit in the block */ deflate_status = deflate(&block->stream, finish ? Z_FINISH : Z_NO_FLUSH); block->compressed_size = block->compressed_data_capacity - block->stream.avail_out; block->uncompressed_size += (row_len - row_off) - block->stream.avail_in; cleanup: return deflate_status; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_zsav_compress.h0000644023477200000240000000144414574360757022345 0ustar00fajardoostaffs typedef struct zsav_block_s { int32_t uncompressed_size; int32_t compressed_size; z_stream stream; unsigned char *compressed_data; size_t compressed_data_capacity; } zsav_block_t; typedef struct zsav_ctx_s { void *buffer; zsav_block_t **blocks; int blocks_count; int blocks_capacity; int64_t uncompressed_block_size; int64_t zheader_ofs; int compression_level; } zsav_ctx_t; zsav_ctx_t *zsav_ctx_init(size_t max_row_len, int64_t offset); void zsav_ctx_free(zsav_ctx_t *ctx); zsav_block_t *zsav_add_block(zsav_ctx_t *ctx); zsav_block_t *zsav_current_block(zsav_ctx_t *ctx); int zsav_compress_row(void *input, size_t input_len, int finish, zsav_ctx_t *zctx); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_zsav_read.c0000644023477200000240000001452314574360757021422 0ustar00fajardoostaffs#include #include #include "../readstat.h" #include "../readstat_bits.h" #include "../readstat_iconv.h" #include "../readstat_malloc.h" #include "readstat_sav.h" #include "readstat_sav_compress.h" struct zheader { uint64_t zheader_ofs; uint64_t ztrailer_ofs; uint64_t ztrailer_len; }; struct ztrailer { int64_t bias; int64_t zero; int32_t block_size; int32_t n_blocks; }; struct ztrailer_entry { int64_t uncompressed_ofs; int64_t compressed_ofs; int32_t uncompressed_size; int32_t compressed_size; }; readstat_error_t zsav_read_compressed_data(sav_ctx_t *ctx, readstat_error_t (*row_handler)(unsigned char *, size_t, sav_ctx_t *)) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; readstat_off_t data_offset = 0; size_t uncompressed_row_len = ctx->var_offset * 8; readstat_off_t uncompressed_offset = 0; unsigned char *uncompressed_row = NULL; uLongf uncompressed_block_len = 0; unsigned char *compressed_block = NULL, *uncompressed_block = NULL; struct sav_row_stream_s state = { .missing_value = ctx->missing_double, .bias = ctx->bias, .bswap = ctx->bswap }; struct zheader zheader; struct ztrailer ztrailer; struct ztrailer_entry *ztrailer_entries = NULL; int n_blocks = 0; int block_i = 0; int i; if (io->read(&zheader, sizeof(struct zheader), io->io_ctx) < sizeof(struct zheader)) { retval = READSTAT_ERROR_READ; goto cleanup; } zheader.zheader_ofs = ctx->bswap ? byteswap8(zheader.zheader_ofs) : zheader.zheader_ofs; zheader.ztrailer_ofs = ctx->bswap ? byteswap8(zheader.ztrailer_ofs) : zheader.ztrailer_ofs; zheader.ztrailer_len = ctx->bswap ? byteswap8(zheader.ztrailer_len) : zheader.ztrailer_len; if (zheader.zheader_ofs != io->seek(0, READSTAT_SEEK_CUR, io->io_ctx) - sizeof(struct zheader)) { retval = READSTAT_ERROR_PARSE; goto cleanup; } n_blocks = (zheader.ztrailer_len - 24) / 24; if (io->seek(zheader.ztrailer_ofs, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->read(&ztrailer, sizeof(struct ztrailer), io->io_ctx) < sizeof(struct ztrailer)) { retval = READSTAT_ERROR_READ; goto cleanup; } ztrailer.bias = ctx->bswap ? byteswap8(ztrailer.bias) : ztrailer.bias; ztrailer.zero = ctx->bswap ? byteswap8(ztrailer.zero) : ztrailer.zero; ztrailer.block_size = ctx->bswap ? byteswap4(ztrailer.block_size) : ztrailer.block_size; ztrailer.n_blocks = ctx->bswap ? byteswap4(ztrailer.n_blocks) : ztrailer.n_blocks; if (n_blocks != ztrailer.n_blocks) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (n_blocks && (ztrailer_entries = readstat_malloc(n_blocks * sizeof(struct ztrailer_entry))) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (io->read(ztrailer_entries, n_blocks * sizeof(struct ztrailer_entry), io->io_ctx) < n_blocks * sizeof(struct ztrailer_entry)) { retval = READSTAT_ERROR_READ; goto cleanup; } for (i=0; iuncompressed_ofs = ctx->bswap ? byteswap8(entry->uncompressed_ofs) : entry->uncompressed_ofs; entry->compressed_ofs = ctx->bswap ? byteswap8(entry->compressed_ofs) : entry->compressed_ofs; entry->uncompressed_size = ctx->bswap ? byteswap4(entry->uncompressed_size) : entry->uncompressed_size; entry->compressed_size = ctx->bswap ? byteswap4(entry->compressed_size) : entry->compressed_size; } if (uncompressed_row_len && (uncompressed_row = readstat_malloc(uncompressed_row_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } while (1) { if (block_i == n_blocks) goto cleanup; struct ztrailer_entry *entry = &ztrailer_entries[block_i]; if (io->seek(entry->compressed_ofs, READSTAT_SEEK_SET, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } if ((compressed_block = readstat_realloc(compressed_block, entry->compressed_size)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (io->read(compressed_block, entry->compressed_size, io->io_ctx) != entry->compressed_size) { retval = READSTAT_ERROR_READ; goto cleanup; } uncompressed_block_len = entry->uncompressed_size; if ((uncompressed_block = readstat_realloc(uncompressed_block, uncompressed_block_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } int status = uncompress(uncompressed_block, &uncompressed_block_len, compressed_block, entry->compressed_size); if (status != Z_OK || uncompressed_block_len != entry->uncompressed_size) { retval = READSTAT_ERROR_PARSE; goto cleanup; } block_i++; state.status = SAV_ROW_STREAM_HAVE_DATA; data_offset = 0; while (state.status != SAV_ROW_STREAM_NEED_DATA) { state.next_in = &uncompressed_block[data_offset]; state.avail_in = uncompressed_block_len - data_offset; state.next_out = &uncompressed_row[uncompressed_offset]; state.avail_out = uncompressed_row_len - uncompressed_offset; sav_decompress_row(&state); uncompressed_offset = uncompressed_row_len - state.avail_out; data_offset = uncompressed_block_len - state.avail_in; if (state.status == SAV_ROW_STREAM_FINISHED_ROW) { retval = row_handler(uncompressed_row, uncompressed_row_len, ctx); if (retval != READSTAT_OK) goto cleanup; uncompressed_offset = 0; } if (state.status == SAV_ROW_STREAM_FINISHED_ALL) goto cleanup; if (ctx->row_limit > 0 && ctx->current_row == ctx->row_limit) goto cleanup; } } cleanup: if (uncompressed_row) free(uncompressed_row); if (ztrailer_entries) free(ztrailer_entries); if (compressed_block) free(compressed_block); if (uncompressed_block) free(uncompressed_block); return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_zsav_read.h0000644023477200000240000000021414574360757021417 0ustar00fajardoostaffs readstat_error_t zsav_read_compressed_data(sav_ctx_t *ctx, readstat_error_t (*row_handler)(unsigned char *, size_t, sav_ctx_t *)); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_zsav_write.c0000644023477200000240000001134214574360757021635 0ustar00fajardoostaffs#include #include #include #include "../readstat.h" #include "../readstat_writer.h" #include "readstat_sav_compress.h" #include "readstat_zsav_compress.h" #include "readstat_zsav_write.h" readstat_error_t zsav_write_compressed_row(void *writer_ctx, void *row, size_t len) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; zsav_ctx_t *zctx = writer->module_ctx; /* Kind of frustrating that SPSS does double compression. If they just * z-compressed the uncompressed data, we could calculate the block count * in advance and write out the file in a streaming manner. As things stand * we have to build up the file in memory until we know the final block * count. A possible streaming solution would be to declare the number of * blocks required to hold the maximum possible row-compressed size and * then fill out the end with no-op zero bytes (that get z-compressed very * small). */ size_t row_len = sav_compress_row(zctx->buffer, row, len, writer); int deflate_status = zsav_compress_row(zctx->buffer, row_len, writer->current_row + 1 == writer->row_count, zctx); if (deflate_status != Z_OK && deflate_status != Z_STREAM_END) return READSTAT_ERROR_WRITE; return READSTAT_OK; } static readstat_error_t zsav_write_data_header(readstat_writer_t *writer, zsav_ctx_t *zctx) { readstat_error_t retval = READSTAT_OK; uint64_t zheader_ofs = zctx->zheader_ofs; uint64_t ztrailer_ofs = zheader_ofs + 24; uint64_t ztrailer_len = 24 + zctx->blocks_count * 24; int i; for (i=0; iblocks_count; i++) { zsav_block_t *block = zctx->blocks[i]; ztrailer_ofs += block->compressed_size; } if ((retval = readstat_write_bytes(writer, &zheader_ofs, sizeof(uint64_t))) != READSTAT_OK) goto cleanup; if ((retval = readstat_write_bytes(writer, &ztrailer_ofs, sizeof(uint64_t))) != READSTAT_OK) goto cleanup; if ((retval = readstat_write_bytes(writer, &ztrailer_len, sizeof(uint64_t))) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t zsav_write_data_blocks(readstat_writer_t *writer, zsav_ctx_t *zctx) { readstat_error_t retval = READSTAT_OK; int i; for (i=0; iblocks_count; i++) { zsav_block_t *block = zctx->blocks[i]; if ((retval = readstat_write_bytes(writer, block->compressed_data, block->compressed_size)) != READSTAT_OK) goto cleanup; } cleanup: return retval; } static readstat_error_t zsav_write_data_trailer(readstat_writer_t *writer, zsav_ctx_t *zctx) { readstat_error_t retval = READSTAT_OK; int64_t bias = -100; int64_t zero = 0; int32_t block_size = zctx->uncompressed_block_size; int32_t n_blocks = zctx->blocks_count; if ((retval = readstat_write_bytes(writer, &bias, sizeof(int64_t))) != READSTAT_OK) goto cleanup; if ((retval = readstat_write_bytes(writer, &zero, sizeof(int64_t))) != READSTAT_OK) goto cleanup; if ((retval = readstat_write_bytes(writer, &block_size, sizeof(int32_t))) != READSTAT_OK) goto cleanup; if ((retval = readstat_write_bytes(writer, &n_blocks, sizeof(int32_t))) != READSTAT_OK) goto cleanup; int i; int64_t uncompressed_ofs = zctx->zheader_ofs; int64_t compressed_ofs = zctx->zheader_ofs + 24; for (i=0; iblocks_count; i++) { zsav_block_t *block = zctx->blocks[i]; int32_t uncompressed_size = block->uncompressed_size; int32_t compressed_size = block->compressed_size; if ((retval = readstat_write_bytes(writer, &uncompressed_ofs, sizeof(int64_t))) != READSTAT_OK) goto cleanup; if ((retval = readstat_write_bytes(writer, &compressed_ofs, sizeof(int64_t))) != READSTAT_OK) goto cleanup; if ((retval = readstat_write_bytes(writer, &uncompressed_size, sizeof(int32_t))) != READSTAT_OK) goto cleanup; if ((retval = readstat_write_bytes(writer, &compressed_size, sizeof(int32_t))) != READSTAT_OK) goto cleanup; uncompressed_ofs += uncompressed_size; compressed_ofs += compressed_size; } cleanup: return retval; } readstat_error_t zsav_end_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; zsav_ctx_t *zctx = writer->module_ctx; readstat_error_t retval = READSTAT_OK; retval = zsav_write_data_header(writer, zctx); if (retval != READSTAT_OK) goto cleanup; retval = zsav_write_data_blocks(writer, zctx); if (retval != READSTAT_OK) goto cleanup; retval = zsav_write_data_trailer(writer, zctx); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/spss/readstat_zsav_write.h0000644023477200000240000000021014574360757021632 0ustar00fajardoostaffs readstat_error_t zsav_write_compressed_row(void *writer_ctx, void *row, size_t len); readstat_error_t zsav_end_data(void *writer_ctx); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/src/stata/0000755023477200000240000000000014574564663015532 5ustar00fajardoostaffs././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/stata/readstat_dta.c0000644023477200000240000002326614574360757020344 0ustar00fajardoostaffs#include #include #include #include #include #include "../readstat.h" #include "../readstat_iconv.h" #include "../readstat_malloc.h" #include "../readstat_bits.h" #include "readstat_dta.h" #define DTA_MIN_VERSION 104 #define DTA_MAX_VERSION 119 dta_ctx_t *dta_ctx_alloc(readstat_io_t *io) { dta_ctx_t *ctx = calloc(1, sizeof(dta_ctx_t)); if (ctx == NULL) { return NULL; } ctx->io = io; ctx->initialized = 0; return ctx; } readstat_error_t dta_ctx_init(dta_ctx_t *ctx, uint32_t nvar, uint64_t nobs, unsigned char byteorder, unsigned char ds_format, const char *input_encoding, const char *output_encoding) { readstat_error_t retval = READSTAT_OK; int machine_byteorder = DTA_HILO; if (ds_format < DTA_MIN_VERSION || ds_format > DTA_MAX_VERSION) return READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION; if (machine_is_little_endian()) { machine_byteorder = DTA_LOHI; } ctx->bswap = (byteorder != machine_byteorder); ctx->ds_format = ds_format; ctx->endianness = byteorder == DTA_LOHI ? READSTAT_ENDIAN_LITTLE : READSTAT_ENDIAN_BIG; ctx->nvar = nvar; ctx->nobs = nobs; if (ctx->nvar) { if ((ctx->variables = readstat_calloc(ctx->nvar, sizeof(readstat_variable_t *))) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } } ctx->machine_is_twos_complement = READSTAT_MACHINE_IS_TWOS_COMPLEMENT; if (ds_format < 105) { ctx->fmtlist_entry_len = 7; } else if (ds_format < 114) { ctx->fmtlist_entry_len = 12; } else if (ds_format < 118) { ctx->fmtlist_entry_len = 49; } else { ctx->fmtlist_entry_len = 57; } if (ds_format >= 117) { ctx->typlist_version = 117; } else if (ds_format >= 111) { ctx->typlist_version = 111; } else { ctx->typlist_version = 0; } if (ds_format >= 118) { ctx->data_label_len_len = 2; ctx->strl_v_len = 2; ctx->strl_o_len = 6; } else if (ds_format >= 117) { ctx->data_label_len_len = 1; ctx->strl_v_len = 4; ctx->strl_o_len = 4; } if (ds_format < 105) { ctx->expansion_len_len = 0; } else if (ds_format < 110) { ctx->expansion_len_len = 2; } else { ctx->expansion_len_len = 4; } if (ds_format < 110) { ctx->lbllist_entry_len = 9; ctx->variable_name_len = 9; ctx->ch_metadata_len = 9; } else if (ds_format < 118) { ctx->lbllist_entry_len = 33; ctx->variable_name_len = 33; ctx->ch_metadata_len = 33; } else { ctx->lbllist_entry_len = 129; ctx->variable_name_len = 129; ctx->ch_metadata_len = 129; } if (ds_format < 108) { ctx->variable_labels_entry_len = 32; ctx->data_label_len = 32; } else if (ds_format < 118) { ctx->variable_labels_entry_len = 81; ctx->data_label_len = 81; } else { ctx->variable_labels_entry_len = 321; ctx->data_label_len = 321; } if (ds_format < 105) { ctx->timestamp_len = 0; ctx->value_label_table_len_len = 2; ctx->value_label_table_labname_len = 12; ctx->value_label_table_padding_len = 2; } else { ctx->timestamp_len = 18; ctx->value_label_table_len_len = 4; if (ds_format < 118) { ctx->value_label_table_labname_len = 33; } else { ctx->value_label_table_labname_len = 129; } ctx->value_label_table_padding_len = 3; } if (ds_format < 117) { ctx->typlist_entry_len = 1; ctx->file_is_xmlish = 0; } else { ctx->typlist_entry_len = 2; ctx->file_is_xmlish = 1; } if (ds_format < 113) { ctx->max_int8 = DTA_OLD_MAX_INT8; ctx->max_int16 = DTA_OLD_MAX_INT16; ctx->max_int32 = DTA_OLD_MAX_INT32; ctx->max_float = DTA_OLD_MAX_FLOAT; ctx->max_double = DTA_OLD_MAX_DOUBLE; } else { ctx->max_int8 = DTA_113_MAX_INT8; ctx->max_int16 = DTA_113_MAX_INT16; ctx->max_int32 = DTA_113_MAX_INT32; ctx->max_float = DTA_113_MAX_FLOAT; ctx->max_double = DTA_113_MAX_DOUBLE; ctx->supports_tagged_missing = 1; } if (output_encoding) { if (input_encoding) { ctx->converter = iconv_open(output_encoding, input_encoding); } else if (ds_format < 118) { ctx->converter = iconv_open(output_encoding, "WINDOWS-1252"); } else if (strcmp(output_encoding, "UTF-8") != 0) { ctx->converter = iconv_open(output_encoding, "UTF-8"); } if (ctx->converter == (iconv_t)-1) { ctx->converter = NULL; retval = READSTAT_ERROR_UNSUPPORTED_CHARSET; goto cleanup; } } if (ds_format < 119) { ctx->srtlist_len = (ctx->nvar + 1) * sizeof(int16_t); } else { ctx->srtlist_len = (ctx->nvar + 1) * sizeof(int32_t); } if ((ctx->srtlist = readstat_malloc(ctx->srtlist_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (ctx->nvar > 0) { ctx->typlist_len = ctx->nvar * sizeof(uint16_t); ctx->varlist_len = ctx->variable_name_len * ctx->nvar * sizeof(char); ctx->fmtlist_len = ctx->fmtlist_entry_len * ctx->nvar * sizeof(char); ctx->lbllist_len = ctx->lbllist_entry_len * ctx->nvar * sizeof(char); ctx->variable_labels_len = ctx->variable_labels_entry_len * ctx->nvar * sizeof(char); if ((ctx->typlist = readstat_malloc(ctx->typlist_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if ((ctx->varlist = readstat_malloc(ctx->varlist_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if ((ctx->fmtlist = readstat_malloc(ctx->fmtlist_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if ((ctx->lbllist = readstat_malloc(ctx->lbllist_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if ((ctx->variable_labels = readstat_malloc(ctx->variable_labels_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } } ctx->initialized = 1; cleanup: return retval; } void dta_ctx_free(dta_ctx_t *ctx) { if (ctx->typlist) free(ctx->typlist); if (ctx->varlist) free(ctx->varlist); if (ctx->srtlist) free(ctx->srtlist); if (ctx->fmtlist) free(ctx->fmtlist); if (ctx->lbllist) free(ctx->lbllist); if (ctx->variable_labels) free(ctx->variable_labels); if (ctx->converter) iconv_close(ctx->converter); if (ctx->data_label) free(ctx->data_label); if (ctx->variables) { int i; for (i=0; invar; i++) { if (ctx->variables[i]) free(ctx->variables[i]); } free(ctx->variables); } if (ctx->strls) { int i; for (i=0; istrls_count; i++) { free(ctx->strls[i]); } free(ctx->strls); } free(ctx); } readstat_error_t dta_type_info(uint16_t typecode, dta_ctx_t *ctx, size_t *max_len, readstat_type_t *out_type) { readstat_error_t retval = READSTAT_OK; size_t len = 0; readstat_type_t type = READSTAT_TYPE_STRING; if (ctx->typlist_version == 111) { switch (typecode) { case DTA_111_TYPE_CODE_INT8: len = 1; type = READSTAT_TYPE_INT8; break; case DTA_111_TYPE_CODE_INT16: len = 2; type = READSTAT_TYPE_INT16; break; case DTA_111_TYPE_CODE_INT32: len = 4; type = READSTAT_TYPE_INT32; break; case DTA_111_TYPE_CODE_FLOAT: len = 4; type = READSTAT_TYPE_FLOAT; break; case DTA_111_TYPE_CODE_DOUBLE: len = 8; type = READSTAT_TYPE_DOUBLE; break; default: len = typecode; type = READSTAT_TYPE_STRING; break; } } else if (ctx->typlist_version == 117) { switch (typecode) { case DTA_117_TYPE_CODE_INT8: len = 1; type = READSTAT_TYPE_INT8; break; case DTA_117_TYPE_CODE_INT16: len = 2; type = READSTAT_TYPE_INT16; break; case DTA_117_TYPE_CODE_INT32: len = 4; type = READSTAT_TYPE_INT32; break; case DTA_117_TYPE_CODE_FLOAT: len = 4; type = READSTAT_TYPE_FLOAT; break; case DTA_117_TYPE_CODE_DOUBLE: len = 8; type = READSTAT_TYPE_DOUBLE; break; case DTA_117_TYPE_CODE_STRL: len = 8; type = READSTAT_TYPE_STRING_REF; break; default: len = typecode; type = READSTAT_TYPE_STRING; break; } } else if (typecode < 0x7F) { switch (typecode) { case DTA_OLD_TYPE_CODE_INT8: len = 1; type = READSTAT_TYPE_INT8; break; case DTA_OLD_TYPE_CODE_INT16: len = 2; type = READSTAT_TYPE_INT16; break; case DTA_OLD_TYPE_CODE_INT32: len = 4; type = READSTAT_TYPE_INT32; break; case DTA_OLD_TYPE_CODE_FLOAT: len = 4; type = READSTAT_TYPE_FLOAT; break; case DTA_OLD_TYPE_CODE_DOUBLE: len = 8; type = READSTAT_TYPE_DOUBLE; break; default: retval = READSTAT_ERROR_PARSE; break; } } else { len = typecode - 0x7F; type = READSTAT_TYPE_STRING; } if (max_len) *max_len = len; if (out_type) *out_type = type; return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/stata/readstat_dta.h0000644023477200000240000001360214574360757020342 0ustar00fajardoostaffs#pragma pack(push, 1) // DTA files typedef struct dta_header_s { unsigned char ds_format; unsigned char byteorder; unsigned char filetype; unsigned char unused; uint16_t nvar; uint32_t nobs; } dta_header_t; typedef struct dta_header64_s { unsigned char ds_format; unsigned char byteorder; unsigned char filetype; unsigned char unused; uint32_t nvar; uint64_t nobs; } dta_header64_t; /* Some compilers will pack the elements, but still round up * the total size of the structure. So use macros in place of * sizeof(dta_117_strl_header_t)/sizeof(dta_118_strl_header_t). */ typedef struct dta_117_strl_header_s { uint32_t v; uint32_t o; unsigned char type; int32_t len; } dta_117_strl_header_t; #define SIZEOF_DTA_117_STRL_HEADER_T 13 typedef struct dta_118_strl_header_s { uint32_t v; uint64_t o; unsigned char type; int32_t len; } dta_118_strl_header_t; #define SIZEOF_DTA_118_STRL_HEADER_T 17 #pragma pack(pop) typedef struct dta_strl_s { uint16_t v; uint64_t o; unsigned char type; size_t len; char data[1]; // Flexible array; use [1] for C++98 compatibility } dta_strl_t; typedef struct dta_ctx_s { char *data_label; size_t data_label_len; size_t data_label_len_len; time_t timestamp; size_t timestamp_len; char typlist_version; size_t typlist_entry_len; uint16_t *typlist; size_t typlist_len; char *varlist; size_t varlist_len; int16_t *srtlist; size_t srtlist_len; char *fmtlist; size_t fmtlist_len; char *lbllist; size_t lbllist_len; char *variable_labels; size_t variable_labels_len; size_t variable_name_len; size_t fmtlist_entry_len; size_t lbllist_entry_len; size_t variable_labels_entry_len; size_t expansion_len_len; size_t ch_metadata_len; size_t value_label_table_len_len; size_t value_label_table_labname_len; size_t value_label_table_padding_len; size_t strl_v_len; size_t strl_o_len; int64_t data_offset; int64_t strls_offset; int64_t value_labels_offset; int ds_format; int nvar; int64_t nobs; size_t record_len; int64_t row_limit; int64_t row_offset; int64_t current_row; unsigned int bswap:1; unsigned int machine_is_twos_complement:1; unsigned int file_is_xmlish:1; unsigned int supports_tagged_missing:1; int8_t max_int8; int16_t max_int16; int32_t max_int32; int32_t max_float; int64_t max_double; dta_strl_t **strls; size_t strls_count; size_t strls_capacity; readstat_variable_t **variables; readstat_endian_t endianness; iconv_t converter; readstat_callbacks_t handle; size_t file_size; void *user_ctx; readstat_io_t *io; int initialized; char error_buf[256]; } dta_ctx_t; #define DTA_HILO 0x01 #define DTA_LOHI 0x02 #define DTA_OLD_MAX_INT8 0x7e #define DTA_OLD_MAX_INT16 0x7ffe #define DTA_OLD_MAX_INT32 0x7ffffffe #define DTA_OLD_MAX_FLOAT 0x7effffff // +1.7e38f #define DTA_OLD_MAX_DOUBLE 0x7fdfffffffffffffL // +8.9e307 #define DTA_OLD_MISSING_INT8 0x7F #define DTA_OLD_MISSING_INT16 0x7FFF #define DTA_OLD_MISSING_INT32 0x7FFFFFFF #define DTA_OLD_MISSING_FLOAT 0x7F000000 #define DTA_OLD_MISSING_DOUBLE 0x7FE0000000000000L #define DTA_113_MAX_INT8 0x64 #define DTA_113_MAX_INT16 0x7fe4 #define DTA_113_MAX_INT32 0x7fffffe4 #define DTA_113_MAX_FLOAT 0x7effffff // +1.7e38f #define DTA_113_MAX_DOUBLE 0x7fdfffffffffffffL // +8.9e307 #define DTA_113_MISSING_INT8 0x65 #define DTA_113_MISSING_INT16 0x7FE5 #define DTA_113_MISSING_INT32 0x7FFFFFE5 #define DTA_113_MISSING_FLOAT 0x7F000000 #define DTA_113_MISSING_DOUBLE 0x7FE0000000000000L #define DTA_113_MISSING_INT8_A (DTA_113_MISSING_INT8+1) #define DTA_113_MISSING_INT16_A (DTA_113_MISSING_INT16+1) #define DTA_113_MISSING_INT32_A (DTA_113_MISSING_INT32+1) #define DTA_113_MISSING_FLOAT_A (DTA_113_MISSING_FLOAT+0x0800) #define DTA_113_MISSING_DOUBLE_A (DTA_113_MISSING_DOUBLE+0x010000000000) #define DTA_GSO_TYPE_BINARY 0x81 #define DTA_GSO_TYPE_ASCII 0x82 #define DTA_117_TYPE_CODE_INT8 0xFFFA #define DTA_117_TYPE_CODE_INT16 0xFFF9 #define DTA_117_TYPE_CODE_INT32 0xFFF8 #define DTA_117_TYPE_CODE_FLOAT 0xFFF7 #define DTA_117_TYPE_CODE_DOUBLE 0xFFF6 #define DTA_117_TYPE_CODE_STRL 0x8000 #define DTA_111_TYPE_CODE_INT8 0xFB #define DTA_111_TYPE_CODE_INT16 0xFC #define DTA_111_TYPE_CODE_INT32 0xFD #define DTA_111_TYPE_CODE_FLOAT 0xFE #define DTA_111_TYPE_CODE_DOUBLE 0xFF #define DTA_OLD_TYPE_CODE_INT8 'b' #define DTA_OLD_TYPE_CODE_INT16 'i' #define DTA_OLD_TYPE_CODE_INT32 'l' #define DTA_OLD_TYPE_CODE_FLOAT 'f' #define DTA_OLD_TYPE_CODE_DOUBLE 'd' dta_ctx_t *dta_ctx_alloc(readstat_io_t *io); readstat_error_t dta_ctx_init(dta_ctx_t *ctx, uint32_t nvar, uint64_t nobs, unsigned char byteorder, unsigned char ds_format, const char *input_encoding, const char *output_encoding); void dta_ctx_free(dta_ctx_t *ctx); readstat_error_t dta_type_info(uint16_t typecode, dta_ctx_t *ctx, size_t *max_len, readstat_type_t *out_type); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/stata/readstat_dta_parse_timestamp.c0000644023477200000240000002460314574360757023615 0ustar00fajardoostaffs#line 1 "src/stata/readstat_dta_parse_timestamp.rl" #include #include "../readstat.h" #include "readstat_dta_parse_timestamp.h" #line 9 "src/stata/readstat_dta_parse_timestamp.c" static const signed char _dta_timestamp_parse_actions[] = { 0, 1, 0, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 2, 1, 0, 0 }; static const signed char _dta_timestamp_parse_key_offsets[] = { 0, 0, 3, 5, 8, 26, 34, 36, 37, 39, 42, 45, 48, 50, 52, 53, 55, 59, 63, 64, 66, 68, 70, 71, 73, 75, 76, 80, 82, 86, 87, 88, 90, 96, 97, 98, 100, 102, 103, 107, 109, 110, 112, 114, 115, 0 }; static const char _dta_timestamp_parse_trans_keys[] = { 32, 48, 57, 48, 57, 32, 48, 57, 65, 68, 69, 70, 74, 77, 78, 79, 83, 97, 100, 101, 102, 106, 109, 110, 111, 115, 66, 71, 80, 85, 98, 103, 112, 117, 82, 114, 32, 48, 57, 32, 48, 57, 32, 48, 57, 58, 48, 57, 48, 57, 79, 111, 32, 71, 103, 69, 73, 101, 105, 67, 90, 99, 122, 32, 67, 99, 78, 110, 69, 101, 32, 69, 101, 66, 98, 32, 65, 85, 97, 117, 78, 110, 76, 78, 108, 110, 32, 32, 65, 97, 73, 82, 89, 105, 114, 121, 32, 32, 79, 111, 86, 118, 32, 67, 75, 99, 107, 84, 116, 32, 69, 101, 80, 112, 32, 48, 57, 0 }; static const signed char _dta_timestamp_parse_single_lengths[] = { 0, 1, 0, 1, 18, 8, 2, 1, 0, 1, 1, 1, 0, 2, 1, 2, 4, 4, 1, 2, 2, 2, 1, 2, 2, 1, 4, 2, 4, 1, 1, 2, 6, 1, 1, 2, 2, 1, 4, 2, 1, 2, 2, 1, 0, 0 }; static const signed char _dta_timestamp_parse_range_lengths[] = { 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }; static const short _dta_timestamp_parse_index_offsets[] = { 0, 0, 3, 5, 8, 27, 36, 39, 41, 43, 46, 49, 52, 54, 57, 59, 62, 67, 72, 74, 77, 80, 83, 85, 88, 91, 93, 98, 101, 106, 108, 110, 113, 120, 122, 124, 127, 130, 132, 137, 140, 142, 145, 148, 150, 0 }; static const signed char _dta_timestamp_parse_cond_targs[] = { 2, 3, 0, 3, 0, 4, 3, 0, 5, 16, 20, 23, 26, 31, 35, 38, 41, 5, 16, 20, 23, 26, 31, 35, 38, 41, 0, 6, 13, 6, 15, 6, 13, 6, 15, 0, 7, 7, 0, 8, 0, 9, 0, 10, 9, 0, 10, 11, 0, 12, 11, 0, 44, 0, 14, 14, 0, 8, 0, 14, 14, 0, 17, 19, 17, 19, 0, 18, 18, 18, 18, 0, 8, 0, 18, 18, 0, 21, 21, 0, 22, 22, 0, 8, 0, 24, 24, 0, 25, 25, 0, 8, 0, 27, 28, 27, 28, 0, 22, 22, 0, 29, 30, 29, 30, 0, 8, 0, 8, 0, 32, 32, 0, 33, 34, 33, 33, 34, 33, 0, 8, 0, 8, 0, 36, 36, 0, 37, 37, 0, 8, 0, 39, 39, 39, 39, 0, 40, 40, 0, 8, 0, 42, 42, 0, 43, 43, 0, 8, 0, 44, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 0 }; static const signed char _dta_timestamp_parse_cond_actions[] = { 0, 35, 0, 35, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 35, 0, 29, 1, 0, 0, 35, 0, 31, 1, 0, 35, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 9, 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, 21, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0 }; static const short _dta_timestamp_parse_eof_trans[] = { 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 0 }; static const int dta_timestamp_parse_start = 1; static const int dta_timestamp_parse_en_main = 1; #line 9 "src/stata/readstat_dta_parse_timestamp.rl" readstat_error_t dta_parse_timestamp(const char *data, size_t len, struct tm *timestamp, readstat_error_handler error_handler, void *user_ctx) { readstat_error_t retval = READSTAT_OK; const char *p = data; const char *pe = p + len; const char *eof = pe; int cs; unsigned int temp_val = 0; #line 154 "src/stata/readstat_dta_parse_timestamp.c" { cs = (int)dta_timestamp_parse_start; } #line 159 "src/stata/readstat_dta_parse_timestamp.c" { int _klen; unsigned int _trans = 0; const char * _keys; const signed char * _acts; unsigned int _nacts; _resume: {} if ( p == pe && p != eof ) goto _out; if ( p == eof ) { if ( _dta_timestamp_parse_eof_trans[cs] > 0 ) { _trans = (unsigned int)_dta_timestamp_parse_eof_trans[cs] - 1; } } else { _keys = ( _dta_timestamp_parse_trans_keys + (_dta_timestamp_parse_key_offsets[cs])); _trans = (unsigned int)_dta_timestamp_parse_index_offsets[cs]; _klen = (int)_dta_timestamp_parse_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + _klen - 1; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _keys += _klen; _trans += (unsigned int)_klen; break; } _mid = _lower + ((_upper-_lower) >> 1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 1; else if ( ( (*( p))) > (*( _mid)) ) _lower = _mid + 1; else { _trans += (unsigned int)(_mid - _keys); goto _match; } } } _klen = (int)_dta_timestamp_parse_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_upper = _keys + (_klen<<1) - 2; const char *_mid; while ( 1 ) { if ( _upper < _lower ) { _trans += (unsigned int)_klen; break; } _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( ( (*( p))) < (*( _mid)) ) _upper = _mid - 2; else if ( ( (*( p))) > (*( _mid + 1)) ) _lower = _mid + 2; else { _trans += (unsigned int)((_mid - _keys)>>1); break; } } } _match: {} } cs = (int)_dta_timestamp_parse_cond_targs[_trans]; if ( _dta_timestamp_parse_cond_actions[_trans] != 0 ) { _acts = ( _dta_timestamp_parse_actions + (_dta_timestamp_parse_cond_actions[_trans])); _nacts = (unsigned int)(*( _acts)); _acts += 1; while ( _nacts > 0 ) { switch ( (*( _acts)) ) { case 0: { { #line 20 "src/stata/readstat_dta_parse_timestamp.rl" temp_val = 10 * temp_val + ((( (*( p)))) - '0'); } #line 244 "src/stata/readstat_dta_parse_timestamp.c" break; } case 1: { { #line 24 "src/stata/readstat_dta_parse_timestamp.rl" temp_val = 0; } #line 253 "src/stata/readstat_dta_parse_timestamp.c" break; } case 2: { { #line 26 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mday = temp_val; } #line 262 "src/stata/readstat_dta_parse_timestamp.c" break; } case 3: { { #line 29 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 0; } #line 271 "src/stata/readstat_dta_parse_timestamp.c" break; } case 4: { { #line 30 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 1; } #line 280 "src/stata/readstat_dta_parse_timestamp.c" break; } case 5: { { #line 31 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 2; } #line 289 "src/stata/readstat_dta_parse_timestamp.c" break; } case 6: { { #line 32 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 3; } #line 298 "src/stata/readstat_dta_parse_timestamp.c" break; } case 7: { { #line 33 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 4; } #line 307 "src/stata/readstat_dta_parse_timestamp.c" break; } case 8: { { #line 34 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 5; } #line 316 "src/stata/readstat_dta_parse_timestamp.c" break; } case 9: { { #line 35 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 6; } #line 325 "src/stata/readstat_dta_parse_timestamp.c" break; } case 10: { { #line 36 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 7; } #line 334 "src/stata/readstat_dta_parse_timestamp.c" break; } case 11: { { #line 37 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 8; } #line 343 "src/stata/readstat_dta_parse_timestamp.c" break; } case 12: { { #line 38 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 9; } #line 352 "src/stata/readstat_dta_parse_timestamp.c" break; } case 13: { { #line 39 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 10; } #line 361 "src/stata/readstat_dta_parse_timestamp.c" break; } case 14: { { #line 40 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_mon = 11; } #line 370 "src/stata/readstat_dta_parse_timestamp.c" break; } case 15: { { #line 42 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_year = temp_val - 1900; } #line 379 "src/stata/readstat_dta_parse_timestamp.c" break; } case 16: { { #line 44 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_hour = temp_val; } #line 388 "src/stata/readstat_dta_parse_timestamp.c" break; } case 17: { { #line 46 "src/stata/readstat_dta_parse_timestamp.rl" timestamp->tm_min = temp_val; } #line 397 "src/stata/readstat_dta_parse_timestamp.c" break; } } _nacts -= 1; _acts += 1; } } if ( p == eof ) { if ( cs >= 44 ) goto _out; } else { if ( cs != 0 ) { p += 1; goto _resume; } } _out: {} } #line 52 "src/stata/readstat_dta_parse_timestamp.rl" if (cs < #line 425 "src/stata/readstat_dta_parse_timestamp.c" 44 #line 54 "src/stata/readstat_dta_parse_timestamp.rl" || p != pe) { char error_buf[1024]; if (error_handler) { snprintf(error_buf, sizeof(error_buf), "Invalid timestamp string (length=%d): %.*s", (int)len, (int)len, data); error_handler(error_buf, user_ctx); } retval = READSTAT_ERROR_BAD_TIMESTAMP_STRING; } (void)dta_timestamp_parse_en_main; return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/stata/readstat_dta_parse_timestamp.h0000644023477200000240000000023114574360757023611 0ustar00fajardoostaffs readstat_error_t dta_parse_timestamp(const char *data, size_t len, struct tm *timestamp, readstat_error_handler error_handler, void *user_ctx); ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/stata/readstat_dta_read.c0000644023477200000240000012062014574360757021327 0ustar00fajardoostaffs #define _XOPEN_SOURCE 700 /* for strnlen */ #include #include #include #include #include #include #include #include "../readstat.h" #include "../readstat_bits.h" #include "../readstat_iconv.h" #include "../readstat_convert.h" #include "../readstat_malloc.h" #include "readstat_dta.h" #include "readstat_dta_parse_timestamp.h" #define MAX_VALUE_LABEL_LEN 32000 static readstat_error_t dta_update_progress(dta_ctx_t *ctx); static readstat_error_t dta_read_descriptors(dta_ctx_t *ctx); static readstat_error_t dta_read_tag(dta_ctx_t *ctx, const char *tag); static readstat_error_t dta_read_expansion_fields(dta_ctx_t *ctx); static readstat_error_t dta_update_progress(dta_ctx_t *ctx) { double progress = 0.0; if (ctx->row_limit > 0) progress = 1.0 * ctx->current_row / ctx->row_limit; if (ctx->handle.progress && ctx->handle.progress(progress, ctx->user_ctx) != READSTAT_HANDLER_OK) return READSTAT_ERROR_USER_ABORT; return READSTAT_OK; } static readstat_variable_t *dta_init_variable(dta_ctx_t *ctx, int i, int index_after_skipping, readstat_type_t type, size_t max_len) { readstat_variable_t *variable = calloc(1, sizeof(readstat_variable_t)); variable->type = type; variable->index = i; variable->index_after_skipping = index_after_skipping; variable->storage_width = max_len; readstat_convert(variable->name, sizeof(variable->name), &ctx->varlist[ctx->variable_name_len*i], strnlen(&ctx->varlist[ctx->variable_name_len*i], ctx->variable_name_len), ctx->converter); if (ctx->variable_labels[ctx->variable_labels_entry_len*i]) { readstat_convert(variable->label, sizeof(variable->label), &ctx->variable_labels[ctx->variable_labels_entry_len*i], strnlen(&ctx->variable_labels[ctx->variable_labels_entry_len*i], ctx->variable_labels_entry_len), ctx->converter); } if (ctx->fmtlist[ctx->fmtlist_entry_len*i]) { readstat_convert(variable->format, sizeof(variable->format), &ctx->fmtlist[ctx->fmtlist_entry_len*i], strnlen(&ctx->fmtlist[ctx->fmtlist_entry_len*i], ctx->fmtlist_entry_len), ctx->converter); if (variable->format[0] == '%') { if (variable->format[1] == '-') { variable->alignment = READSTAT_ALIGNMENT_LEFT; } else if (variable->format[1] == '~') { variable->alignment = READSTAT_ALIGNMENT_CENTER; } else { variable->alignment = READSTAT_ALIGNMENT_RIGHT; } } int display_width; if (sscanf(variable->format, "%%%ds", &display_width) == 1 || sscanf(variable->format, "%%-%ds", &display_width) == 1) { variable->display_width = display_width; } } return variable; } static readstat_error_t dta_read_chunk( dta_ctx_t *ctx, const char *start_tag, void *dst, size_t dst_len, const char *end_tag) { char *dst_buffer = (char *)dst; readstat_io_t *io = ctx->io; readstat_error_t retval = READSTAT_OK; if ((retval = dta_read_tag(ctx, start_tag)) != READSTAT_OK) goto cleanup; if (io->read(dst_buffer, dst_len, io->io_ctx) != dst_len) { retval = READSTAT_ERROR_READ; goto cleanup; } if ((retval = dta_read_tag(ctx, end_tag)) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t dta_read_map(dta_ctx_t *ctx) { if (!ctx->file_is_xmlish) return READSTAT_OK; readstat_error_t retval = READSTAT_OK; uint64_t map_buffer[14]; if ((retval = dta_read_chunk(ctx, "", map_buffer, sizeof(map_buffer), "")) != READSTAT_OK) { goto cleanup; } ctx->data_offset = ctx->bswap ? byteswap8(map_buffer[9]) : map_buffer[9]; ctx->strls_offset = ctx->bswap ? byteswap8(map_buffer[10]) : map_buffer[10]; ctx->value_labels_offset = ctx->bswap ? byteswap8(map_buffer[11]) : map_buffer[11]; cleanup: return retval; } static readstat_error_t dta_read_descriptors(dta_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; size_t buffer_len = ctx->nvar * ctx->typlist_entry_len; unsigned char *buffer = NULL; int i; if (ctx->nvar && (buffer = readstat_malloc(buffer_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if ((retval = dta_read_chunk(ctx, "", buffer, buffer_len, "")) != READSTAT_OK) goto cleanup; if (ctx->typlist_entry_len == 1) { for (i=0; invar; i++) { ctx->typlist[i] = buffer[i]; } } else if (ctx->typlist_entry_len == 2) { memcpy(ctx->typlist, buffer, buffer_len); if (ctx->bswap) { for (i=0; invar; i++) { ctx->typlist[i] = byteswap2(ctx->typlist[i]); } } } if ((retval = dta_read_chunk(ctx, "", ctx->varlist, ctx->varlist_len, "")) != READSTAT_OK) goto cleanup; if ((retval = dta_read_chunk(ctx, "", ctx->srtlist, ctx->srtlist_len, "")) != READSTAT_OK) goto cleanup; if ((retval = dta_read_chunk(ctx, "", ctx->fmtlist, ctx->fmtlist_len, "")) != READSTAT_OK) goto cleanup; if ((retval = dta_read_chunk(ctx, "", ctx->lbllist, ctx->lbllist_len, "")) != READSTAT_OK) goto cleanup; if ((retval = dta_read_chunk(ctx, "", ctx->variable_labels, ctx->variable_labels_len, "")) != READSTAT_OK) goto cleanup; cleanup: if (buffer) free(buffer); return retval; } static readstat_error_t dta_read_expansion_fields(dta_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; char *buffer = NULL; if (ctx->expansion_len_len == 0) return READSTAT_OK; if (ctx->file_is_xmlish && !ctx->handle.note) { if (io->seek(ctx->data_offset, READSTAT_SEEK_SET, io->io_ctx) == -1) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "Failed to seek to data section (offset=%" PRId64 ")", ctx->data_offset); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } return READSTAT_ERROR_SEEK; } return READSTAT_OK; } retval = dta_read_tag(ctx, ""); if (retval != READSTAT_OK) goto cleanup; while (1) { size_t len; char data_type; if (ctx->file_is_xmlish) { char start[4]; if (io->read(start, sizeof(start), io->io_ctx) != sizeof(start)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (memcmp(start, ""); if (retval != READSTAT_OK) goto cleanup; break; } else if (memcmp(start, "", sizeof(start)) != 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } data_type = 1; } else { if (io->read(&data_type, 1, io->io_ctx) != 1) { retval = READSTAT_ERROR_READ; goto cleanup; } } if (ctx->expansion_len_len == 2) { uint16_t len16; if (io->read(&len16, sizeof(uint16_t), io->io_ctx) != sizeof(uint16_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } len = ctx->bswap ? byteswap2(len16) : len16; } else { uint32_t len32; if (io->read(&len32, sizeof(uint32_t), io->io_ctx) != sizeof(uint32_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } len = ctx->bswap ? byteswap4(len32) : len32; } if (data_type == 0 && len == 0) break; if (data_type != 1 || len > (1<<20)) { retval = READSTAT_ERROR_NOTE_IS_TOO_LONG; goto cleanup; } if (ctx->handle.note && len >= 2 * ctx->ch_metadata_len) { if ((buffer = readstat_realloc(buffer, len + 1)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } buffer[len] = '\0'; if (io->read(buffer, len, io->io_ctx) != len) { retval = READSTAT_ERROR_READ; goto cleanup; } int index = 0; if (strncmp(&buffer[0], "_dta", 4) == 0 && sscanf(&buffer[ctx->ch_metadata_len], "note%d", &index) == 1) { if (ctx->handle.note(index, &buffer[2*ctx->ch_metadata_len], ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } } else { if (io->seek(len, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } } retval = dta_read_tag(ctx, ""); if (retval != READSTAT_OK) goto cleanup; } cleanup: if (buffer) free(buffer); return retval; } static readstat_error_t dta_read_tag(dta_ctx_t *ctx, const char *tag) { readstat_error_t retval = READSTAT_OK; if (ctx->initialized && !ctx->file_is_xmlish) return retval; char buffer[256]; size_t len = strlen(tag); if (ctx->io->read(buffer, len, ctx->io->io_ctx) != len) { retval = READSTAT_ERROR_READ; goto cleanup; } if (strncmp(buffer, tag, len) != 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } cleanup: return retval; } static int dta_compare_strls(const void *elem1, const void *elem2) { const dta_strl_t *key = (const dta_strl_t *)elem1; const dta_strl_t *target = *(const dta_strl_t **)elem2; if (key->o == target->o) return key->v - target->v; return key->o - target->o; } static dta_strl_t dta_interpret_strl_vo_bytes(dta_ctx_t *ctx, const unsigned char *vo_bytes) { dta_strl_t strl = {0}; if (ctx->strl_v_len == 2) { if (ctx->endianness == READSTAT_ENDIAN_BIG) { strl.v = (vo_bytes[0] << 8) + vo_bytes[1]; strl.o = (((uint64_t)vo_bytes[2] << 40) + ((uint64_t)vo_bytes[3] << 32) + ((uint64_t)vo_bytes[4] << 24) + (vo_bytes[5] << 16) + (vo_bytes[6] << 8) + vo_bytes[7]); } else { strl.v = vo_bytes[0] + (vo_bytes[1] << 8); strl.o = (vo_bytes[2] + (vo_bytes[3] << 8) + (vo_bytes[4] << 16) + ((uint64_t)vo_bytes[5] << 24) + ((uint64_t)vo_bytes[6] << 32) + ((uint64_t)vo_bytes[7] << 40)); } } else if (ctx->strl_v_len == 4) { uint32_t v, o; memcpy(&v, &vo_bytes[0], sizeof(uint32_t)); memcpy(&o, &vo_bytes[4], sizeof(uint32_t)); strl.v = ctx->bswap ? byteswap4(v) : v; strl.o = ctx->bswap ? byteswap4(o) : o; } return strl; } static readstat_error_t dta_117_read_strl(dta_ctx_t *ctx, dta_strl_t *strl) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; dta_117_strl_header_t header; if (io->read(&header, SIZEOF_DTA_117_STRL_HEADER_T, io->io_ctx) != SIZEOF_DTA_117_STRL_HEADER_T) { retval = READSTAT_ERROR_READ; goto cleanup; } strl->v = ctx->bswap ? byteswap4(header.v) : header.v; strl->o = ctx->bswap ? byteswap4(header.o) : header.o; strl->type = header.type; strl->len = ctx->bswap ? byteswap4(header.len) : header.len; cleanup: return retval; } static readstat_error_t dta_118_read_strl(dta_ctx_t *ctx, dta_strl_t *strl) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; dta_118_strl_header_t header; if (io->read(&header, SIZEOF_DTA_118_STRL_HEADER_T, io->io_ctx) != SIZEOF_DTA_118_STRL_HEADER_T) { retval = READSTAT_ERROR_READ; goto cleanup; } strl->v = ctx->bswap ? byteswap4(header.v) : header.v; strl->o = ctx->bswap ? byteswap8(header.o) : header.o; strl->type = header.type; strl->len = ctx->bswap ? byteswap4(header.len) : header.len; cleanup: return retval; } static readstat_error_t dta_read_strl(dta_ctx_t *ctx, dta_strl_t *strl) { if (ctx->strl_o_len > 4) { return dta_118_read_strl(ctx, strl); } return dta_117_read_strl(ctx, strl); } static readstat_error_t dta_read_strls(dta_ctx_t *ctx) { if (!ctx->file_is_xmlish) return READSTAT_OK; readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; if (io->seek(ctx->strls_offset, READSTAT_SEEK_SET, io->io_ctx) == -1) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "Failed to seek to strls section (offset=%" PRId64 ")", ctx->strls_offset); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_SEEK; goto cleanup; } retval = dta_read_tag(ctx, ""); if (retval != READSTAT_OK) goto cleanup; ctx->strls_capacity = 100; ctx->strls = readstat_malloc(ctx->strls_capacity * sizeof(dta_strl_t *)); while (1) { char tag[3]; if (io->read(tag, sizeof(tag), io->io_ctx) != sizeof(tag)) { retval = READSTAT_ERROR_READ; goto cleanup; } if (memcmp(tag, "GSO", sizeof(tag)) == 0) { dta_strl_t strl; retval = dta_read_strl(ctx, &strl); if (retval != READSTAT_OK) goto cleanup; if (strl.type != DTA_GSO_TYPE_ASCII) continue; if (ctx->strls_count == ctx->strls_capacity) { ctx->strls_capacity *= 2; if ((ctx->strls = readstat_realloc(ctx->strls, sizeof(dta_strl_t *) * ctx->strls_capacity)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } } dta_strl_t *strl_ptr = readstat_malloc(sizeof(dta_strl_t) + strl.len); if (strl_ptr == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } memcpy(strl_ptr, &strl, sizeof(dta_strl_t)); ctx->strls[ctx->strls_count++] = strl_ptr; if (io->read(&strl_ptr->data[0], strl_ptr->len, io->io_ctx) != strl_ptr->len) { retval = READSTAT_ERROR_READ; goto cleanup; } } else if (memcmp(tag, ""); if (retval != READSTAT_OK) goto cleanup; break; } else { retval = READSTAT_ERROR_PARSE; goto cleanup; } } cleanup: return retval; } static readstat_value_t dta_interpret_int8_bytes(dta_ctx_t *ctx, const void *buf) { readstat_value_t value = { .type = READSTAT_TYPE_INT8 }; int8_t byte = 0; memcpy(&byte, buf, sizeof(int8_t)); if (ctx->machine_is_twos_complement) { byte = ones_to_twos_complement1(byte); } if (byte > ctx->max_int8) { if (ctx->supports_tagged_missing && byte > DTA_113_MISSING_INT8) { value.tag = 'a' + (byte - DTA_113_MISSING_INT8_A); value.is_tagged_missing = 1; } else { value.is_system_missing = 1; } } value.v.i8_value = byte; return value; } static readstat_value_t dta_interpret_int16_bytes(dta_ctx_t *ctx, const void *buf) { readstat_value_t value = { .type = READSTAT_TYPE_INT16 }; int16_t num = 0; memcpy(&num, buf, sizeof(int16_t)); if (ctx->bswap) { num = byteswap2(num); } if (ctx->machine_is_twos_complement) { num = ones_to_twos_complement2(num); } if (num > ctx->max_int16) { if (ctx->supports_tagged_missing && num > DTA_113_MISSING_INT16) { value.tag = 'a' + (num - DTA_113_MISSING_INT16_A); value.is_tagged_missing = 1; } else { value.is_system_missing = 1; } } value.v.i16_value = num; return value; } static readstat_value_t dta_interpret_int32_bytes(dta_ctx_t *ctx, const void *buf) { readstat_value_t value = { .type = READSTAT_TYPE_INT32 }; int32_t num = 0; memcpy(&num, buf, sizeof(int32_t)); if (ctx->bswap) { num = byteswap4(num); } if (ctx->machine_is_twos_complement) { num = ones_to_twos_complement4(num); } if (num > ctx->max_int32) { if (ctx->supports_tagged_missing && num > DTA_113_MISSING_INT32) { value.tag = 'a' + (num - DTA_113_MISSING_INT32_A); value.is_tagged_missing = 1; } else { value.is_system_missing = 1; } } value.v.i32_value = num; return value; } static readstat_value_t dta_interpret_float_bytes(dta_ctx_t *ctx, const void *buf) { readstat_value_t value = { .type = READSTAT_TYPE_FLOAT }; float f_num = NAN; int32_t num = 0; memcpy(&num, buf, sizeof(int32_t)); if (ctx->bswap) { num = byteswap4(num); } if (num > ctx->max_float) { if (ctx->supports_tagged_missing && num > DTA_113_MISSING_FLOAT) { value.tag = 'a' + ((num - DTA_113_MISSING_FLOAT_A) >> 11); value.is_tagged_missing = 1; } else { value.is_system_missing = 1; } } else { memcpy(&f_num, &num, sizeof(int32_t)); } value.v.float_value = f_num; return value; } static readstat_value_t dta_interpret_double_bytes(dta_ctx_t *ctx, const void *buf) { readstat_value_t value = { .type = READSTAT_TYPE_DOUBLE }; double d_num = NAN; int64_t num = 0; memcpy(&num, buf, sizeof(int64_t)); if (ctx->bswap) { num = byteswap8(num); } if (num > ctx->max_double) { if (ctx->supports_tagged_missing && num > DTA_113_MISSING_DOUBLE) { value.tag = 'a' + ((num - DTA_113_MISSING_DOUBLE_A) >> 40); value.is_tagged_missing = 1; } else { value.is_system_missing = 1; } } else { memcpy(&d_num, &num, sizeof(int64_t)); } value.v.double_value = d_num; return value; } static readstat_error_t dta_handle_row(const unsigned char *buf, dta_ctx_t *ctx) { char str_buf[2048]; int j; readstat_off_t offset = 0; readstat_error_t retval = READSTAT_OK; for (j=0; jnvar; j++) { size_t max_len; readstat_value_t value = { { 0 } }; retval = dta_type_info(ctx->typlist[j], ctx, &max_len, &value.type); if (retval != READSTAT_OK) goto cleanup; if (ctx->variables[j]->skip) { offset += max_len; continue; } if (offset + max_len > ctx->record_len) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if (value.type == READSTAT_TYPE_STRING) { if (max_len == 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } size_t str_len = strnlen((const char *)&buf[offset], max_len); retval = readstat_convert(str_buf, sizeof(str_buf), (const char *)&buf[offset], str_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; value.v.string_value = str_buf; } else if (value.type == READSTAT_TYPE_STRING_REF) { dta_strl_t key = dta_interpret_strl_vo_bytes(ctx, &buf[offset]); dta_strl_t **found = bsearch(&key, ctx->strls, ctx->strls_count, sizeof(dta_strl_t *), &dta_compare_strls); if (found) { value.v.string_value = (*found)->data; } value.type = READSTAT_TYPE_STRING; } else if (value.type == READSTAT_TYPE_INT8) { value = dta_interpret_int8_bytes(ctx, &buf[offset]); } else if (value.type == READSTAT_TYPE_INT16) { value = dta_interpret_int16_bytes(ctx, &buf[offset]); } else if (value.type == READSTAT_TYPE_INT32) { value = dta_interpret_int32_bytes(ctx, &buf[offset]); } else if (value.type == READSTAT_TYPE_FLOAT) { value = dta_interpret_float_bytes(ctx, &buf[offset]); } else if (value.type == READSTAT_TYPE_DOUBLE) { value = dta_interpret_double_bytes(ctx, &buf[offset]); } if (ctx->handle.value(ctx->current_row, ctx->variables[j], value, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } offset += max_len; } cleanup: return retval; } static readstat_error_t dta_handle_rows(dta_ctx_t *ctx) { readstat_io_t *io = ctx->io; unsigned char *buf = NULL; int i; readstat_error_t retval = READSTAT_OK; if (ctx->record_len && (buf = readstat_malloc(ctx->record_len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (ctx->row_offset) { if (io->seek(ctx->record_len * ctx->row_offset, READSTAT_SEEK_CUR, io->io_ctx) == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } } for (i=0; irow_limit; i++) { if (io->read(buf, ctx->record_len, io->io_ctx) != ctx->record_len) { retval = READSTAT_ERROR_READ; goto cleanup; } if ((retval = dta_handle_row(buf, ctx)) != READSTAT_OK) { goto cleanup; } ctx->current_row++; if ((retval = dta_update_progress(ctx)) != READSTAT_OK) { goto cleanup; } } if (ctx->row_limit < ctx->nobs - ctx->row_offset) { if (io->seek(ctx->record_len * (ctx->nobs - ctx->row_offset - ctx->row_limit), READSTAT_SEEK_CUR, io->io_ctx) == -1) retval = READSTAT_ERROR_SEEK; } cleanup: if (buf) free(buf); return retval; } static readstat_error_t dta_read_data(dta_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; if (!ctx->handle.value) { return READSTAT_OK; } if (io->seek(ctx->data_offset, READSTAT_SEEK_SET, io->io_ctx) == -1) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "Failed to seek to data section (offset=%" PRId64 ")", ctx->data_offset); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_SEEK; goto cleanup; } if ((retval = dta_read_tag(ctx, "")) != READSTAT_OK) goto cleanup; if ((retval = dta_update_progress(ctx)) != READSTAT_OK) goto cleanup; if ((retval = dta_handle_rows(ctx)) != READSTAT_OK) goto cleanup; if ((retval = dta_read_tag(ctx, "")) != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t dta_read_header(dta_ctx_t *ctx, dta_header_t *header) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = ctx->io; int bswap = 0; if (io->read(header, sizeof(dta_header_t), io->io_ctx) != sizeof(dta_header_t)) { retval = READSTAT_ERROR_READ; goto cleanup; } bswap = (header->byteorder == DTA_LOHI) ^ machine_is_little_endian(); header->nvar = bswap ? byteswap2(header->nvar) : header->nvar; header->nobs = bswap ? byteswap4(header->nobs) : header->nobs; cleanup: return retval; } static readstat_error_t dta_read_xmlish_header(dta_ctx_t *ctx, dta_header64_t *header) { readstat_error_t retval = READSTAT_OK; if ((retval = dta_read_tag(ctx, "")) != READSTAT_OK) { goto cleanup; } if ((retval = dta_read_tag(ctx, "
")) != READSTAT_OK) { goto cleanup; } char ds_format[3]; if ((retval = dta_read_chunk(ctx, "", ds_format, sizeof(ds_format), "")) != READSTAT_OK) { goto cleanup; } header->ds_format = 100 * (ds_format[0] - '0') + 10 * (ds_format[1] - '0') + (ds_format[2] - '0'); char byteorder[3]; int byteswap = 0; if ((retval = dta_read_chunk(ctx, "", byteorder, sizeof(byteorder), "")) != READSTAT_OK) { goto cleanup; } if (strncmp(byteorder, "MSF", 3) == 0) { header->byteorder = DTA_HILO; } else if (strncmp(byteorder, "LSF", 3) == 0) { header->byteorder = DTA_LOHI; } else { retval = READSTAT_ERROR_PARSE; goto cleanup; } byteswap = (header->byteorder == DTA_LOHI) ^ machine_is_little_endian(); if (header->ds_format >= 119) { uint32_t nvar; if ((retval = dta_read_chunk(ctx, "", &nvar, sizeof(uint32_t), "")) != READSTAT_OK) { goto cleanup; } header->nvar = byteswap ? byteswap4(nvar) : nvar; } else { uint16_t nvar; if ((retval = dta_read_chunk(ctx, "", &nvar, sizeof(uint16_t), "")) != READSTAT_OK) { goto cleanup; } header->nvar = byteswap ? byteswap2(nvar) : nvar; } if (header->ds_format >= 118) { uint64_t nobs; if ((retval = dta_read_chunk(ctx, "", &nobs, sizeof(uint64_t), "")) != READSTAT_OK) { goto cleanup; } header->nobs = byteswap ? byteswap8(nobs) : nobs; } else { uint32_t nobs; if ((retval = dta_read_chunk(ctx, "", &nobs, sizeof(uint32_t), "")) != READSTAT_OK) { goto cleanup; } header->nobs = byteswap ? byteswap4(nobs) : nobs; } cleanup: return retval; } static readstat_error_t dta_read_label_and_timestamp(dta_ctx_t *ctx) { readstat_io_t *io = ctx->io; readstat_error_t retval = READSTAT_OK; char *data_label_buffer = NULL; char *timestamp_buffer = NULL; uint16_t label_len = 0; unsigned char timestamp_len = 0; char last_data_label_char = 0; struct tm timestamp = { .tm_isdst = -1 }; if (ctx->file_is_xmlish) { if ((retval = dta_read_tag(ctx, "")) != READSTAT_OK) { goto cleanup; } if ((retval = dta_read_tag(ctx, "")) != READSTAT_OK) { goto cleanup; } if (io->read(×tamp_len, 1, io->io_ctx) != 1) { retval = READSTAT_ERROR_READ; goto cleanup; } } else { timestamp_len = ctx->timestamp_len; } if (timestamp_len) { timestamp_buffer = readstat_malloc(timestamp_len); if (io->read(timestamp_buffer, timestamp_len, io->io_ctx) != timestamp_len) { retval = READSTAT_ERROR_READ; goto cleanup; } if (!ctx->file_is_xmlish) timestamp_len--; if (timestamp_buffer[0]) { if (timestamp_buffer[timestamp_len-1] == '\0' && last_data_label_char != '\0') { /* Stupid hack for miswritten files with off-by-one timestamp, DTA 114 era? */ memmove(timestamp_buffer+1, timestamp_buffer, timestamp_len-1); timestamp_buffer[0] = last_data_label_char; } if (dta_parse_timestamp(timestamp_buffer, timestamp_len, ×tamp, ctx->handle.error, ctx->user_ctx) == READSTAT_OK) { ctx->timestamp = mktime(×tamp); } } } if ((retval = dta_read_tag(ctx, "")) != READSTAT_OK) { goto cleanup; } cleanup: if (data_label_buffer) free(data_label_buffer); if (timestamp_buffer) free(timestamp_buffer); return retval; } static readstat_error_t dta_handle_variables(dta_ctx_t *ctx) { if (!ctx->handle.variable) return READSTAT_OK; readstat_error_t retval = READSTAT_OK; int i; int index_after_skipping = 0; for (i=0; invar; i++) { size_t max_len; readstat_type_t type; retval = dta_type_info(ctx->typlist[i], ctx, &max_len, &type); if (retval != READSTAT_OK) goto cleanup; if (type == READSTAT_TYPE_STRING) max_len++; /* might append NULL */ if (type == READSTAT_TYPE_STRING_REF) { type = READSTAT_TYPE_STRING; max_len = 0; } ctx->variables[i] = dta_init_variable(ctx, i, index_after_skipping, type, max_len); const char *value_labels = NULL; if (ctx->lbllist[ctx->lbllist_entry_len*i]) value_labels = &ctx->lbllist[ctx->lbllist_entry_len*i]; int cb_retval = ctx->handle.variable(i, ctx->variables[i], value_labels, ctx->user_ctx); if (cb_retval == READSTAT_HANDLER_ABORT) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } if (cb_retval == READSTAT_HANDLER_SKIP_VARIABLE) { ctx->variables[i]->skip = 1; } else { index_after_skipping++; } } cleanup: return retval; } static readstat_error_t dta_handle_value_labels(dta_ctx_t *ctx) { readstat_io_t *io = ctx->io; readstat_error_t retval = READSTAT_OK; char *table_buffer = NULL; char *utf8_buffer = NULL; if (io->seek(ctx->value_labels_offset, READSTAT_SEEK_SET, io->io_ctx) == -1) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "Failed to seek to value labels section (offset=%" PRId64 ")", ctx->value_labels_offset); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_SEEK; goto cleanup; } if ((retval = dta_read_tag(ctx, "")) != READSTAT_OK) { goto cleanup; } if (!ctx->handle.value_label) { return READSTAT_OK; } while (1) { size_t len = 0; char labname[129]; uint32_t i = 0, n = 0; if (ctx->value_label_table_len_len == 2) { int16_t table_header_len; if (io->read(&table_header_len, sizeof(int16_t), io->io_ctx) < sizeof(int16_t)) break; len = table_header_len; if (ctx->bswap) len = byteswap2(table_header_len); n = len / 8; } else { if (dta_read_tag(ctx, "") != READSTAT_OK) { break; } int32_t table_header_len; if (io->read(&table_header_len, sizeof(int32_t), io->io_ctx) < sizeof(int32_t)) break; len = table_header_len; if (ctx->bswap) len = byteswap4(table_header_len); } if (io->read(labname, ctx->value_label_table_labname_len, io->io_ctx) < ctx->value_label_table_labname_len) break; if (io->seek(ctx->value_label_table_padding_len, READSTAT_SEEK_CUR, io->io_ctx) == -1) break; if ((table_buffer = readstat_realloc(table_buffer, len)) == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (io->read(table_buffer, len, io->io_ctx) < len) { break; } if (ctx->value_label_table_len_len == 2) { for (i=0; iconverter); if (retval != READSTAT_OK) goto cleanup; if (label_buf[0] && ctx->handle.value_label(labname, value, label_buf, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } } else if (len >= 8) { if ((retval = dta_read_tag(ctx, "")) != READSTAT_OK) { goto cleanup; } n = *(uint32_t *)table_buffer; uint32_t txtlen = *((uint32_t *)table_buffer+1); if (ctx->bswap) { n = byteswap4(n); txtlen = byteswap4(txtlen); } if (txtlen > len - 8 || n > (len - 8 - txtlen) / 8) { break; } uint32_t *off = (uint32_t *)table_buffer+2; uint32_t *val = (uint32_t *)table_buffer+2+n; char *txt = &table_buffer[8LL*n+8]; size_t utf8_buffer_len = 4*txtlen+1; if (txtlen > MAX_VALUE_LABEL_LEN+1) utf8_buffer_len = 4*MAX_VALUE_LABEL_LEN+1; utf8_buffer = realloc(utf8_buffer, utf8_buffer_len); /* Much bigger than we need but whatever */ if (utf8_buffer == NULL) { retval = READSTAT_ERROR_MALLOC; goto cleanup; } if (ctx->bswap) { for (i=0; i= txtlen) { retval = READSTAT_ERROR_PARSE; goto cleanup; } readstat_value_t value = dta_interpret_int32_bytes(ctx, &val[i]); size_t max_label_len = txtlen - off[i]; if (max_label_len > MAX_VALUE_LABEL_LEN) max_label_len = MAX_VALUE_LABEL_LEN; size_t label_len = strnlen(&txt[off[i]], max_label_len); retval = readstat_convert(utf8_buffer, utf8_buffer_len, &txt[off[i]], label_len, ctx->converter); if (retval != READSTAT_OK) goto cleanup; if (ctx->handle.value_label(labname, value, utf8_buffer, ctx->user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } } } cleanup: if (table_buffer) free(table_buffer); if (utf8_buffer) free(utf8_buffer); return retval; } readstat_error_t readstat_parse_dta(readstat_parser_t *parser, const char *path, void *user_ctx) { readstat_error_t retval = READSTAT_OK; readstat_io_t *io = parser->io; int i; dta_ctx_t *ctx; size_t file_size = 0; ctx = dta_ctx_alloc(io); if (io->open(path, io->io_ctx) == -1) { retval = READSTAT_ERROR_OPEN; goto cleanup; } char magic[4]; if (io->read(magic, 4, io->io_ctx) != 4) { retval = READSTAT_ERROR_READ; goto cleanup; } file_size = io->seek(0, READSTAT_SEEK_END, io->io_ctx); if (file_size == -1) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "Failed to seek to end of file"); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_SEEK; goto cleanup; } if (io->seek(0, READSTAT_SEEK_SET, io->io_ctx) == -1) { if (ctx->handle.error) { snprintf(ctx->error_buf, sizeof(ctx->error_buf), "Failed to seek to start of file"); ctx->handle.error(ctx->error_buf, ctx->user_ctx); } retval = READSTAT_ERROR_SEEK; goto cleanup; } if (strncmp(magic, "input_encoding, parser->output_encoding); } else { dta_header_t header; if ((retval = dta_read_header(ctx, &header)) != READSTAT_OK) { goto cleanup; } retval = dta_ctx_init(ctx, header.nvar, header.nobs, header.byteorder, header.ds_format, parser->input_encoding, parser->output_encoding); } if (retval != READSTAT_OK) { goto cleanup; } ctx->user_ctx = user_ctx; ctx->file_size = file_size; ctx->handle = parser->handlers; if (parser->row_offset > 0) ctx->row_offset = parser->row_offset; int64_t nobs_after_skipping = ctx->nobs - ctx->row_offset; if (nobs_after_skipping < 0) { nobs_after_skipping = 0; ctx->row_offset = ctx->nobs; } ctx->row_limit = nobs_after_skipping; if (parser->row_limit > 0 && parser->row_limit < nobs_after_skipping) ctx->row_limit = parser->row_limit; retval = dta_update_progress(ctx); if (retval != READSTAT_OK) goto cleanup; if ((retval = dta_read_label_and_timestamp(ctx)) != READSTAT_OK) goto cleanup; if ((retval = dta_read_tag(ctx, "
")) != READSTAT_OK) { goto cleanup; } if (ctx->handle.metadata) { readstat_metadata_t metadata = { .row_count = ctx->row_limit, .var_count = ctx->nvar, .file_label = ctx->data_label, .creation_time = ctx->timestamp, .modified_time = ctx->timestamp, .file_format_version = ctx->ds_format, .is64bit = ctx->ds_format >= 118, .endianness = ctx->endianness }; if (ctx->handle.metadata(&metadata, user_ctx) != READSTAT_HANDLER_OK) { retval = READSTAT_ERROR_USER_ABORT; goto cleanup; } } if ((retval = dta_read_map(ctx)) != READSTAT_OK) { retval = READSTAT_ERROR_READ; goto cleanup; } if ((retval = dta_read_descriptors(ctx)) != READSTAT_OK) { goto cleanup; } for (i=0; invar; i++) { size_t max_len; if ((retval = dta_type_info(ctx->typlist[i], ctx, &max_len, NULL)) != READSTAT_OK) goto cleanup; ctx->record_len += max_len; } if ((ctx->nvar > 0 || ctx->nobs > 0) && ctx->record_len == 0) { retval = READSTAT_ERROR_PARSE; goto cleanup; } if ((retval = dta_handle_variables(ctx)) != READSTAT_OK) goto cleanup; if ((retval = dta_read_expansion_fields(ctx)) != READSTAT_OK) goto cleanup; if (!ctx->file_is_xmlish) { ctx->data_offset = io->seek(0, READSTAT_SEEK_CUR, io->io_ctx); if (ctx->data_offset == -1) { retval = READSTAT_ERROR_SEEK; goto cleanup; } ctx->value_labels_offset = ctx->data_offset + ctx->record_len * ctx->nobs; } if ((retval = dta_read_strls(ctx)) != READSTAT_OK) goto cleanup; if ((retval = dta_read_data(ctx)) != READSTAT_OK) goto cleanup; if ((retval = dta_handle_value_labels(ctx)) != READSTAT_OK) goto cleanup; cleanup: io->close(io->io_ctx); if (ctx) dta_ctx_free(ctx); return retval; } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/src/stata/readstat_dta_write.c0000644023477200000240000014207214574360757021553 0ustar00fajardoostaffs #include #include #include #include #include #include #include "../readstat.h" #include "../readstat_bits.h" #include "../readstat_iconv.h" #include "../readstat_writer.h" #include "readstat_dta.h" #define DTA_DEFAULT_DISPLAY_WIDTH_BYTE 8 #define DTA_DEFAULT_DISPLAY_WIDTH_INT16 8 #define DTA_DEFAULT_DISPLAY_WIDTH_INT32 12 #define DTA_DEFAULT_DISPLAY_WIDTH_FLOAT 9 #define DTA_DEFAULT_DISPLAY_WIDTH_DOUBLE 10 #define DTA_DEFAULT_DISPLAY_WIDTH_STRING 9 #define DTA_FILE_VERSION_MIN 104 #define DTA_FILE_VERSION_MAX 119 #define DTA_FILE_VERSION_DEFAULT 118 #define DTA_OLD_MAX_WIDTH 128 #define DTA_111_MAX_WIDTH 244 #define DTA_117_MAX_WIDTH 2045 #define DTA_OLD_MAX_NAME_LEN 9 #define DTA_110_MAX_NAME_LEN 33 #define DTA_118_MAX_NAME_LEN 129 static readstat_error_t dta_113_write_missing_numeric(void *row, const readstat_variable_t *var); static readstat_error_t dta_write_tag(readstat_writer_t *writer, dta_ctx_t *ctx, const char *tag) { if (!ctx->file_is_xmlish) return READSTAT_OK; return readstat_write_string(writer, tag); } static readstat_error_t dta_write_chunk(readstat_writer_t *writer, dta_ctx_t *ctx, const char *start_tag, const void *bytes, size_t len, const char *end_tag) { readstat_error_t error = READSTAT_OK; if ((error = dta_write_tag(writer, ctx, start_tag)) != READSTAT_OK) goto cleanup; if ((error = readstat_write_bytes(writer, bytes, len)) != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, end_tag)) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_emit_header_data_label(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; char *data_label = NULL; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; cleanup: if (data_label) free(data_label); return error; } static readstat_error_t dta_emit_header_time_stamp(readstat_writer_t *writer, dta_ctx_t *ctx) { if (!ctx->timestamp_len) return READSTAT_OK; readstat_error_t error = READSTAT_OK; time_t now = writer->timestamp; struct tm *time_s = localtime(&now); char *timestamp = calloc(1, ctx->timestamp_len); /* There are locale/portability issues with strftime so hack something up */ char months[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; if (!time_s) { error = READSTAT_ERROR_BAD_TIMESTAMP_VALUE; goto cleanup; } if (!timestamp) { error = READSTAT_ERROR_MALLOC; goto cleanup; } uint8_t actual_timestamp_len = snprintf(timestamp, ctx->timestamp_len, "%02d %3s %04d %02d:%02d", time_s->tm_mday, months[time_s->tm_mon], time_s->tm_year + 1900, time_s->tm_hour, time_s->tm_min); if (actual_timestamp_len == 0) { error = READSTAT_ERROR_WRITE; goto cleanup; } if (ctx->file_is_xmlish) { if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; if ((error = readstat_write_bytes(writer, &actual_timestamp_len, sizeof(uint8_t))) != READSTAT_OK) goto cleanup; if ((error = readstat_write_bytes(writer, timestamp, actual_timestamp_len)) != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; } else { error = readstat_write_bytes(writer, timestamp, ctx->timestamp_len); } cleanup: free(timestamp); return error; } static readstat_error_t dta_111_typecode_for_variable(readstat_variable_t *r_variable, uint16_t *out_typecode) { readstat_error_t retval = READSTAT_OK; size_t max_len = r_variable->storage_width; uint16_t typecode = 0; switch (r_variable->type) { case READSTAT_TYPE_INT8: typecode = DTA_111_TYPE_CODE_INT8; break; case READSTAT_TYPE_INT16: typecode = DTA_111_TYPE_CODE_INT16; break; case READSTAT_TYPE_INT32: typecode = DTA_111_TYPE_CODE_INT32; break; case READSTAT_TYPE_FLOAT: typecode = DTA_111_TYPE_CODE_FLOAT; break; case READSTAT_TYPE_DOUBLE: typecode = DTA_111_TYPE_CODE_DOUBLE; break; case READSTAT_TYPE_STRING: typecode = max_len; break; case READSTAT_TYPE_STRING_REF: retval = READSTAT_ERROR_STRING_REFS_NOT_SUPPORTED; break; } if (out_typecode && retval == READSTAT_OK) *out_typecode = typecode; return retval; } static readstat_error_t dta_117_typecode_for_variable(readstat_variable_t *r_variable, uint16_t *out_typecode) { readstat_error_t retval = READSTAT_OK; size_t max_len = r_variable->storage_width; uint16_t typecode = 0; switch (r_variable->type) { case READSTAT_TYPE_INT8: typecode = DTA_117_TYPE_CODE_INT8; break; case READSTAT_TYPE_INT16: typecode = DTA_117_TYPE_CODE_INT16; break; case READSTAT_TYPE_INT32: typecode = DTA_117_TYPE_CODE_INT32; break; case READSTAT_TYPE_FLOAT: typecode = DTA_117_TYPE_CODE_FLOAT; break; case READSTAT_TYPE_DOUBLE: typecode = DTA_117_TYPE_CODE_DOUBLE; break; case READSTAT_TYPE_STRING: typecode = max_len; break; case READSTAT_TYPE_STRING_REF: typecode = DTA_117_TYPE_CODE_STRL; break; } if (out_typecode) *out_typecode = typecode; return retval; } static readstat_error_t dta_old_typecode_for_variable(readstat_variable_t *r_variable, uint16_t *out_typecode) { readstat_error_t retval = READSTAT_OK; size_t max_len = r_variable->storage_width; uint16_t typecode = 0; switch (r_variable->type) { case READSTAT_TYPE_INT8: typecode = DTA_OLD_TYPE_CODE_INT8; break; case READSTAT_TYPE_INT16: typecode = DTA_OLD_TYPE_CODE_INT16; break; case READSTAT_TYPE_INT32: typecode = DTA_OLD_TYPE_CODE_INT32; break; case READSTAT_TYPE_FLOAT: typecode = DTA_OLD_TYPE_CODE_FLOAT; break; case READSTAT_TYPE_DOUBLE: typecode = DTA_OLD_TYPE_CODE_DOUBLE; break; case READSTAT_TYPE_STRING: typecode = max_len + 0x7F; break; case READSTAT_TYPE_STRING_REF: retval = READSTAT_ERROR_STRING_REFS_NOT_SUPPORTED; break; } if (out_typecode && retval == READSTAT_OK) *out_typecode = typecode; return retval; } static readstat_error_t dta_typecode_for_variable(readstat_variable_t *r_variable, int typlist_version, uint16_t *typecode) { if (typlist_version == 111) { return dta_111_typecode_for_variable(r_variable, typecode); } if (typlist_version == 117) { return dta_117_typecode_for_variable(r_variable, typecode); } return dta_old_typecode_for_variable(r_variable, typecode); } static readstat_error_t dta_emit_typlist(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; int i; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; for (i=0; invar; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); uint16_t typecode = 0; error = dta_typecode_for_variable(r_variable, ctx->typlist_version, &typecode); if (error != READSTAT_OK) goto cleanup; ctx->typlist[i] = typecode; } for (i=0; invar; i++) { if (ctx->typlist_entry_len == 1) { uint8_t byte = ctx->typlist[i]; error = readstat_write_bytes(writer, &byte, sizeof(uint8_t)); } else if (ctx->typlist_entry_len == 2) { uint16_t val = ctx->typlist[i]; error = readstat_write_bytes(writer, &val, sizeof(uint16_t)); } if (error != READSTAT_OK) goto cleanup; } if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_validate_name_chars(const char *name, int unicode) { /* TODO check Unicode class */ int j; for (j=0; name[j]; j++) { if (((unsigned char)name[j] < 0x80 || !unicode) && name[j] != '_' && !(name[j] >= 'a' && name[j] <= 'z') && !(name[j] >= 'A' && name[j] <= 'Z') && !(name[j] >= '0' && name[j] <= '9')) { return READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER; } } char first_char = name[0]; if (((unsigned char)first_char < 0x80 || !unicode) && first_char != '_' && !(first_char >= 'a' && first_char <= 'z') && !(first_char >= 'A' && first_char <= 'Z')) { return READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER; } return READSTAT_OK; } static readstat_error_t dta_validate_name_unreserved(const char *name) { if (strcmp(name, "_all") == 0 || strcmp(name, "_b") == 0 || strcmp(name, "byte") == 0 || strcmp(name, "_coef") == 0 || strcmp(name, "_cons") == 0 || strcmp(name, "double") == 0 || strcmp(name, "float") == 0 || strcmp(name, "if") == 0 || strcmp(name, "in") == 0 || strcmp(name, "int") == 0 || strcmp(name, "long") == 0 || strcmp(name, "_n") == 0 || strcmp(name, "_N") == 0 || strcmp(name, "_pi") == 0 || strcmp(name, "_pred") == 0 || strcmp(name, "_rc") == 0 || strcmp(name, "_skip") == 0 || strcmp(name, "strL") == 0 || strcmp(name, "using") == 0 || strcmp(name, "with") == 0) { return READSTAT_ERROR_NAME_IS_RESERVED_WORD; } int len; if (sscanf(name, "str%d", &len) == 1) return READSTAT_ERROR_NAME_IS_RESERVED_WORD; return READSTAT_OK; } static readstat_error_t dta_validate_name(const char *name, int unicode, size_t max_len) { readstat_error_t error = READSTAT_OK; if (strlen(name) > max_len) return READSTAT_ERROR_NAME_IS_TOO_LONG; if (strlen(name) == 0) return READSTAT_ERROR_NAME_IS_ZERO_LENGTH; if ((error = dta_validate_name_chars(name, unicode)) != READSTAT_OK) return error; return dta_validate_name_unreserved(name); } static readstat_error_t dta_old_variable_ok(const readstat_variable_t *variable) { return dta_validate_name(readstat_variable_get_name(variable), 0, DTA_OLD_MAX_NAME_LEN); } static readstat_error_t dta_110_variable_ok(const readstat_variable_t *variable) { return dta_validate_name(readstat_variable_get_name(variable), 0, DTA_110_MAX_NAME_LEN); } static readstat_error_t dta_118_variable_ok(const readstat_variable_t *variable) { return dta_validate_name(readstat_variable_get_name(variable), 1, DTA_118_MAX_NAME_LEN); } static readstat_error_t dta_emit_varlist(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; int i; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; for (i=0; invar; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); strncpy(&ctx->varlist[ctx->variable_name_len*i], r_variable->name, ctx->variable_name_len); } if ((error = readstat_write_bytes(writer, ctx->varlist, ctx->varlist_len)) != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_emit_srtlist(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; memset(ctx->srtlist, '\0', ctx->srtlist_len); if ((error = readstat_write_bytes(writer, ctx->srtlist, ctx->srtlist_len)) != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_emit_fmtlist(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; int i; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; for (i=0; invar; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); if (r_variable->format[0]) { strncpy(&ctx->fmtlist[ctx->fmtlist_entry_len*i], r_variable->format, ctx->fmtlist_entry_len); } else { char format_letter = 'g'; int display_width = r_variable->display_width; if (readstat_type_class(r_variable->type) == READSTAT_TYPE_CLASS_STRING) { format_letter = 's'; } if (!display_width) { if (r_variable->type == READSTAT_TYPE_INT8) { display_width = DTA_DEFAULT_DISPLAY_WIDTH_BYTE; } else if (r_variable->type == READSTAT_TYPE_INT16) { display_width = DTA_DEFAULT_DISPLAY_WIDTH_INT16; } else if (r_variable->type == READSTAT_TYPE_INT32) { display_width = DTA_DEFAULT_DISPLAY_WIDTH_INT32; } else if (r_variable->type == READSTAT_TYPE_FLOAT) { display_width = DTA_DEFAULT_DISPLAY_WIDTH_FLOAT; } else if (r_variable->type == READSTAT_TYPE_DOUBLE) { display_width = DTA_DEFAULT_DISPLAY_WIDTH_DOUBLE; } else { display_width = DTA_DEFAULT_DISPLAY_WIDTH_STRING; } } char format[64]; if (format_letter == 'g') { snprintf(format, sizeof(format), "%%%s%d.0g", r_variable->alignment == READSTAT_ALIGNMENT_LEFT ? "-" : "", display_width); } else { snprintf(format, sizeof(format), "%%%s%ds", r_variable->alignment == READSTAT_ALIGNMENT_LEFT ? "-" : "", display_width); } strncpy(&ctx->fmtlist[ctx->fmtlist_entry_len*i], format, ctx->fmtlist_entry_len); } } if ((error = readstat_write_bytes(writer, ctx->fmtlist, ctx->fmtlist_len)) != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_emit_lbllist(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; int i; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; for (i=0; invar; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); if (r_variable->label_set) { strncpy(&ctx->lbllist[ctx->lbllist_entry_len*i], r_variable->label_set->name, ctx->lbllist_entry_len); } else { memset(&ctx->lbllist[ctx->lbllist_entry_len*i], '\0', ctx->lbllist_entry_len); } } if ((error = readstat_write_bytes(writer, ctx->lbllist, ctx->lbllist_len)) != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_emit_descriptors(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; error = dta_emit_typlist(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_varlist(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_srtlist(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_fmtlist(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_lbllist(writer, ctx); if (error != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_emit_variable_labels(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; int i; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; for (i=0; invar; i++) { readstat_variable_t *r_variable = readstat_get_variable(writer, i); strncpy(&ctx->variable_labels[ctx->variable_labels_entry_len*i], r_variable->label, ctx->variable_labels_entry_len); } if ((error = readstat_write_bytes(writer, ctx->variable_labels, ctx->variable_labels_len)) != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_emit_characteristics(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; int i; char *buffer = NULL; if (ctx->expansion_len_len == 0) return READSTAT_OK; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) return error; buffer = malloc(ctx->ch_metadata_len); for (i=0; inotes_count; i++) { if (ctx->file_is_xmlish) { error = dta_write_tag(writer, ctx, ""); } else { char data_type = 1; error = readstat_write_bytes(writer, &data_type, 1); } if (error != READSTAT_OK) goto cleanup; size_t len = strlen(writer->notes[i]); if (ctx->expansion_len_len == 2) { int16_t len16 = 2*ctx->ch_metadata_len + len + 1; error = readstat_write_bytes(writer, &len16, sizeof(len16)); } else if (ctx->expansion_len_len == 4) { int32_t len32 = 2*ctx->ch_metadata_len + len + 1; error = readstat_write_bytes(writer, &len32, sizeof(len32)); } if (error != READSTAT_OK) goto cleanup; strncpy(buffer, "_dta", ctx->ch_metadata_len); error = readstat_write_bytes(writer, buffer, ctx->ch_metadata_len); if (error != READSTAT_OK) goto cleanup; snprintf(buffer, ctx->ch_metadata_len, "note%d", i+1); error = readstat_write_bytes(writer, buffer, ctx->ch_metadata_len); if (error != READSTAT_OK) goto cleanup; error = readstat_write_bytes(writer, writer->notes[i], len + 1); if (error != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; } if (ctx->file_is_xmlish) { error = dta_write_tag(writer, ctx, ""); } else { error = readstat_write_zeros(writer, 1 + ctx->expansion_len_len); } if (error != READSTAT_OK) goto cleanup; cleanup: free(buffer); return error; } static readstat_error_t dta_117_emit_strl_header(readstat_writer_t *writer, readstat_string_ref_t *ref) { dta_117_strl_header_t header = { .v = ref->first_v, .o = ref->first_o, .type = DTA_GSO_TYPE_ASCII, .len = ref->len }; return readstat_write_bytes(writer, &header, SIZEOF_DTA_117_STRL_HEADER_T); } static readstat_error_t dta_118_emit_strl_header(readstat_writer_t *writer, readstat_string_ref_t *ref) { dta_118_strl_header_t header = { .v = ref->first_v, .o = ref->first_o, .type = DTA_GSO_TYPE_ASCII, .len = ref->len }; return readstat_write_bytes(writer, &header, SIZEOF_DTA_118_STRL_HEADER_T); } static readstat_error_t dta_emit_strls(readstat_writer_t *writer, dta_ctx_t *ctx) { if (!ctx->file_is_xmlish) return READSTAT_OK; readstat_error_t retval = READSTAT_OK; retval = readstat_write_string(writer, ""); if (retval != READSTAT_OK) goto cleanup; int i; for (i=0; istring_refs_count; i++) { readstat_string_ref_t *ref = writer->string_refs[i]; retval = readstat_write_string(writer, "GSO"); if (retval != READSTAT_OK) goto cleanup; if (ctx->strl_o_len > 4) { retval = dta_118_emit_strl_header(writer, ref); } else { retval = dta_117_emit_strl_header(writer, ref); } if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &ref->data[0], ref->len); if (retval != READSTAT_OK) goto cleanup; } retval = readstat_write_string(writer, ""); if (retval != READSTAT_OK) goto cleanup; cleanup: return retval; } static readstat_error_t dta_old_emit_value_labels(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t retval = READSTAT_OK; int i, j; char labname[12+2]; char *label_buffer = NULL; for (i=0; ilabel_sets_count; i++) { readstat_label_set_t *r_label_set = readstat_get_label_set(writer, i); int32_t max_value = 0; for (j=0; jvalue_labels_count; j++) { readstat_value_label_t *value_label = readstat_get_value_label(r_label_set, j); if (value_label->tag) { retval = READSTAT_ERROR_TAGGED_VALUES_NOT_SUPPORTED; goto cleanup; } if (value_label->int32_key < 0 || value_label->int32_key > 1024) { retval = READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; goto cleanup; } if (value_label->int32_key > max_value) { max_value = value_label->int32_key; } } int16_t table_len = 8*(max_value + 1); retval = readstat_write_bytes(writer, &table_len, sizeof(int16_t)); if (retval != READSTAT_OK) goto cleanup; memset(labname, 0, sizeof(labname)); strncpy(labname, r_label_set->name, ctx->value_label_table_labname_len); retval = readstat_write_bytes(writer, labname, ctx->value_label_table_labname_len + ctx->value_label_table_padding_len); if (retval != READSTAT_OK) goto cleanup; label_buffer = realloc(label_buffer, table_len); memset(label_buffer, 0, table_len); for (j=0; jvalue_labels_count; j++) { readstat_value_label_t *value_label = readstat_get_value_label(r_label_set, j); size_t len = value_label->label_len; if (len > 8) len = 8; memcpy(&label_buffer[8*value_label->int32_key], value_label->label, len); } retval = readstat_write_bytes(writer, label_buffer, table_len); if (retval != READSTAT_OK) goto cleanup; } cleanup: if (label_buffer) free(label_buffer); return retval; } static int dta_compare_value_labels(const readstat_value_label_t *vl1, const readstat_value_label_t *vl2) { if (vl1->tag) { if (vl2->tag) { return vl1->tag - vl2->tag; } return 1; } if (vl2->tag) { return -1; } return vl1->int32_key - vl2->int32_key; } static readstat_error_t dta_emit_value_labels(readstat_writer_t *writer, dta_ctx_t *ctx) { if (ctx->value_label_table_len_len == 2) return dta_old_emit_value_labels(writer, ctx); readstat_error_t retval = READSTAT_OK; int i, j; int32_t *off = NULL; int32_t *val = NULL; char *txt = NULL; char *labname = calloc(1, ctx->value_label_table_labname_len + ctx->value_label_table_padding_len); retval = dta_write_tag(writer, ctx, ""); if (retval != READSTAT_OK) goto cleanup; for (i=0; ilabel_sets_count; i++) { readstat_label_set_t *r_label_set = readstat_get_label_set(writer, i); int32_t n = r_label_set->value_labels_count; int32_t txtlen = 0; for (j=0; jlabel_len + 1; } retval = dta_write_tag(writer, ctx, ""); if (retval != READSTAT_OK) goto cleanup; int32_t table_len = 8 + 8*n + txtlen; retval = readstat_write_bytes(writer, &table_len, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; strncpy(labname, r_label_set->name, ctx->value_label_table_labname_len); retval = readstat_write_bytes(writer, labname, ctx->value_label_table_labname_len + ctx->value_label_table_padding_len); if (retval != READSTAT_OK) goto cleanup; if (txtlen == 0) { retval = readstat_write_bytes(writer, &txtlen, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &txtlen, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = dta_write_tag(writer, ctx, ""); if (retval != READSTAT_OK) goto cleanup; continue; } off = realloc(off, 4*n); val = realloc(val, 4*n); txt = realloc(txt, txtlen); readstat_off_t offset = 0; readstat_sort_label_set(r_label_set, &dta_compare_value_labels); for (j=0; jlabel; size_t label_data_len = value_label->label_len; off[j] = offset; if (value_label->tag) { if (writer->version < 113) { retval = READSTAT_ERROR_TAGGED_VALUES_NOT_SUPPORTED; goto cleanup; } val[j] = DTA_113_MISSING_INT32_A + (value_label->tag - 'a'); } else { val[j] = value_label->int32_key; } memcpy(txt + offset, label, label_data_len); offset += label_data_len; txt[offset++] = '\0'; } retval = readstat_write_bytes(writer, &n, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, &txtlen, sizeof(int32_t)); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, off, 4*n); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, val, 4*n); if (retval != READSTAT_OK) goto cleanup; retval = readstat_write_bytes(writer, txt, txtlen); if (retval != READSTAT_OK) goto cleanup; retval = dta_write_tag(writer, ctx, ""); if (retval != READSTAT_OK) goto cleanup; } retval = dta_write_tag(writer, ctx, ""); if (retval != READSTAT_OK) goto cleanup; cleanup: if (off) free(off); if (val) free(val); if (txt) free(txt); if (labname) free(labname); return retval; } static size_t dta_numeric_variable_width(readstat_type_t type, size_t user_width) { size_t len = 0; if (type == READSTAT_TYPE_DOUBLE) { len = 8; } else if (type == READSTAT_TYPE_FLOAT) { len = 4; } else if (type == READSTAT_TYPE_INT32) { len = 4; } else if (type == READSTAT_TYPE_INT16) { len = 2; } else if (type == READSTAT_TYPE_INT8) { len = 1; } return len; } static size_t dta_111_variable_width(readstat_type_t type, size_t user_width) { if (type == READSTAT_TYPE_STRING) { if (user_width > DTA_111_MAX_WIDTH || user_width == 0) user_width = DTA_111_MAX_WIDTH; return user_width; } return dta_numeric_variable_width(type, user_width); } static size_t dta_117_variable_width(readstat_type_t type, size_t user_width) { if (type == READSTAT_TYPE_STRING) { if (user_width > DTA_117_MAX_WIDTH || user_width == 0) user_width = DTA_117_MAX_WIDTH; return user_width; } if (type == READSTAT_TYPE_STRING_REF) return 8; return dta_numeric_variable_width(type, user_width); } static size_t dta_old_variable_width(readstat_type_t type, size_t user_width) { if (type == READSTAT_TYPE_STRING) { if (user_width > DTA_OLD_MAX_WIDTH || user_width == 0) user_width = DTA_OLD_MAX_WIDTH; return user_width; } return dta_numeric_variable_width(type, user_width); } static readstat_error_t dta_emit_xmlish_header(readstat_writer_t *writer, dta_ctx_t *ctx) { readstat_error_t error = READSTAT_OK; if ((error = dta_write_tag(writer, ctx, "")) != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "
")) != READSTAT_OK) goto cleanup; char release[128]; snprintf(release, sizeof(release), "%ld", writer->version); if ((error = readstat_write_string(writer, release)) != READSTAT_OK) goto cleanup; error = dta_write_chunk(writer, ctx, "", machine_is_little_endian() ? "LSF" : "MSF", sizeof("MSF")-1, ""); if (error != READSTAT_OK) goto cleanup; if (writer->version >= 119) { uint32_t nvar = writer->variables_count; error = dta_write_chunk(writer, ctx, "", &nvar, sizeof(uint32_t), ""); if (error != READSTAT_OK) goto cleanup; } else { uint16_t nvar = writer->variables_count; error = dta_write_chunk(writer, ctx, "", &nvar, sizeof(uint16_t), ""); if (error != READSTAT_OK) goto cleanup; } if (writer->version >= 118) { uint64_t nobs = writer->row_count; error = dta_write_chunk(writer, ctx, "", &nobs, sizeof(uint64_t), ""); if (error != READSTAT_OK) goto cleanup; } else { uint32_t nobs = writer->row_count; error = dta_write_chunk(writer, ctx, "", &nobs, sizeof(uint32_t), ""); if (error != READSTAT_OK) goto cleanup; } error = dta_emit_header_data_label(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_header_time_stamp(writer, ctx); if (error != READSTAT_OK) goto cleanup; if ((error = dta_write_tag(writer, ctx, "
")) != READSTAT_OK) goto cleanup; cleanup: return error; } static readstat_error_t dta_emit_header(readstat_writer_t *writer, dta_ctx_t *ctx) { if (ctx->file_is_xmlish) { return dta_emit_xmlish_header(writer, ctx); } readstat_error_t error = READSTAT_OK; dta_header_t header = {0}; header.ds_format = writer->version; header.byteorder = machine_is_little_endian() ? DTA_LOHI : DTA_HILO; header.filetype = 0x01; header.unused = 0x00; header.nvar = writer->variables_count; header.nobs = writer->row_count; if (writer->variables_count > 32767) { error = READSTAT_ERROR_TOO_MANY_COLUMNS; goto cleanup; } if ((error = readstat_write_bytes(writer, &header, sizeof(dta_header_t))) != READSTAT_OK) goto cleanup; if ((error = dta_emit_header_data_label(writer, ctx)) != READSTAT_OK) goto cleanup; if ((error = dta_emit_header_time_stamp(writer, ctx)) != READSTAT_OK) goto cleanup; cleanup: return READSTAT_OK; } static size_t dta_measure_tag(dta_ctx_t *ctx, const char *tag) { if (!ctx->file_is_xmlish) return 0; return strlen(tag); } static size_t dta_measure_map(dta_ctx_t *ctx) { return (dta_measure_tag(ctx, "") + 14 * sizeof(uint64_t) + dta_measure_tag(ctx, "")); } static size_t dta_measure_typlist(dta_ctx_t *ctx) { return (dta_measure_tag(ctx, "") + ctx->typlist_entry_len * ctx->nvar + dta_measure_tag(ctx, "")); } static size_t dta_measure_varlist(dta_ctx_t *ctx) { return (dta_measure_tag(ctx, "") + ctx->varlist_len + dta_measure_tag(ctx, "")); } static size_t dta_measure_srtlist(dta_ctx_t *ctx) { return (dta_measure_tag(ctx, "") + ctx->srtlist_len + dta_measure_tag(ctx, "")); } static size_t dta_measure_fmtlist(dta_ctx_t *ctx) { return (dta_measure_tag(ctx, "") + ctx->fmtlist_len + dta_measure_tag(ctx, "")); } static size_t dta_measure_lbllist(dta_ctx_t *ctx) { return (dta_measure_tag(ctx, "") + ctx->lbllist_len + dta_measure_tag(ctx, "")); } static size_t dta_measure_variable_labels(dta_ctx_t *ctx) { return (dta_measure_tag(ctx, "") + ctx->variable_labels_len + dta_measure_tag(ctx, "")); } static size_t dta_measure_characteristics(readstat_writer_t *writer, dta_ctx_t *ctx) { size_t characteristics_len = 0; int i; for (i=0; inotes_count; i++) { size_t ch_len = dta_measure_tag(ctx, "") + ctx->expansion_len_len + 2 * ctx->ch_metadata_len + strlen(writer->notes[i]) + 1 + dta_measure_tag(ctx, ""); characteristics_len += ch_len; } return (dta_measure_tag(ctx, "") + characteristics_len + dta_measure_tag(ctx, "")); } static size_t dta_measure_data(readstat_writer_t *writer, dta_ctx_t *ctx) { int i; for (i=0; invar; i++) { size_t max_len = 0; readstat_variable_t *r_variable = readstat_get_variable(writer, i); uint16_t typecode = 0; dta_typecode_for_variable(r_variable, ctx->typlist_version, &typecode); if (dta_type_info(typecode, ctx, &max_len, NULL) == READSTAT_OK) ctx->record_len += max_len; } return (dta_measure_tag(ctx, "") + ctx->record_len * ctx->nobs + dta_measure_tag(ctx, "")); } static size_t dta_measure_strls(readstat_writer_t *writer, dta_ctx_t *ctx) { int i; size_t strls_len = 0; for (i=0; istring_refs_count; i++) { readstat_string_ref_t *ref = writer->string_refs[i]; if (ctx->strl_o_len > 4) { strls_len += sizeof("GSO") - 1 + SIZEOF_DTA_118_STRL_HEADER_T + ref->len; } else { strls_len += sizeof("GSO") - 1 + SIZEOF_DTA_117_STRL_HEADER_T + ref->len; } } return (dta_measure_tag(ctx, "") + strls_len + dta_measure_tag(ctx, "")); } static size_t dta_measure_value_labels(readstat_writer_t *writer, dta_ctx_t *ctx) { size_t len = dta_measure_tag(ctx, ""); int i, j; for (i=0; ilabel_sets_count; i++) { readstat_label_set_t *r_label_set = readstat_get_label_set(writer, i); int32_t n = r_label_set->value_labels_count; int32_t txtlen = 0; for (j=0; jlabel_len + 1; } len += dta_measure_tag(ctx, ""); len += sizeof(int32_t); len += ctx->value_label_table_labname_len; len += ctx->value_label_table_padding_len; len += 8 + 8*n + txtlen; len += dta_measure_tag(ctx, ""); } len += dta_measure_tag(ctx, ""); return len; } static readstat_error_t dta_emit_map(readstat_writer_t *writer, dta_ctx_t *ctx) { if (!ctx->file_is_xmlish) return READSTAT_OK; uint64_t map[14]; map[0] = 0; /* */ map[1] = writer->bytes_written; /* */ map[2] = map[1] + dta_measure_map(ctx); /* */ map[3] = map[2] + dta_measure_typlist(ctx); /* */ map[4] = map[3] + dta_measure_varlist(ctx); /* */ map[5] = map[4] + dta_measure_srtlist(ctx); /* */ map[6] = map[5] + dta_measure_fmtlist(ctx); /* */ map[7] = map[6] + dta_measure_lbllist(ctx); /* */ map[8] = map[7] + dta_measure_variable_labels(ctx); /* */ map[9] = map[8] + dta_measure_characteristics(writer, ctx); /* */ map[10]= map[9] + dta_measure_data(writer, ctx); /* */ map[11]= map[10]+ dta_measure_strls(writer, ctx); /* */ map[12]= map[11]+ dta_measure_value_labels(writer, ctx); /* */ map[13]= map[12]+ dta_measure_tag(ctx, "
"); return dta_write_chunk(writer, ctx, "", map, sizeof(map), ""); } static readstat_error_t dta_begin_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; readstat_error_t error = READSTAT_OK; if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; dta_ctx_t *ctx = dta_ctx_alloc(NULL); error = dta_ctx_init(ctx, writer->variables_count, writer->row_count, machine_is_little_endian() ? DTA_LOHI : DTA_HILO, writer->version, NULL, NULL); if (error != READSTAT_OK) goto cleanup; error = dta_emit_header(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_map(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_descriptors(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_variable_labels(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_characteristics(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_write_tag(writer, ctx, ""); if (error != READSTAT_OK) goto cleanup; cleanup: if (error != READSTAT_OK) { dta_ctx_free(ctx); } else { writer->module_ctx = ctx; } return error; } static readstat_error_t dta_write_raw_int8(void *row, int8_t value) { memcpy(row, &value, sizeof(char)); return READSTAT_OK; } static readstat_error_t dta_write_raw_int16(void *row, int16_t value) { memcpy(row, &value, sizeof(int16_t)); return READSTAT_OK; } static readstat_error_t dta_write_raw_int32(void *row, int32_t value) { memcpy(row, &value, sizeof(int32_t)); return READSTAT_OK; } static readstat_error_t dta_write_raw_int64(void *row, int64_t value) { memcpy(row, &value, sizeof(int64_t)); return READSTAT_OK; } static readstat_error_t dta_write_raw_float(void *row, float value) { memcpy(row, &value, sizeof(float)); return READSTAT_OK; } static readstat_error_t dta_write_raw_double(void *row, double value) { memcpy(row, &value, sizeof(double)); return READSTAT_OK; } static readstat_error_t dta_113_write_int8(void *row, const readstat_variable_t *var, int8_t value) { if (value > DTA_113_MAX_INT8) { return READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; } return dta_write_raw_int8(row, value); } static readstat_error_t dta_old_write_int8(void *row, const readstat_variable_t *var, int8_t value) { if (value > DTA_OLD_MAX_INT8) { return READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; } return dta_write_raw_int8(row, value); } static readstat_error_t dta_113_write_int16(void *row, const readstat_variable_t *var, int16_t value) { if (value > DTA_113_MAX_INT16) { return READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; } return dta_write_raw_int16(row, value); } static readstat_error_t dta_old_write_int16(void *row, const readstat_variable_t *var, int16_t value) { if (value > DTA_OLD_MAX_INT16) { return READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; } return dta_write_raw_int16(row, value); } static readstat_error_t dta_113_write_int32(void *row, const readstat_variable_t *var, int32_t value) { if (value > DTA_113_MAX_INT32) { return READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; } return dta_write_raw_int32(row, value); } static readstat_error_t dta_old_write_int32(void *row, const readstat_variable_t *var, int32_t value) { if (value > DTA_OLD_MAX_INT32) { return READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; } return dta_write_raw_int32(row, value); } static readstat_error_t dta_write_float(void *row, const readstat_variable_t *var, float value) { int32_t max_flt_i32 = DTA_113_MAX_FLOAT; float max_flt; memcpy(&max_flt, &max_flt_i32, sizeof(float)); if (value > max_flt) { return READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; } else if (isnan(value)) { return dta_113_write_missing_numeric(row, var); } return dta_write_raw_float(row, value); } static readstat_error_t dta_write_double(void *row, const readstat_variable_t *var, double value) { int64_t max_dbl_i64 = DTA_113_MAX_DOUBLE; double max_dbl; memcpy(&max_dbl, &max_dbl_i64, sizeof(double)); if (value > max_dbl) { return READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE; } else if (isnan(value)) { return dta_113_write_missing_numeric(row, var); } return dta_write_raw_double(row, value); } static readstat_error_t dta_write_string(void *row, const readstat_variable_t *var, const char *value) { size_t max_len = var->storage_width; if (value == NULL || value[0] == '\0') { memset(row, '\0', max_len); } else { size_t value_len = strlen(value); if (value_len > max_len) return READSTAT_ERROR_STRING_VALUE_IS_TOO_LONG; strncpy((char *)row, value, max_len); } return READSTAT_OK; } static readstat_error_t dta_118_write_string_ref(void *row, const readstat_variable_t *var, readstat_string_ref_t *ref) { if (ref == NULL) return READSTAT_ERROR_STRING_REF_IS_REQUIRED; int16_t v = ref->first_v; int64_t o = ref->first_o; char *row_bytes = (char *)row; memcpy(&row_bytes[0], &v, sizeof(int16_t)); if (!machine_is_little_endian()) { o <<= 16; } memcpy(&row_bytes[2], &o, 6); return READSTAT_OK; } static readstat_error_t dta_117_write_string_ref(void *row, const readstat_variable_t *var, readstat_string_ref_t *ref) { if (ref == NULL) return READSTAT_ERROR_STRING_REF_IS_REQUIRED; int32_t v = ref->first_v; int32_t o = ref->first_o; char *row_bytes = (char *)row; memcpy(&row_bytes[0], &v, sizeof(int32_t)); memcpy(&row_bytes[4], &o, sizeof(int32_t)); return READSTAT_OK; } static readstat_error_t dta_113_write_missing_numeric(void *row, const readstat_variable_t *var) { readstat_error_t retval = READSTAT_OK; if (var->type == READSTAT_TYPE_INT8) { retval = dta_write_raw_int8(row, DTA_113_MISSING_INT8); } else if (var->type == READSTAT_TYPE_INT16) { retval = dta_write_raw_int16(row, DTA_113_MISSING_INT16); } else if (var->type == READSTAT_TYPE_INT32) { retval = dta_write_raw_int32(row, DTA_113_MISSING_INT32); } else if (var->type == READSTAT_TYPE_FLOAT) { retval = dta_write_raw_int32(row, DTA_113_MISSING_FLOAT); } else if (var->type == READSTAT_TYPE_DOUBLE) { retval = dta_write_raw_int64(row, DTA_113_MISSING_DOUBLE); } return retval; } static readstat_error_t dta_old_write_missing_numeric(void *row, const readstat_variable_t *var) { readstat_error_t retval = READSTAT_OK; if (var->type == READSTAT_TYPE_INT8) { retval = dta_write_raw_int8(row, DTA_OLD_MISSING_INT8); } else if (var->type == READSTAT_TYPE_INT16) { retval = dta_write_raw_int16(row, DTA_OLD_MISSING_INT16); } else if (var->type == READSTAT_TYPE_INT32) { retval = dta_write_raw_int32(row, DTA_OLD_MISSING_INT32); } else if (var->type == READSTAT_TYPE_FLOAT) { retval = dta_write_raw_int32(row, DTA_OLD_MISSING_FLOAT); } else if (var->type == READSTAT_TYPE_DOUBLE) { retval = dta_write_raw_int64(row, DTA_OLD_MISSING_DOUBLE); } return retval; } static readstat_error_t dta_write_missing_string(void *row, const readstat_variable_t *var) { return dta_write_string(row, var, NULL); } static readstat_error_t dta_113_write_missing_tagged(void *row, const readstat_variable_t *var, char tag) { readstat_error_t retval = READSTAT_OK; if (tag < 'a' || tag > 'z') return READSTAT_ERROR_TAGGED_VALUE_IS_OUT_OF_RANGE; if (var->type == READSTAT_TYPE_INT8) { retval = dta_write_raw_int8(row, DTA_113_MISSING_INT8_A + (tag - 'a')); } else if (var->type == READSTAT_TYPE_INT16) { retval = dta_write_raw_int16(row, DTA_113_MISSING_INT16_A + (tag - 'a')); } else if (var->type == READSTAT_TYPE_INT32) { retval = dta_write_raw_int32(row, DTA_113_MISSING_INT32_A + (tag - 'a')); } else if (var->type == READSTAT_TYPE_FLOAT) { retval = dta_write_raw_int32(row, DTA_113_MISSING_FLOAT_A + ((tag - 'a') << 11)); } else if (var->type == READSTAT_TYPE_DOUBLE) { retval = dta_write_raw_int64(row, DTA_113_MISSING_DOUBLE_A + ((int64_t)(tag - 'a') << 40)); } else { retval = READSTAT_ERROR_TAGGED_VALUES_NOT_SUPPORTED; } return retval; } static readstat_error_t dta_end_data(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; dta_ctx_t *ctx = writer->module_ctx; readstat_error_t error = READSTAT_OK; if (!writer->initialized) return READSTAT_ERROR_WRITER_NOT_INITIALIZED; error = dta_write_tag(writer, ctx, ""); if (error != READSTAT_OK) goto cleanup; error = dta_emit_strls(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_emit_value_labels(writer, ctx); if (error != READSTAT_OK) goto cleanup; error = dta_write_tag(writer, ctx, "
"); if (error != READSTAT_OK) goto cleanup; cleanup: return error; } static void dta_module_ctx_free(void *module_ctx) { dta_ctx_free(module_ctx); } readstat_error_t dta_metadata_ok(void *writer_ctx) { readstat_writer_t *writer = (readstat_writer_t *)writer_ctx; if (writer->compression != READSTAT_COMPRESS_NONE) return READSTAT_ERROR_UNSUPPORTED_COMPRESSION; if (writer->version > DTA_FILE_VERSION_MAX || writer->version < DTA_FILE_VERSION_MIN) return READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION; return READSTAT_OK; } readstat_error_t readstat_begin_writing_dta(readstat_writer_t *writer, void *user_ctx, long row_count) { if (writer->version == 0) writer->version = DTA_FILE_VERSION_DEFAULT; writer->callbacks.metadata_ok = &dta_metadata_ok; if (writer->version >= 117) { writer->callbacks.variable_width = &dta_117_variable_width; } else if (writer->version >= 111) { writer->callbacks.variable_width = &dta_111_variable_width; } else { writer->callbacks.variable_width = &dta_old_variable_width; } if (writer->version >= 118) { writer->callbacks.variable_ok = &dta_118_variable_ok; } else if (writer->version >= 110) { writer->callbacks.variable_ok = &dta_110_variable_ok; } else { writer->callbacks.variable_ok = &dta_old_variable_ok; } if (writer->version >= 118) { writer->callbacks.write_string_ref = &dta_118_write_string_ref; } else if (writer->version == 117) { writer->callbacks.write_string_ref = &dta_117_write_string_ref; } if (writer->version >= 113) { writer->callbacks.write_int8 = &dta_113_write_int8; writer->callbacks.write_int16 = &dta_113_write_int16; writer->callbacks.write_int32 = &dta_113_write_int32; writer->callbacks.write_missing_number = &dta_113_write_missing_numeric; writer->callbacks.write_missing_tagged = &dta_113_write_missing_tagged; } else { writer->callbacks.write_int8 = &dta_old_write_int8; writer->callbacks.write_int16 = &dta_old_write_int16; writer->callbacks.write_int32 = &dta_old_write_int32; writer->callbacks.write_missing_number = &dta_old_write_missing_numeric; } writer->callbacks.write_float = &dta_write_float; writer->callbacks.write_double = &dta_write_double; writer->callbacks.write_string = &dta_write_string; writer->callbacks.write_missing_string = &dta_write_missing_string; writer->callbacks.begin_data = &dta_begin_data; writer->callbacks.end_data = &dta_end_data; writer->callbacks.module_ctx_free = &dta_module_ctx_free; return readstat_begin_writing_file(writer, user_ctx, row_count); } ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710418355.0 pyreadstat-1.2.7/tests/0000755023477200000240000000000014574564663014771 5ustar00fajardoostaffs././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710410703.0 pyreadstat-1.2.7/tests/test_basic.py0000644023477200000240000016403314574545717017471 0ustar00fajardoostaffs#-*- coding: utf-8 -*- # ############################################################################# # Copyright 2018 Hoffmann-La Roche # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # ############################################################################# from datetime import datetime, timedelta, date import unittest import os import sys import shutil import pandas as pd import numpy as np is_pathlib_available = False try: from pathlib import Path is_pathlib_available = True except: pass class TestBasic(unittest.TestCase): """ Test suite for pyreadstat. """ def _prepare_data(self): self.script_folder = os.path.dirname(os.path.realpath(__file__)) self.parent_folder = os.path.split(self.script_folder)[0] self.data_folder = os.path.join(self.parent_folder, "test_data") self.basic_data_folder = os.path.join(self.data_folder, "basic") self.catalog_data_folder = os.path.join(self.data_folder, "sas_catalog") self.international_data_folder = os.path.join(self.data_folder, "ínternátionál") self.missing_data_folder = os.path.join(self.data_folder, "missing_data") self.write_folder = os.path.join(self.data_folder, "write") if not os.path.isdir(self.write_folder): os.makedirs(self.write_folder) # basic pandas_csv = os.path.join(self.basic_data_folder, "sample.csv") df_pandas = pd.read_csv(pandas_csv) df_pandas["mydate"] = [datetime.strptime(x, '%Y-%m-%d').date() if type(x) == str else float('nan') for x in df_pandas["mydate"]] df_pandas["dtime"] = [datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.000000') if type(x) == str else float('nan') for x in df_pandas["dtime"]] df_pandas["mytime"] = [datetime.strptime(x, '%H:%M:%S.000000').time() if type(x) == str else float('nan') for x in df_pandas["mytime"]] df_pandas["myord"] = df_pandas["myord"].astype(float) df_pandas["mylabl"] = df_pandas["mylabl"].astype(float) self.df_pandas = df_pandas # formatted mylabl_format = {1.0:"Male", 2.0:"Female"} myord_format = {1.0:"low", 2.0:"medium", 3.0:"high"} df_pandas_formatted = df_pandas.copy() df_pandas_formatted["mylabl"] = df_pandas_formatted["mylabl"].apply(lambda x: mylabl_format[x]) df_pandas_formatted["myord"] = df_pandas_formatted["myord"].apply(lambda x: myord_format[x]) df_pandas_formatted["mylabl"] = df_pandas_formatted["mylabl"].astype("category") df_pandas_formatted["myord"] = df_pandas_formatted["myord"].astype("category") self.df_pandas_formatted = df_pandas_formatted # skip some columns self.usecols = ['mynum', 'myord'] cols_to_drop = list(set(df_pandas.columns.values.tolist()) - set(self.usecols)) self.df_usecols = df_pandas.drop(cols_to_drop, axis=1) # sas formatted sas_formatted = os.path.join(self.catalog_data_folder, "sas_formatted.csv") df_sas = pd.read_csv(sas_formatted) df_sas["SEXA"] = df_sas["SEXA"].astype("category") df_sas["SEXB"] = df_sas["SEXB"].astype("category") self.df_sas_format = df_sas # dates sas_dates = os.path.join(self.basic_data_folder, "dates.csv") df_dates1 = pd.read_csv(sas_dates) df_dates1["date"] = pd.to_datetime(df_dates1["date"]) df_dates1["dtime"] = pd.to_datetime(df_dates1["dtime"]) df_dates1["time"] = pd.to_datetime(df_dates1["time"], format='%H:%M:%S') df_dates1["time"] = df_dates1["time"].apply(lambda x: x.time()) self.df_sas_dates_as_pandas = df_dates1 df_dates2 = df_dates1.copy() df_dates2["date"] = df_dates2["date"].apply(lambda x: x.date()) self.df_sas_dates = df_dates2 self.df_sas_dates2 = pd.concat([self.df_sas_dates, pd.DataFrame([[np.NaN, pd.NaT, np.NaN]],columns=["date", "dtime", "time"])], ignore_index=True) # missing data pandas_missing_sav_csv = os.path.join(self.basic_data_folder, "sample_missing.csv") df_missing_sav = pd.read_csv(pandas_missing_sav_csv, na_values="#NULL!", keep_default_na=False) df_missing_sav["mydate"] = [datetime.strptime(x, '%Y-%m-%d').date() if type(x) == str else float('nan') for x in df_missing_sav["mydate"]] df_missing_sav["dtime"] = [datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.000000') if type(x) == str else float('nan') for x in df_missing_sav["dtime"]] df_missing_sav["mytime"] = [datetime.strptime(x, '%H:%M:%S.000000').time() if type(x) == str else float('nan') for x in df_missing_sav["mytime"]] self.df_missing_sav = df_missing_sav pandas_missing_user_sav_csv = os.path.join(self.basic_data_folder, "sample_missing_user.csv") df_user_missing_sav = pd.read_csv(pandas_missing_user_sav_csv, na_values="#NULL!", keep_default_na=False) df_user_missing_sav["mydate"] = [datetime.strptime(x, '%Y-%m-%d').date() if type(x) == str else float('nan') for x in df_user_missing_sav["mydate"]] df_user_missing_sav["dtime"] = [datetime.strptime(x, '%Y-%m-%dT%H:%M:%S.000000') if type(x) == str else float('nan') for x in df_user_missing_sav["dtime"]] df_user_missing_sav["mytime"] = [datetime.strptime(x, '%H:%M:%S.000000').time() if type(x) == str else float('nan') for x in df_user_missing_sav["mytime"]] self.df_user_missing_sav = df_user_missing_sav # no dates nodates_spss_csv = os.path.join(self.basic_data_folder, "sample_nodate_spss.csv") df_nodates_spss = pd.read_csv(nodates_spss_csv) df_nodates_spss["myord"] = df_nodates_spss["myord"].astype(float) df_nodates_spss["mylabl"] = df_nodates_spss["mylabl"].astype(float) self.df_nodates_spss = df_nodates_spss nodates_sastata_csv = os.path.join(self.basic_data_folder, "sample_nodate_sas_stata.csv") df_nodates_sastata = pd.read_csv(nodates_sastata_csv) df_nodates_sastata["myord"] = df_nodates_sastata["myord"].astype(float) df_nodates_sastata["mylabl"] = df_nodates_sastata["mylabl"].astype(float) self.df_nodates_sastata = df_nodates_sastata # character column with nan and object column with nan (object pyreadstat writer doesn't know what to do with) self.df_charnan = pd.DataFrame([[0,np.nan,np.nan],[1,"test", timedelta]], columns = ["integer", "string", "object"]) # xport files v5 vs v8 self.xptv5v8 = pd.DataFrame([[float(x)] for x in range(1,11)], columns=["i"]) # long string self.df_longstr = pd.DataFrame({ "v1": { "10001": """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ac pretium sem. Fusce aliquet augue rhoncus consequat pulvinar. In est ex, porta congue diam sed, laoreet suscipit purus. Phasellus mollis lobortis tellus at vehicula. Etiam egestas augue id massa bibendum volutpat id et ipsum. Praesent ut lorem rhoncus, pharetra risus sed, pharetra sem. In pulvinar egestas erat, id condimentum tortor tempus sed. Duis ornare lacus ut ligula congue, non convallis urna dignissim. Etiam vehicula turpis sit amet nisi finibus laoreet. Duis molestie consequat nulla, non lobortis est tempus sit amet. Quisque elit est, congue non commodo vitae, porttitor ac erat. """, "10002": "fgsdghshsgh", "10003": "gsfdgsdg", }, "v2": { "10001": "gsfdgsfdgsfg", "10002": "fgsdghshsgh", "10003": "gsfdgsdg", }, }) def setUp(self): # set paths self._prepare_data() def test_sas7bdat(self): df, meta = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "sample.sas7bdat")) self.assertTrue(df.equals(self.df_pandas)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas)) #self.assertTrue(meta.creation_time==datetime(2018, 8, 16, 18, 21, 52)) #self.assertTrue(meta.modification_time==datetime(2018, 8, 16, 18, 21, 52)) def test_sas7bdat_bincompressed(self): df, meta = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "sample_bincompressed.sas7bdat")) self.assertTrue(df.equals(self.df_pandas)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas)) def test_sas7bdat_metaonly(self): df, meta = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "sample.sas7bdat")) df2, meta2 = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "sample.sas7bdat"), metadataonly=True) self.assertTrue(df2.empty) self.assertTrue(meta.number_columns == meta2.number_columns) self.assertTrue(meta.number_rows == meta2.number_rows) self.assertTrue(meta.column_names == meta2.column_names) self.assertTrue(meta.column_labels == meta2.column_labels) self.assertTrue(meta.readstat_variable_types["mychar"]=="string") self.assertTrue(meta.readstat_variable_types["myord"]=="double") self.assertTrue(meta.readstat_variable_types["dtime"]=="double") def test_sas7bdat_usecols(self): df, meta = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "sample.sas7bdat"), usecols=self.usecols) self.assertTrue(df.equals(self.df_usecols)) self.assertTrue(meta.number_columns == len(self.usecols)) self.assertTrue(meta.column_names == self.usecols) def test_sas7bdat_international(self): """ On windows, paths with international characters are problematic. This is verifying that it is working as expected """ # in addition, this works only in python 3 if sys.version_info[0]>2: df, meta = pyreadstat.read_sas7bdat(os.path.join(self.international_data_folder, "sample.sas7bdat")) self.assertTrue(df.equals(self.df_pandas)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas)) def test_sas7bdat_nodates(self): df, meta = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "sample.sas7bdat"), disable_datetime_conversion=True) self.assertTrue(df.equals(self.df_nodates_sastata)) def test_sas7bdat_chunk(self): df, meta = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "sample.sas7bdat"), row_limit = 2, row_offset =1) df_pandas = self.df_pandas.iloc[1:3,:].reset_index(drop=True) df_pandas["dtime"] = pd.to_datetime(df_pandas["dtime"]) self.assertTrue(df.equals(df_pandas)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(df_pandas)) def test_xport(self): df, meta = pyreadstat.read_xport(os.path.join(self.basic_data_folder, "sample.xpt")) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(self.df_pandas)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas)) #self.assertTrue(meta.creation_time==datetime(2018, 8, 14, 10, 55, 46)) #self.assertTrue(meta.modification_time==datetime(2018, 8, 14, 10, 55, 46)) def test_xport_v5(self): df, meta = pyreadstat.read_xport(os.path.join(self.basic_data_folder, "sas.xpt5")) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(self.xptv5v8)) def test_xport_v8(self): df, meta = pyreadstat.read_xport(os.path.join(self.basic_data_folder, "sas.xpt8")) self.assertTrue(df.equals(self.xptv5v8)) def test_xport_metaonly(self): df, meta = pyreadstat.read_xport(os.path.join(self.basic_data_folder, "sample.xpt")) df2, meta2 = pyreadstat.read_xport(os.path.join(self.basic_data_folder, "sample.xpt"), metadataonly=True) self.assertTrue(df2.empty) self.assertTrue(meta.number_columns == meta2.number_columns) self.assertTrue(meta2.number_rows is None) self.assertTrue(meta.column_names == meta2.column_names) self.assertTrue(meta.column_labels == meta2.column_labels) def test_xport_usecols(self): # Currently readstat does not support skipping cols for XPT files, usecols = [x.upper() for x in self.usecols] df, meta = pyreadstat.pyreadstat.read_xport(os.path.join(self.basic_data_folder, "sample.xpt"), usecols=usecols) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(self.df_usecols)) self.assertTrue(meta.number_columns == len(self.usecols)) def test_xport_nodates(self): df, meta = pyreadstat.read_xport(os.path.join(self.basic_data_folder, "sample.xpt"), disable_datetime_conversion=True) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(self.df_nodates_sastata)) def test_xport_chunks(self): df, meta = pyreadstat.read_xport(os.path.join(self.basic_data_folder, "sample.xpt"), row_limit = 2, row_offset =1) df.columns = [x.lower() for x in df.columns] df_pandas = self.df_pandas.iloc[1:3,:].reset_index(drop=True) df_pandas["dtime"] = pd.to_datetime(df_pandas["dtime"]) self.assertTrue(df.equals(df_pandas)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(df_pandas)) def test_dta(self): # discard dtime and arrange time df, meta = pyreadstat.read_dta(os.path.join(self.basic_data_folder, "sample.dta")) df_pandas = self.df_pandas.copy() df_pandas["myord"] = df_pandas["myord"].astype(np.int64) df_pandas["mylabl"] = df_pandas["mylabl"].astype(np.int64) self.assertTrue(df.equals(df_pandas)) self.assertTrue(meta.number_columns == len(df_pandas.columns)) self.assertTrue(meta.number_rows == len(df_pandas)) self.assertTrue(meta.readstat_variable_types["mychar"]=="string") self.assertTrue(meta.readstat_variable_types["myord"]=="int8") self.assertTrue(meta.readstat_variable_types["dtime"]=="double") #self.assertTrue(meta.creation_time==datetime(2018, 12, 17, 14, 53)) #self.assertTrue(meta.modification_time==datetime(2018, 12, 17, 14, 53)) def test_dta_metaonly(self): df, meta = pyreadstat.read_dta(os.path.join(self.basic_data_folder, "sample.dta")) df2, meta2 = pyreadstat.read_dta(os.path.join(self.basic_data_folder, "sample.dta"), metadataonly=True) self.assertTrue(df2.empty) self.assertTrue(meta.number_columns == meta2.number_columns) self.assertTrue(meta.number_rows == meta2.number_rows) self.assertTrue(meta.column_names == meta2.column_names) self.assertTrue(meta.column_labels == meta2.column_labels) def test_dta_usecols(self): df, meta = pyreadstat.read_dta(os.path.join(self.basic_data_folder, "sample.dta"), usecols=self.usecols) df_pandas = self.df_usecols.copy() df_pandas["myord"] = df_pandas["myord"].astype(np.int64) self.assertTrue(df.equals(df_pandas)) self.assertTrue(meta.number_columns == len(self.usecols)) self.assertTrue(meta.column_names == self.usecols) def test_dta_nodates(self): df, meta = pyreadstat.read_dta(os.path.join(self.basic_data_folder,"sample.dta"), disable_datetime_conversion=True) df_pandas = self.df_nodates_sastata df_pandas["myord"] = df_pandas["myord"].astype(np.int64) df_pandas["mylabl"] = df_pandas["mylabl"].astype(np.int64) df_pandas["dtime"] = df_pandas["dtime"] * 1000 df_pandas["mytime"] = df_pandas["mytime"] * 1000 self.assertTrue(df.equals(df_pandas)) def test_dta_chunks(self): # discard dtime and arrange time df, meta = pyreadstat.read_dta(os.path.join(self.basic_data_folder, "sample.dta"), row_limit = 2, row_offset =1) df_pandas = self.df_pandas.iloc[1:3,:].reset_index(drop=True) df_pandas["dtime"] = pd.to_datetime(df_pandas["dtime"]) df_pandas["myord"] = df_pandas["myord"].astype(np.int64) df_pandas["mylabl"] = df_pandas["mylabl"].astype(np.int64) self.assertTrue(df.equals(df_pandas)) self.assertTrue(meta.number_columns == len(df_pandas.columns)) self.assertTrue(meta.number_rows == len(df_pandas)) def test_sav(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav")) self.assertTrue(df.equals(self.df_pandas)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas)) self.assertTrue(len(meta.notes)>0) self.assertTrue(meta.variable_display_width["mychar"]==9) self.assertTrue(meta.variable_storage_width["mychar"] == 8) self.assertTrue(meta.variable_measure["mychar"]=="nominal") self.assertTrue(meta.readstat_variable_types["mychar"]=="string") self.assertTrue(meta.readstat_variable_types["myord"]=="double") #self.assertTrue(meta.creation_time==datetime(2018, 8, 16, 17, 22, 33)) #self.assertTrue(meta.modification_time==datetime(2018, 8, 16, 17, 22, 33)) def test_sav_metaonly(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav")) df2, meta2 = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav"), metadataonly=True) self.assertTrue(df2.empty) self.assertTrue(meta.number_columns == meta2.number_columns) self.assertTrue(meta.number_rows == meta2.number_rows) self.assertTrue(meta.column_names == meta2.column_names) self.assertTrue(meta.column_labels == meta2.column_labels) self.assertTrue(len(meta2.notes) > 0) def test_sav_formatted(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav"), apply_value_formats=True, formats_as_category=True) #df.columns = self.df_pandas_formatted.columns self.assertTrue(df.equals(self.df_pandas_formatted)) self.assertTrue(meta.number_columns == len(self.df_pandas_formatted.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas_formatted)) self.assertTrue(len(meta.notes) > 0) def test_sav_usecols(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav"), usecols=self.usecols) self.assertTrue(df.equals(self.df_usecols)) self.assertTrue(meta.number_columns == len(self.usecols)) self.assertTrue(meta.column_names == self.usecols) def test_sav_missing(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample_missing.sav")) self.assertTrue(df.equals(self.df_missing_sav)) self.assertTrue(meta.missing_ranges == {}) df_user, meta_user = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample_missing.sav"), user_missing=True) self.assertTrue(df_user.equals(self.df_user_missing_sav)) self.assertTrue(meta_user.missing_ranges['mynum'][0]=={'lo': 2000.0, 'hi': 3000.0}) # user missing with usecols df_user, meta_user = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample_missing.sav"), user_missing=True, usecols=["mynum", "mylabl"]) df_sub = self.df_user_missing_sav[["mynum", "mylabl"]] self.assertTrue(df_user.equals(df_sub)) def test_sav_nodates(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav"), disable_datetime_conversion=True) #import pdb; pdb.set_trace() self.assertTrue(df.equals(self.df_nodates_spss)) def test_sav_chunks(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav"), row_limit = 2, row_offset =1) df_pandas = self.df_pandas.iloc[1:3,:].reset_index(drop=True) df_pandas["dtime"] = pd.to_datetime(df_pandas["dtime"]) self.assertTrue(df.equals(df_pandas)) self.assertTrue(meta.number_columns == len(df_pandas.columns)) self.assertTrue(meta.number_rows == len(df_pandas)) self.assertTrue(len(meta.notes)>0) self.assertTrue(meta.variable_display_width["mychar"]==9) self.assertTrue(meta.variable_storage_width["mychar"] == 8) self.assertTrue(meta.variable_measure["mychar"]=="nominal") def test_sav_expand(self): src = os.path.join(self.basic_data_folder, "sample.sav") dst = "~/sample.sav" shutil.copyfile(src, os.path.expanduser(dst)) df, meta = pyreadstat.read_sav(dst) os.remove(os.path.expanduser(dst)) self.assertTrue(df.equals(self.df_pandas)) def test_zsav(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.zsav")) self.assertTrue(df.equals(self.df_pandas)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas)) self.assertTrue(len(meta.notes) > 0) def test_zsav_metaonly(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.zsav")) df2, meta2 = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav"), metadataonly=True) self.assertTrue(df2.empty) self.assertTrue(meta.number_columns == meta2.number_columns) self.assertTrue(meta.number_rows == meta2.number_rows) self.assertTrue(meta.column_names == meta2.column_names) self.assertTrue(meta.column_labels == meta2.column_labels) self.assertTrue(len(meta2.notes) > 0) def test_zsav_formatted(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.zsav"), apply_value_formats=True, formats_as_category=True) self.assertTrue(df.equals(self.df_pandas_formatted)) self.assertTrue(meta.number_columns == len(self.df_pandas_formatted.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas_formatted)) self.assertTrue(len(meta.notes) > 0) def test_zsav_usecols(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.zsav"), usecols=self.usecols) self.assertTrue(df.equals(self.df_usecols)) self.assertTrue(meta.number_columns == len(self.usecols)) self.assertTrue(meta.column_names == self.usecols) def test_zsav_nodates(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.zsav"), disable_datetime_conversion=True) self.assertTrue(df.equals(self.df_nodates_spss)) def test_zsav_chunks(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.zsav"), row_limit = 2, row_offset =1) df_pandas = self.df_pandas.iloc[1:3,:].reset_index(drop=True) df_pandas["dtime"] = pd.to_datetime(df_pandas["dtime"]) self.assertTrue(df.equals(df_pandas)) self.assertTrue(meta.number_columns == len(df_pandas.columns)) self.assertTrue(meta.number_rows == len(df_pandas)) self.assertTrue(len(meta.notes)>0) self.assertTrue(meta.variable_display_width["mychar"]==9) self.assertTrue(meta.variable_storage_width["mychar"] == 8) self.assertTrue(meta.variable_measure["mychar"]=="nominal") def test_por(self): df, meta = pyreadstat.read_por(os.path.join(self.basic_data_folder, "sample.por")) df_pandas_por = self.df_pandas.copy() df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(df_pandas_por)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(df_pandas_por)) self.assertTrue(len(meta.notes) > 0) #self.assertTrue(meta.creation_time==datetime(2018, 12, 16, 17, 28, 21)) #self.assertTrue(meta.modification_time==datetime(2018, 12, 16, 17, 28, 21)) def test_por_formatted(self): df, meta = pyreadstat.read_por(os.path.join(self.basic_data_folder, "sample.por"), apply_value_formats=True, formats_as_category=True) df_pandas_por = self.df_pandas_formatted.copy() df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(df_pandas_por)) self.assertTrue(meta.number_columns == len(self.df_pandas_formatted.columns)) self.assertTrue(meta.number_rows == len(df_pandas_por)) self.assertTrue(len(meta.notes) > 0) def test_por_metaonly(self): df, meta = pyreadstat.read_por(os.path.join(self.basic_data_folder, "sample.por")) df2, meta2 = pyreadstat.read_por(os.path.join(self.basic_data_folder, "sample.por"), metadataonly=True) self.assertTrue(df2.empty) self.assertTrue(meta.number_columns == meta2.number_columns) self.assertTrue(meta2.number_rows is None) self.assertTrue(meta.column_names == meta2.column_names) self.assertTrue(meta.column_labels == meta2.column_labels) self.assertTrue(len(meta2.notes) > 0) def test_por_usecols(self): df, meta = pyreadstat.read_por(os.path.join(self.basic_data_folder, "sample.por"), usecols=["MYNUM"]) df_pandas_por = self.df_pandas[["mynum"]] df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(df_pandas_por)) self.assertTrue(meta.number_columns == len(df_pandas_por.columns.values.tolist())) def test_por_nodates(self): df, meta = pyreadstat.read_por(os.path.join(self.basic_data_folder, "sample.por"), disable_datetime_conversion=True) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(self.df_nodates_spss)) def test_por_chunks(self): df, meta = pyreadstat.read_por(os.path.join(self.basic_data_folder, "sample.por"), row_limit = 2, row_offset =1) df_pandas_por = self.df_pandas.iloc[1:3,:].reset_index(drop=True) df_pandas_por['dtime'] = pd.to_datetime(df_pandas_por.dtime) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(df_pandas_por)) self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(df_pandas_por)) self.assertTrue(len(meta.notes) > 0) def test_sas_catalog_win(self): """these sas7bdat and sasbcat where produced on windows, probably 32 bit""" dat = os.path.join(self.catalog_data_folder, "test_data_win.sas7bdat") cat = os.path.join(self.catalog_data_folder, "test_formats_win.sas7bcat") df, meta = pyreadstat.read_sas7bdat(dat, catalog_file=cat) self.assertTrue(df.equals(self.df_sas_format)) def test_sas_catalog_linux(self): """these sas7bdat and sasbcat where produced on linux 64 bit""" dat = os.path.join(self.catalog_data_folder, "test_data_linux.sas7bdat") cat = os.path.join(self.catalog_data_folder, "test_formats_linux.sas7bcat") df, meta = pyreadstat.read_sas7bdat(dat, catalog_file=cat) self.assertTrue(df.equals(self.df_sas_format)) def test_sas_dates(self): sas_file = os.path.join(self.basic_data_folder, "dates.sas7bdat") df_sas, meta = pyreadstat.read_sas7bdat(sas_file) self.assertTrue(df_sas.equals(self.df_sas_dates)) def test_sas_dates_as_pandas(self): sas_file = os.path.join(self.basic_data_folder, "dates.sas7bdat") df_sas, meta = pyreadstat.read_sas7bdat(sas_file, dates_as_pandas_datetime=True) self.assertTrue(df_sas.equals(self.df_sas_dates_as_pandas)) def test_sas_user_missing(self): sas_file = os.path.join(self.missing_data_folder, "missing_test.sas7bdat") cat_file = os.path.join(self.missing_data_folder, "missing_formats.sas7bcat") unformatted_csv = os.path.join(self.missing_data_folder, "missing_unformatted.csv") formatted_csv = os.path.join(self.missing_data_folder, "missing_sas_formatted.csv") labeled_csv = os.path.join(self.missing_data_folder, "missing_sas_labeled.csv") df_sas, meta = pyreadstat.read_sas7bdat(sas_file) df_csv = pd.read_csv(unformatted_csv) self.assertTrue(df_sas.equals(df_csv)) df_sas, meta = pyreadstat.read_sas7bdat(sas_file, user_missing=True) df_csv = pd.read_csv(formatted_csv) self.assertTrue(df_sas.equals(df_csv)) missing_user_values = {'var1':['A'],'var2': ['B'], 'var3':['C'], 'var4':['X'], 'var5':['Y'], 'var6':['Z'], 'var7':['_']} self.assertDictEqual(meta.missing_user_values, missing_user_values) df_sas, meta = pyreadstat.read_sas7bdat(sas_file, catalog_file=cat_file, user_missing=True, formats_as_category=False) df_csv = pd.read_csv(labeled_csv) self.assertTrue(df_sas.equals(df_csv)) def test_dta_user_missing(self): dta_file = os.path.join(self.missing_data_folder, "missing_test.dta") unformatted_csv = os.path.join(self.missing_data_folder, "missing_unformatted.csv") formatted_csv = os.path.join(self.missing_data_folder, "missing_dta_formatted.csv") labeled_csv = os.path.join(self.missing_data_folder, "missing_dta_labeled.csv") df_sas, meta = pyreadstat.read_dta(dta_file) df_csv = pd.read_csv(unformatted_csv) self.assertTrue(df_sas.equals(df_csv)) df_sas, meta = pyreadstat.read_dta(dta_file, user_missing=True) df_csv = pd.read_csv(formatted_csv) self.assertTrue(df_sas.equals(df_csv)) missing_user_values = {'var1':['a'],'var2': ['b'], 'var3':['c'], 'var4':['x'], 'var5':['y'], 'var6':['z']} self.assertDictEqual(meta.missing_user_values, missing_user_values) df_sas, meta = pyreadstat.read_dta(dta_file, apply_value_formats=True, user_missing=True, formats_as_category=False) df_csv = pd.read_csv(labeled_csv) self.assertTrue(df_sas.equals(df_csv)) def test_sav_user_missing(self): sav_file = os.path.join(self.missing_data_folder, "missing_test.sav") unformatted_csv = os.path.join(self.missing_data_folder, "missing_sav_unformatted.csv") formatted_csv = os.path.join(self.missing_data_folder, "missing_sav_formatted.csv") labeled_csv = os.path.join(self.missing_data_folder, "missing_sav_labeled.csv") df_sas, meta = pyreadstat.read_sav(sav_file) df_csv = pd.read_csv(unformatted_csv) self.assertTrue(df_sas.equals(df_csv)) df_sas, meta = pyreadstat.read_sav(sav_file, user_missing=True) df_csv = pd.read_csv(formatted_csv) self.assertTrue(df_sas.equals(df_csv)) df_sas, meta = pyreadstat.read_sav(sav_file, apply_value_formats=True, user_missing=True, formats_as_category=False) df_sas.loc[1, 'var1'] = int(df_sas['var1'][1]) df_sas['var1'] = df_sas['var1'].astype(str) df_csv = pd.read_csv(labeled_csv) self.assertTrue(df_sas.equals(df_csv)) def test_sav_missing_char(self): df, meta = pyreadstat.read_sav(os.path.join(self.missing_data_folder, "missing_char.sav")) mdf = pd.DataFrame([[np.nan], ["a"]], columns=["mychar"]) self.assertTrue(df.equals(mdf)) self.assertTrue(meta.missing_ranges == {}) df2, meta2 = pyreadstat.read_sav(os.path.join(self.missing_data_folder, "missing_char.sav"), user_missing=True) mdf2 = pd.DataFrame([["Z"], ["a"]], columns=["mychar"]) self.assertTrue(df2.equals(mdf2)) self.assertTrue(meta2.missing_ranges['mychar'][0]=={'lo': "Z", 'hi': "Z"}) # read in chunks def test_chunk_reader(self): fpath = os.path.join(self.basic_data_folder, "sample.sas7bdat") reader = pyreadstat.read_file_in_chunks(pyreadstat.read_sas7bdat, fpath, chunksize= 2, offset=1, limit=2, disable_datetime_conversion=True) for df, meta in reader: pass currow = self.df_nodates_sastata.iloc[1:3,:].reset_index(drop=True) self.assertTrue(df.equals(currow)) # read multiprocessing def test_multiprocess_reader(self): fpath = os.path.join(self.basic_data_folder, "sample_large.sav") df_multi, meta_multi = pyreadstat.read_file_multiprocessing(pyreadstat.read_sav, fpath) df_single, meta_single = pyreadstat.read_sav(fpath) self.assertTrue(df_multi.equals(df_single)) self.assertEqual(meta_multi.number_rows, meta_single.number_rows) def test_chunk_reader_multiprocess(self): fpath = os.path.join(self.basic_data_folder, "sample_large.sav") reader = pyreadstat.read_file_in_chunks(pyreadstat.read_sav, fpath, chunksize= 50, multiprocess=True) alldfs = list() for df, meta in reader: alldfs.append(df) df_multi = pd.concat(alldfs, axis=0, ignore_index=True) df_single, meta_single = pyreadstat.read_sav(fpath) self.assertTrue(df_multi.equals(df_single)) def test_chunk_reader_multiprocess_dict(self): fpath = os.path.join(self.basic_data_folder, "sample_large.sav") reader = pyreadstat.read_file_in_chunks(pyreadstat.read_sav, fpath, chunksize= 50, multiprocess=True, output_format='dict') alldfs = list() for chunkdict, meta in reader: df = pd.DataFrame(chunkdict) alldfs.append(df) df_multi = pd.concat(alldfs, axis=0, ignore_index=True) df_single, meta_single = pyreadstat.read_sav(fpath) self.assertTrue(df_multi.equals(df_single)) def test_multiprocess_reader_xport(self): fpath = os.path.join(self.basic_data_folder, "sample.xpt") df_multi, meta_multi = pyreadstat.read_file_multiprocessing(pyreadstat.read_xport, fpath, num_rows=1000) df_single, meta_single = pyreadstat.read_xport(fpath) self.assertTrue(df_multi.equals(df_single)) # writing def test_sav_write_basic(self): file_label = "basic write" file_note = "These are some notes" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] variable_value_labels = {'mylabl': {1.0: 'Male', 2.0: 'Female'}, 'myord': {1.0: 'low', 2.0: 'medium', 3.0: 'high'}} missing_ranges = {'mychar':['a'], 'myord': [{'hi':2, 'lo':1}]} #variable_alignment = {'mychar':"center", 'myord':"right"} variable_display_width = {'mychar':20} variable_measure = {"mychar": "nominal"} path = os.path.join(self.write_folder, "basic_write.sav") pyreadstat.write_sav(self.df_pandas, path, file_label=file_label, column_labels=col_labels, note=file_note, variable_value_labels=variable_value_labels, missing_ranges=missing_ranges, variable_display_width=variable_display_width, variable_measure=variable_measure) #, variable_alignment=variable_alignment) df, meta = pyreadstat.read_sav(path, user_missing=True) self.assertTrue(df.equals(self.df_pandas)) self.assertEqual(meta.file_label, file_label) self.assertListEqual(meta.column_labels, col_labels) self.assertEqual(meta.notes[0], file_note) self.assertDictEqual(meta.variable_value_labels, variable_value_labels) self.assertEqual(meta.variable_display_width['mychar'], variable_display_width['mychar']) #self.assertDictEqual(meta.variable_alignment, variable_alignment) self.assertEqual(meta.variable_measure["mychar"], variable_measure["mychar"]) def test_sav_write_basic_expanduser(self): file_label = "basic write" file_note = "These are some notes" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] variable_value_labels = {'mylabl': {1.0: 'Male', 2.0: 'Female'}, 'myord': {1.0: 'low', 2.0: 'medium', 3.0: 'high'}} missing_ranges = {'mychar':['a'], 'myord': [{'hi':2, 'lo':1}]} #variable_alignment = {'mychar':"center", 'myord':"right"} variable_display_width = {'mychar':20} variable_measure = {"mychar": "nominal"} path = "~/sav_expand.sav" pyreadstat.write_sav(self.df_pandas, path, file_label=file_label, column_labels=col_labels, note=file_note, variable_value_labels=variable_value_labels, missing_ranges=missing_ranges, variable_display_width=variable_display_width, variable_measure=variable_measure) #, variable_alignment=variable_alignment) df, meta = pyreadstat.read_sav(path, user_missing=True) os.remove(os.path.expanduser(path)) self.assertTrue(df.equals(self.df_pandas)) def test_zsav_write_basic(self): file_label = "basic write" file_note = "These are some notes" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] variable_value_labels = {'mylabl': {1.0: 'Male', 2.0: 'Female'}, 'myord': {1.0: 'low', 2.0: 'medium', 3.0: 'high'}} missing_ranges = {'mychar':['a'], 'myord': [{'hi':2, 'lo':1}]} path = os.path.join(self.write_folder, "basic_write.zsav") pyreadstat.write_sav(self.df_pandas, path, file_label=file_label, column_labels=col_labels, compress=True, note=file_note, variable_value_labels=variable_value_labels, missing_ranges=missing_ranges) df, meta = pyreadstat.read_sav(path, user_missing=True) self.assertTrue(df.equals(self.df_pandas)) self.assertEqual(meta.file_label, file_label) self.assertListEqual(meta.column_labels, col_labels) self.assertEqual(meta.notes[0], file_note) self.assertDictEqual(meta.variable_value_labels, variable_value_labels) def test_dta_write_basic(self): df_pandas = self.df_pandas.copy() df_pandas["myord"] = df_pandas["myord"].astype(np.int32) df_pandas["mylabl"] = df_pandas["mylabl"].astype(np.int32) file_label = "basic write" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] variable_value_labels = {'mylabl': {1: 'Male', 2: 'Female'}, 'myord': {1: 'low', 2: 'medium', 3: 'high'}} path = os.path.join(self.write_folder, "basic_write.dta") pyreadstat.write_dta(df_pandas, path, file_label=file_label, column_labels=col_labels, version=12, variable_value_labels=variable_value_labels) df, meta = pyreadstat.read_dta(path) df_pandas["myord"] = df_pandas["myord"].astype(np.int64) df_pandas["mylabl"] = df_pandas["mylabl"].astype(np.int64) self.assertTrue(df.equals(df_pandas)) self.assertEqual(meta.file_label, file_label) self.assertListEqual(meta.column_labels, col_labels) self.assertDictEqual(meta.variable_value_labels, variable_value_labels) def test_dta_write_user_missing(self): df_csv = pd.DataFrame([[3,"a"],["a","b"]], columns=["Var1", "Var2"]) df_csv2 = pd.DataFrame([[3,"a"],["labeled","b"]], columns=["Var1", "Var2"]) missing_user_values = {'Var1': ['a']} variable_value_labels = {'Var1':{'a':'labeled'}} path = os.path.join(self.write_folder, "user_missing_write.dta") pyreadstat.write_dta(df_csv, path, version=12, missing_user_values=missing_user_values, variable_value_labels=variable_value_labels) df_dta, meta = pyreadstat.read_dta(path, user_missing=True) self.assertTrue(df_csv.equals(df_dta)) self.assertDictEqual(meta.missing_user_values, missing_user_values) df_dta2, meta2 = pyreadstat.read_dta(path, user_missing=True, apply_value_formats=True, formats_as_category=False) self.assertTrue(df_csv2.equals(df_dta2)) def test_xport_write_basic_v8(self): file_label = "basic write" table_name = "TEST" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] path = os.path.join(self.write_folder, "write.xpt") pyreadstat.write_xport(self.df_pandas, path, file_label=file_label, column_labels=col_labels, table_name=table_name, file_format_version=8) df, meta = pyreadstat.read_xport(path) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(self.df_pandas)) self.assertEqual(meta.file_label, file_label) self.assertListEqual(meta.column_labels, col_labels) self.assertEqual(table_name, meta.table_name) def test_xport_write_basic_v5(self): file_label = "basic write" table_name = "TEST" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] path = os.path.join(self.write_folder, "write.xpt") pyreadstat.write_xport(self.df_pandas, path, file_label=file_label, column_labels=col_labels, table_name=table_name, file_format_version=5) df, meta = pyreadstat.read_xport(path) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(self.df_pandas)) self.assertEqual(meta.file_label, file_label) self.assertListEqual(meta.column_labels, col_labels) self.assertEqual(table_name, meta.table_name) def test_por_write_basic(self): file_label = "basic write" #file_note = "These are some notes" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] path = os.path.join(self.write_folder, "write.por") pyreadstat.write_por(self.df_pandas, path, file_label=file_label, column_labels=col_labels) #, note=file_note) df, meta = pyreadstat.read_por(path) df.columns = [x.lower() for x in df.columns] self.assertTrue(df.equals(self.df_pandas)) self.assertEqual(meta.file_label, file_label) self.assertListEqual(meta.column_labels, col_labels) #self.assertEqual(meta.notes[0], file_note) def test_sav_write_dates(self): path = os.path.join(self.write_folder, "dates_write.sav") pyreadstat.write_sav(self.df_sas_dates2, path) df, meta = pyreadstat.read_sav(path) self.assertTrue(df.equals(self.df_sas_dates2)) def test_zsav_write_dates(self): path = os.path.join(self.write_folder, "dates_write_zsav.sav") pyreadstat.write_sav(self.df_sas_dates2, path, compress=True) df, meta = pyreadstat.read_sav(path) self.assertTrue(df.equals(self.df_sas_dates2)) def test_dta_write_dates(self): path = os.path.join(self.write_folder, "dates_write.dta") pyreadstat.write_dta(self.df_sas_dates, path) df, meta = pyreadstat.read_dta(path) self.assertTrue(df.equals(self.df_sas_dates)) def test_xport_write_dates(self): path = os.path.join(self.write_folder, "dates_write.xpt") pyreadstat.write_xport(self.df_sas_dates2, path) df, meta = pyreadstat.read_xport(path) #import pdb;pdb.set_trace() self.assertTrue(df.equals(self.df_sas_dates2)) def test_sav_write_charnan(self): path = os.path.join(self.write_folder, "charnan.sav") pyreadstat.write_sav(self.df_charnan, path) df, meta = pyreadstat.read_sav(path) df2 = self.df_charnan df2.iloc[0,1] = "" df2.iloc[0,2] = "" df2['integer'] = df2["integer"].astype(float) df2['object'] = df2['object'].astype(str) self.assertTrue(df2.equals(df)) def test_zsav_write_charnan(self): path = os.path.join(self.write_folder, "charnan_zsav.sav") pyreadstat.write_sav(self.df_charnan, path, compress=True) df, meta = pyreadstat.read_sav(path) df2 = self.df_charnan df2.iloc[0,1] = "" df2.iloc[0,2] = "" df2['integer'] = df2["integer"].astype(float) df2['object'] = df2['object'].astype(str) self.assertTrue(df2.equals(df)) def test_xport_write_charnan(self): path = os.path.join(self.write_folder, "charnan.xpt") pyreadstat.write_xport(self.df_charnan, path) df, meta = pyreadstat.read_xport(path) df2 = self.df_charnan df2.iloc[0,1] = "" df2.iloc[0,2] = "" df2['integer'] = df2["integer"].astype(float) df2['object'] = df2['object'].astype(str) self.assertTrue(df2.equals(df)) def test_por_write_charnan(self): path = os.path.join(self.write_folder, "charnan_zsav.por") pyreadstat.write_por(self.df_charnan, path) df, meta = pyreadstat.read_por(path) df.columns = [x.lower() for x in df.columns] df2 = self.df_charnan df2.iloc[0,1] = "" df2.iloc[0,2] = "" df2['integer'] = df2["integer"].astype(float) df2['object'] = df2['object'].astype(str) self.assertTrue(df2.equals(df)) def test_dta_write_charnan(self): path = os.path.join(self.write_folder, "charnan.dta") pyreadstat.write_dta(self.df_charnan, path) df, meta = pyreadstat.read_dta(path) df2 = self.df_charnan df2.iloc[0,1] = "" df2.iloc[0,2] = "" df2['integer'] = df2["integer"].astype(float) df2['object'] = df2['object'].astype(str) self.assertTrue(df2.equals(df)) def test_set_value_labels(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav")) df_formatted = pyreadstat.set_value_labels(df, meta, formats_as_category=True) #df.columns = self.df_pandas_formatted.columns self.assertTrue(df_formatted.equals(self.df_pandas_formatted)) # partial sub1_raw = df[['myord']] sub1 = pyreadstat.set_value_labels(sub1_raw, meta, formats_as_category=True) sub2 = self.df_pandas_formatted[['myord']] self.assertTrue(sub1.equals(sub2)) def test_update_delete_file(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav")) dst_path = os.path.join(self.write_folder, "update_test.sav") pyreadstat.write_sav(df, dst_path, variable_value_labels = meta.variable_value_labels) # update meta.variable_value_labels.update({'mylabl':{1.0:"Gents", 2.0:"Ladies"}}) pyreadstat.write_sav(df, dst_path, variable_value_labels = meta.variable_value_labels) df2, meta2 = pyreadstat.read_sav(dst_path) self.assertDictEqual(meta2.variable_value_labels, meta.variable_value_labels) os.remove(dst_path) def test_xport_write_dates2_v8(self): # this sas7bdat file has features that are not compatible with v5 df, meta = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "dates_xpt.sas7bdat")) dst_path = os.path.join(self.write_folder, "dates_xptv8.xpt") pyreadstat.write_xport(df, dst_path, file_format_version=8) df2, meta2 = pyreadstat.read_xport(dst_path) self.assertTrue(df.equals(df2)) def test_xport_dates2_v8(self): # this sas7bdat file has features that are not compatible with v5 df, meta = pyreadstat.read_sas7bdat(os.path.join(self.basic_data_folder, "dates_xpt.sas7bdat")) # this xpt file was written in SAS from the sas7bdat file df2, meta2 = pyreadstat.read_xport(os.path.join(self.basic_data_folder, "dates_xpt_v8.xpt")) self.assertTrue(df.equals(df2)) self.assertListEqual(meta.column_labels, meta2.column_labels) def test_sav_international_utf8_char_value(self): # a file that has a value with international characters and the file is coded in utf-8 df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "tegulu.sav")) self.assertTrue(df.iloc[0,1] == "నేను గతంలో వాడిన బ") def test_sav_international_varname(self): # a file with a varname with international characters df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "hebrews.sav")) self.assertTrue(df.columns[0] == "ותק_ב") def test_sav_original_var_types(self): # a file with a varname with international characters df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "test_width.sav")) self.assertEqual(meta.original_variable_types['StartDate'],'A1024') self.assertEqual(meta.original_variable_types['ResponseId'],'A18') self.assertEqual(meta.original_variable_types['Duration__in_seconds_'],'F40.2') self.assertEqual(meta.original_variable_types['Finished'],'F1.0') self.assertEqual(meta.readstat_variable_types['Finished'],'double') def test_sav_write_longstr(self): path = os.path.join(self.write_folder, "longstr.sav") pyreadstat.write_sav(self.df_longstr, path, variable_display_width={"v1": 1000}) df, meta = pyreadstat.read_sav(path) self.assertTrue(meta.variable_display_width['v1']==1000) self.assertTrue(len(df.iloc[0,0])==781) def test_sas7bdat_file_label_linux(self): "testing file label for file produced on linux" path = os.path.join(self.basic_data_folder, "test_file_label_linux.sas7bdat") df, meta = pyreadstat.read_sas7bdat(path) self.assertEqual(meta.file_label, "mytest label") self.assertEqual(meta.table_name, "TEST_DATA") def test_sas7bdat_extra_date_formats(self): "testing extra date format argument" path = os.path.join(self.basic_data_folder, "date_test.sas7bdat") df, meta = pyreadstat.read_sas7bdat(path, extra_date_formats=["MMYY", "YEAR"]) self.assertEqual(df['yr'].iloc[0], date(2023,1,1)) self.assertEqual(df['dtc4'].iloc[0], date(2023,7,1)) def test_sas7bdat_file_label_windows(self): "testing file label for file produced on windows" path = os.path.join(self.basic_data_folder, "test_file_label_win.sas7bdat") df, meta = pyreadstat.read_sas7bdat(path) self.assertEqual(meta.file_label, "mytest label") self.assertEqual(meta.table_name, "TEST_DATA") def test_sav_write_variable_formats(self): "testing variable formats for SAV files" path = os.path.join(self.write_folder, "variable_format.sav") df = pd.DataFrame({'restricted':[1023, 10], 'integer':[1,2]}) formats = {'restricted':'restricted_integer', 'integer':'integer'} pyreadstat.write_sav(df, path, variable_format=formats) df2, meta2 = pyreadstat.read_sav(path) self.assertEqual(meta2.original_variable_types['restricted'], "N4") self.assertEqual(meta2.original_variable_types['integer'], "F1.0") def test_sav_ordered_categories(self): path = os.path.join(self.basic_data_folder, "ordered_category.sav") df, meta = pyreadstat.read_sav(path, apply_value_formats=True, formats_as_ordered_category=True) self.assertTrue(df.Col1.cat.ordered) self.assertListEqual(list(df.Col1.cat.categories), ['high', 'low', 'medium']) def test_sav_pathlib(self): if is_pathlib_available: path = Path(self.basic_data_folder).joinpath("sample.sav") df, meta = pyreadstat.read_sav(path) self.assertTrue(df.equals(self.df_pandas)) def test_sav_write_pathlib(self): if is_pathlib_available: file_label = "basic write" file_note = "These are some notes" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] variable_value_labels = {'mylabl': {1.0: 'Male', 2.0: 'Female'}, 'myord': {1.0: 'low', 2.0: 'medium', 3.0: 'high'}} missing_ranges = {'mychar':['a'], 'myord': [{'hi':2, 'lo':1}]} #variable_alignment = {'mychar':"center", 'myord':"right"} variable_display_width = {'mychar':20} variable_measure = {"mychar": "nominal"} path = Path(self.write_folder).joinpath('pathlib_write.sav') pyreadstat.write_sav(self.df_pandas, path, file_label=file_label, column_labels=col_labels, note=file_note, variable_value_labels=variable_value_labels, missing_ranges=missing_ranges, variable_display_width=variable_display_width, variable_measure=variable_measure) #, variable_alignment=variable_alignment) df, meta = pyreadstat.read_sav(path, user_missing=True) self.assertTrue(df.equals(self.df_pandas)) self.assertEqual(meta.file_label, file_label) self.assertListEqual(meta.column_labels, col_labels) self.assertEqual(meta.notes[0], file_note) self.assertDictEqual(meta.variable_value_labels, variable_value_labels) self.assertEqual(meta.variable_display_width['mychar'], variable_display_width['mychar']) #self.assertDictEqual(meta.variable_alignment, variable_alignment) self.assertEqual(meta.variable_measure["mychar"], variable_measure["mychar"]) def test_sav_write_dictlabels(self): col_names = ["mychar", "mynum", "mydate", "dtime", "mylabl", "myord", "mytime"] col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] col_lab_dict = {k:v for k,v in zip(col_names, col_labels) if v} variable_value_labels = {'mylabl': {1.0: 'Male', 2.0: 'Female'}, 'myord': {1.0: 'low', 2.0: 'medium', 3.0: 'high'}} missing_ranges = {'mychar':['a'], 'myord': [{'hi':2, 'lo':1}]} path = os.path.join(self.write_folder, "dictlabel_write.sav") pyreadstat.write_sav(self.df_pandas, path, column_labels=col_lab_dict) df, meta = pyreadstat.read_sav(path, user_missing=True) self.assertTrue(df.equals(self.df_pandas)) self.assertListEqual(meta.column_labels, col_labels) def test_dta_write_single_value_user_missing(self): df = pd.DataFrame({"var": ["a", "a", "a", "a"]}) missing_user_values = {"var": ["a"]} path = os.path.join(self.write_folder, "singleusermissing.dta") pyreadstat.write_dta(df=df, dst_path=path, missing_user_values=missing_user_values,version=12) df2, meta2 = pyreadstat.read_dta(path, user_missing=True) self.assertTrue(df.equals(df2)) def test_dta_write_only_missing_and_user_missing(self): df = pd.DataFrame({"var": [np.nan, "a", "b"]}) path = os.path.join(self.write_folder, "onlymissing_and_usermissing.dta") variable_value_labels={"var": {1: "Val 1", 2: "Val 2", 3: "Val 3", "a": "Missing A", "b": "Missing B", } } missing_user_values={"var": ["a", "b"]} pyreadstat.write_dta(df, path, variable_value_labels=variable_value_labels, missing_user_values=missing_user_values,version=12) df2, meta2 = pyreadstat.read_dta(path, user_missing=True, ) self.assertTrue(df.equals(df2)) def test_sav_outputformat_dict(self): df, meta = pyreadstat.read_sav(os.path.join(self.basic_data_folder, "sample.sav"), output_format='dict') self.assertTrue(meta.number_columns == len(self.df_pandas.columns)) self.assertTrue(meta.number_rows == len(self.df_pandas)) self.assertTrue(len(meta.notes)>0) self.assertTrue(meta.variable_display_width["mychar"]==9) self.assertTrue(meta.variable_storage_width["mychar"] == 8) self.assertTrue(meta.variable_measure["mychar"]=="nominal") self.assertTrue(meta.readstat_variable_types["mychar"]=="string") self.assertTrue(meta.readstat_variable_types["myord"]=="double") padic = self.df_pandas.to_dict(orient='list') #import pdb;pdb.set_trace() for colname, data in df.items(): curdfcol = df[colname] for indx, val in enumerate(data): if pd.isna(val) and pd.isna(curdfcol[indx]): continue self.assertTrue(val==curdfcol[indx]) def test_sav_write_rowcompression(self): file_label = "row compression write" file_note = "These are some notes" col_labels = ["mychar label","mynum label", "mydate label", "dtime label", None, "myord label", "mytime label"] variable_value_labels = {'mylabl': {1.0: 'Male', 2.0: 'Female'}, 'myord': {1.0: 'low', 2.0: 'medium', 3.0: 'high'}} missing_ranges = {'mychar':['a'], 'myord': [{'hi':2, 'lo':1}]} #variable_alignment = {'mychar':"center", 'myord':"right"} variable_display_width = {'mychar':20} variable_measure = {"mychar": "nominal"} path = os.path.join(self.write_folder, "rowcompression_write.sav") pyreadstat.write_sav(self.df_pandas, path, file_label=file_label, column_labels=col_labels, note=file_note, variable_value_labels=variable_value_labels, missing_ranges=missing_ranges, variable_display_width=variable_display_width, variable_measure=variable_measure, row_compress=True) #, variable_alignment=variable_alignment) df, meta = pyreadstat.read_sav(path, user_missing=True) self.assertTrue(df.equals(self.df_pandas)) self.assertEqual(meta.file_label, file_label) self.assertListEqual(meta.column_labels, col_labels) self.assertEqual(meta.notes[0], file_note) self.assertDictEqual(meta.variable_value_labels, variable_value_labels) self.assertEqual(meta.variable_display_width['mychar'], variable_display_width['mychar']) #self.assertDictEqual(meta.variable_alignment, variable_alignment) self.assertEqual(meta.variable_measure["mychar"], variable_measure["mychar"]) if __name__ == '__main__': import sys if "--inplace" in sys.argv: script_folder = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0] sys.path.insert(0, script_folder) sys.argv.remove('--inplace') import pyreadstat print("package location:", pyreadstat.__file__) unittest.main() ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1710350831.0 pyreadstat-1.2.7/tests/test_version.py0000644023477200000240000000215114574360757020064 0ustar00fajardoostaffs""" Test if the version in pyreadstat __init__ matches the version in setup.py """ import os import sys import re script_folder = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0] sys.path.insert(0, script_folder) sys.path.insert(1,os.path.join(script_folder, "docs")) import pyreadstat import conf pyreadstat_version = pyreadstat.__version__ with open(os.path.join(script_folder, "setup.py")) as h: content = h.read() raw = re.findall("version=\'.*?\'", content) setup_version = raw[0].replace("version=", "") setup_version = setup_version.replace("'", "") with open(os.path.join(script_folder, "CITATION.cff")) as h: content = h.readlines() raw = [x for x in content if x.startswith("version")] cff_version = raw[0].replace("version:", "").strip() print("testing if module and setup versions match") assert(pyreadstat_version == setup_version) print("testing if documentation and setup versions match") assert(conf.release == setup_version) print("testing if cff and setup versions match") assert(cff_version == setup_version) print("all versions match!")