repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
konstantinstadler/pymrio
pymrio/tools/iometadata.py
MRIOMetaData._add_history
def _add_history(self, entry_type, entry): """ Generic method to add entry as entry_type to the history """ meta_string = "{time} - {etype} - {entry}".format( time=self._time(), etype=entry_type.upper(), entry=entry) self._content['history'].insert(0, meta_s...
python
def _add_history(self, entry_type, entry): """ Generic method to add entry as entry_type to the history """ meta_string = "{time} - {etype} - {entry}".format( time=self._time(), etype=entry_type.upper(), entry=entry) self._content['history'].insert(0, meta_s...
[ "def", "_add_history", "(", "self", ",", "entry_type", ",", "entry", ")", ":", "meta_string", "=", "\"{time} - {etype} - {entry}\"", ".", "format", "(", "time", "=", "self", ".", "_time", "(", ")", ",", "etype", "=", "entry_type", ".", "upper", "(", ")", ...
Generic method to add entry as entry_type to the history
[ "Generic", "method", "to", "add", "entry", "as", "entry_type", "to", "the", "history" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iometadata.py#L184-L192
konstantinstadler/pymrio
pymrio/tools/iometadata.py
MRIOMetaData.change_meta
def change_meta(self, para, new_value, log=True): """ Changes the meta data This function does nothing if None is passed as new_value. To set a certain value to None pass the str 'None' Parameters ---------- para: str Meta data entry to change new_v...
python
def change_meta(self, para, new_value, log=True): """ Changes the meta data This function does nothing if None is passed as new_value. To set a certain value to None pass the str 'None' Parameters ---------- para: str Meta data entry to change new_v...
[ "def", "change_meta", "(", "self", ",", "para", ",", "new_value", ",", "log", "=", "True", ")", ":", "if", "not", "new_value", ":", "return", "para", "=", "para", ".", "lower", "(", ")", "if", "para", "==", "'history'", ":", "raise", "ValueError", "(...
Changes the meta data This function does nothing if None is passed as new_value. To set a certain value to None pass the str 'None' Parameters ---------- para: str Meta data entry to change new_value: str New value log: boolean, optiona...
[ "Changes", "the", "meta", "data" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iometadata.py#L238-L273
konstantinstadler/pymrio
pymrio/tools/iometadata.py
MRIOMetaData._read_content
def _read_content(self): """ Reads metadata from location (and path_in_arc if archive) This function is called during the init process and should not be used in isolation: it overwrites unsafed metadata. """ if self._path_in_arc: with zipfile.ZipFile(file=str...
python
def _read_content(self): """ Reads metadata from location (and path_in_arc if archive) This function is called during the init process and should not be used in isolation: it overwrites unsafed metadata. """ if self._path_in_arc: with zipfile.ZipFile(file=str...
[ "def", "_read_content", "(", "self", ")", ":", "if", "self", ".", "_path_in_arc", ":", "with", "zipfile", ".", "ZipFile", "(", "file", "=", "str", "(", "self", ".", "_metadata_file", ")", ")", "as", "zf", ":", "self", ".", "_content", "=", "json", "....
Reads metadata from location (and path_in_arc if archive) This function is called during the init process and should not be used in isolation: it overwrites unsafed metadata.
[ "Reads", "metadata", "from", "location", "(", "and", "path_in_arc", "if", "archive", ")" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iometadata.py#L278-L293
konstantinstadler/pymrio
pymrio/tools/iometadata.py
MRIOMetaData.save
def save(self, location=None): """ Saves the current status of the metadata This saves the metadata at the location of the previously loaded metadata or at the file/path given in location. Specify a location if the metadata should be stored in a different location or was never ...
python
def save(self, location=None): """ Saves the current status of the metadata This saves the metadata at the location of the previously loaded metadata or at the file/path given in location. Specify a location if the metadata should be stored in a different location or was never ...
[ "def", "save", "(", "self", ",", "location", "=", "None", ")", ":", "if", "location", ":", "location", "=", "Path", "(", "location", ")", "if", "os", ".", "path", ".", "splitext", "(", "str", "(", "location", ")", ")", "[", "1", "]", "==", "''", ...
Saves the current status of the metadata This saves the metadata at the location of the previously loaded metadata or at the file/path given in location. Specify a location if the metadata should be stored in a different location or was never stored before. Subsequent saves will use th...
[ "Saves", "the", "current", "status", "of", "the", "metadata" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iometadata.py#L295-L325
konstantinstadler/pymrio
pymrio/tools/iomath.py
calc_x
def calc_x(Z, Y): """ Calculate the industry output x from the Z and Y matrix Parameters ---------- Z : pandas.DataFrame or numpy.array Symmetric input output table (flows) Y : pandas.DataFrame or numpy.array final demand with categories (1.order) for each country (2.order) Ret...
python
def calc_x(Z, Y): """ Calculate the industry output x from the Z and Y matrix Parameters ---------- Z : pandas.DataFrame or numpy.array Symmetric input output table (flows) Y : pandas.DataFrame or numpy.array final demand with categories (1.order) for each country (2.order) Ret...
[ "def", "calc_x", "(", "Z", ",", "Y", ")", ":", "x", "=", "np", ".", "reshape", "(", "np", ".", "sum", "(", "np", ".", "hstack", "(", "(", "Z", ",", "Y", ")", ")", ",", "1", ")", ",", "(", "-", "1", ",", "1", ")", ")", "if", "type", "(...
Calculate the industry output x from the Z and Y matrix Parameters ---------- Z : pandas.DataFrame or numpy.array Symmetric input output table (flows) Y : pandas.DataFrame or numpy.array final demand with categories (1.order) for each country (2.order) Returns ------- panda...
[ "Calculate", "the", "industry", "output", "x", "from", "the", "Z", "and", "Y", "matrix" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iomath.py#L18-L42
konstantinstadler/pymrio
pymrio/tools/iomath.py
calc_x_from_L
def calc_x_from_L(L, y): """ Calculate the industry output x from L and a y vector Parameters ---------- L : pandas.DataFrame or numpy.array Symmetric input output Leontief table y : pandas.DataFrame or numpy.array a column vector of the total final demand Returns ------- ...
python
def calc_x_from_L(L, y): """ Calculate the industry output x from L and a y vector Parameters ---------- L : pandas.DataFrame or numpy.array Symmetric input output Leontief table y : pandas.DataFrame or numpy.array a column vector of the total final demand Returns ------- ...
[ "def", "calc_x_from_L", "(", "L", ",", "y", ")", ":", "x", "=", "L", ".", "dot", "(", "y", ")", "if", "type", "(", "x", ")", "is", "pd", ".", "Series", ":", "x", "=", "pd", ".", "DataFrame", "(", "x", ")", "if", "type", "(", "x", ")", "is...
Calculate the industry output x from L and a y vector Parameters ---------- L : pandas.DataFrame or numpy.array Symmetric input output Leontief table y : pandas.DataFrame or numpy.array a column vector of the total final demand Returns ------- pandas.DataFrame or numpy.arra...
[ "Calculate", "the", "industry", "output", "x", "from", "L", "and", "a", "y", "vector" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iomath.py#L45-L67
konstantinstadler/pymrio
pymrio/tools/iomath.py
calc_Z
def calc_Z(A, x): """ calculate the Z matrix (flows) from A and x Parameters ---------- A : pandas.DataFrame or numpy.array Symmetric input output table (coefficients) x : pandas.DataFrame or numpy.array Industry output column vector Returns ------- pandas.DataFrame or ...
python
def calc_Z(A, x): """ calculate the Z matrix (flows) from A and x Parameters ---------- A : pandas.DataFrame or numpy.array Symmetric input output table (coefficients) x : pandas.DataFrame or numpy.array Industry output column vector Returns ------- pandas.DataFrame or ...
[ "def", "calc_Z", "(", "A", ",", "x", ")", ":", "if", "(", "type", "(", "x", ")", "is", "pd", ".", "DataFrame", ")", "or", "(", "type", "(", "x", ")", "is", "pd", ".", "Series", ")", ":", "x", "=", "x", ".", "values", "x", "=", "x", ".", ...
calculate the Z matrix (flows) from A and x Parameters ---------- A : pandas.DataFrame or numpy.array Symmetric input output table (coefficients) x : pandas.DataFrame or numpy.array Industry output column vector Returns ------- pandas.DataFrame or numpy.array Symmet...
[ "calculate", "the", "Z", "matrix", "(", "flows", ")", "from", "A", "and", "x" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iomath.py#L70-L97
konstantinstadler/pymrio
pymrio/tools/iomath.py
calc_A
def calc_A(Z, x): """ Calculate the A matrix (coefficients) from Z and x Parameters ---------- Z : pandas.DataFrame or numpy.array Symmetric input output table (flows) x : pandas.DataFrame or numpy.array Industry output column vector Returns ------- pandas.DataFrame or ...
python
def calc_A(Z, x): """ Calculate the A matrix (coefficients) from Z and x Parameters ---------- Z : pandas.DataFrame or numpy.array Symmetric input output table (flows) x : pandas.DataFrame or numpy.array Industry output column vector Returns ------- pandas.DataFrame or ...
[ "def", "calc_A", "(", "Z", ",", "x", ")", ":", "if", "(", "type", "(", "x", ")", "is", "pd", ".", "DataFrame", ")", "or", "(", "type", "(", "x", ")", "is", "pd", ".", "Series", ")", ":", "x", "=", "x", ".", "values", "if", "(", "type", "(...
Calculate the A matrix (coefficients) from Z and x Parameters ---------- Z : pandas.DataFrame or numpy.array Symmetric input output table (flows) x : pandas.DataFrame or numpy.array Industry output column vector Returns ------- pandas.DataFrame or numpy.array Symmet...
[ "Calculate", "the", "A", "matrix", "(", "coefficients", ")", "from", "Z", "and", "x" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iomath.py#L100-L136
konstantinstadler/pymrio
pymrio/tools/iomath.py
calc_L
def calc_L(A): """ Calculate the Leontief L from A Parameters ---------- A : pandas.DataFrame or numpy.array Symmetric input output table (coefficients) Returns ------- pandas.DataFrame or numpy.array Leontief input output table L The type is determined by the type ...
python
def calc_L(A): """ Calculate the Leontief L from A Parameters ---------- A : pandas.DataFrame or numpy.array Symmetric input output table (coefficients) Returns ------- pandas.DataFrame or numpy.array Leontief input output table L The type is determined by the type ...
[ "def", "calc_L", "(", "A", ")", ":", "I", "=", "np", ".", "eye", "(", "A", ".", "shape", "[", "0", "]", ")", "# noqa", "if", "type", "(", "A", ")", "is", "pd", ".", "DataFrame", ":", "return", "pd", ".", "DataFrame", "(", "np", ".", "linalg",...
Calculate the Leontief L from A Parameters ---------- A : pandas.DataFrame or numpy.array Symmetric input output table (coefficients) Returns ------- pandas.DataFrame or numpy.array Leontief input output table L The type is determined by the type of A. If DataFr...
[ "Calculate", "the", "Leontief", "L", "from", "A" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iomath.py#L139-L160
konstantinstadler/pymrio
pymrio/tools/iomath.py
recalc_M
def recalc_M(S, D_cba, Y, nr_sectors): """ Calculate Multipliers based on footprints. Parameters ---------- D_cba : pandas.DataFrame or numpy array Footprint per sector and country Y : pandas.DataFrame or numpy array Final demand: aggregated across categories or just one category, o...
python
def recalc_M(S, D_cba, Y, nr_sectors): """ Calculate Multipliers based on footprints. Parameters ---------- D_cba : pandas.DataFrame or numpy array Footprint per sector and country Y : pandas.DataFrame or numpy array Final demand: aggregated across categories or just one category, o...
[ "def", "recalc_M", "(", "S", ",", "D_cba", ",", "Y", ",", "nr_sectors", ")", ":", "Y_diag", "=", "ioutil", ".", "diagonalize_blocks", "(", "Y", ".", "values", ",", "blocksize", "=", "nr_sectors", ")", "Y_inv", "=", "np", ".", "linalg", ".", "inv", "(...
Calculate Multipliers based on footprints. Parameters ---------- D_cba : pandas.DataFrame or numpy array Footprint per sector and country Y : pandas.DataFrame or numpy array Final demand: aggregated across categories or just one category, one column per country. This will be dia...
[ "Calculate", "Multipliers", "based", "on", "footprints", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iomath.py#L291-L323
konstantinstadler/pymrio
pymrio/tools/iomath.py
calc_accounts
def calc_accounts(S, L, Y, nr_sectors): """ Calculate sector specific cba and pba based accounts, imp and exp accounts The total industry output x for the calculation is recalculated from L and y Parameters ---------- L : pandas.DataFrame Leontief input output table L S : pandas.Da...
python
def calc_accounts(S, L, Y, nr_sectors): """ Calculate sector specific cba and pba based accounts, imp and exp accounts The total industry output x for the calculation is recalculated from L and y Parameters ---------- L : pandas.DataFrame Leontief input output table L S : pandas.Da...
[ "def", "calc_accounts", "(", "S", ",", "L", ",", "Y", ",", "nr_sectors", ")", ":", "# diagonalize each sector block per country", "# this results in a disaggregated y with final demand per country per", "# sector in one column", "Y_diag", "=", "ioutil", ".", "diagonalize_blocks...
Calculate sector specific cba and pba based accounts, imp and exp accounts The total industry output x for the calculation is recalculated from L and y Parameters ---------- L : pandas.DataFrame Leontief input output table L S : pandas.DataFrame Direct impact coefficients Y...
[ "Calculate", "sector", "specific", "cba", "and", "pba", "based", "accounts", "imp", "and", "exp", "accounts" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iomath.py#L326-L390
konstantinstadler/pymrio
pymrio/tools/iodownloader.py
_get_url_datafiles
def _get_url_datafiles(url_db_view, url_db_content, mrio_regex, access_cookie=None): """ Urls of mrio files by parsing url content for mrio_regex Parameters ---------- url_db_view: url str Url which shows the list of mrios in the db url_db_content: url str U...
python
def _get_url_datafiles(url_db_view, url_db_content, mrio_regex, access_cookie=None): """ Urls of mrio files by parsing url content for mrio_regex Parameters ---------- url_db_view: url str Url which shows the list of mrios in the db url_db_content: url str U...
[ "def", "_get_url_datafiles", "(", "url_db_view", ",", "url_db_content", ",", "mrio_regex", ",", "access_cookie", "=", "None", ")", ":", "# Use post here - NB: get could be necessary for some other pages", "# but currently works for wiod and eora", "returnvalue", "=", "namedtuple"...
Urls of mrio files by parsing url content for mrio_regex Parameters ---------- url_db_view: url str Url which shows the list of mrios in the db url_db_content: url str Url which needs to be appended before the url parsed from the url_db_view to get a valid download link m...
[ "Urls", "of", "mrio", "files", "by", "parsing", "url", "content", "for", "mrio_regex" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iodownloader.py#L32-L66
konstantinstadler/pymrio
pymrio/tools/iodownloader.py
_download_urls
def _download_urls(url_list, storage_folder, overwrite_existing, meta_handler, access_cookie=None): """ Save url from url_list to storage_folder Parameters ---------- url_list: list of str Valid url to download storage_folder: str, valid path Location to store th...
python
def _download_urls(url_list, storage_folder, overwrite_existing, meta_handler, access_cookie=None): """ Save url from url_list to storage_folder Parameters ---------- url_list: list of str Valid url to download storage_folder: str, valid path Location to store th...
[ "def", "_download_urls", "(", "url_list", ",", "storage_folder", ",", "overwrite_existing", ",", "meta_handler", ",", "access_cookie", "=", "None", ")", ":", "for", "url", "in", "url_list", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "url"...
Save url from url_list to storage_folder Parameters ---------- url_list: list of str Valid url to download storage_folder: str, valid path Location to store the download, folder will be created if not existing. If the file is already present in the folder, the download ...
[ "Save", "url", "from", "url_list", "to", "storage_folder" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iodownloader.py#L69-L112
konstantinstadler/pymrio
pymrio/tools/iodownloader.py
download_wiod2013
def download_wiod2013(storage_folder, years=None, overwrite_existing=False, satellite_urls=WIOD_CONFIG['satellite_urls']): """ Downloads the 2013 wiod release Note ---- Currently, pymrio only works with the 2013 release of the wiod tables. The more recent 2016 release so far (...
python
def download_wiod2013(storage_folder, years=None, overwrite_existing=False, satellite_urls=WIOD_CONFIG['satellite_urls']): """ Downloads the 2013 wiod release Note ---- Currently, pymrio only works with the 2013 release of the wiod tables. The more recent 2016 release so far (...
[ "def", "download_wiod2013", "(", "storage_folder", ",", "years", "=", "None", ",", "overwrite_existing", "=", "False", ",", "satellite_urls", "=", "WIOD_CONFIG", "[", "'satellite_urls'", "]", ")", ":", "try", ":", "os", ".", "makedirs", "(", "storage_folder", ...
Downloads the 2013 wiod release Note ---- Currently, pymrio only works with the 2013 release of the wiod tables. The more recent 2016 release so far (October 2017) lacks the environmental and social extensions. Parameters ---------- storage_folder: str, valid path Location to ...
[ "Downloads", "the", "2013", "wiod", "release" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/iodownloader.py#L115-L184
shichao-an/115wangpan
u115/utils.py
get_timestamp
def get_timestamp(length): """Get a timestamp of `length` in string""" s = '%.6f' % time.time() whole, frac = map(int, s.split('.')) res = '%d%d' % (whole, frac) return res[:length]
python
def get_timestamp(length): """Get a timestamp of `length` in string""" s = '%.6f' % time.time() whole, frac = map(int, s.split('.')) res = '%d%d' % (whole, frac) return res[:length]
[ "def", "get_timestamp", "(", "length", ")", ":", "s", "=", "'%.6f'", "%", "time", ".", "time", "(", ")", "whole", ",", "frac", "=", "map", "(", "int", ",", "s", ".", "split", "(", "'.'", ")", ")", "res", "=", "'%d%d'", "%", "(", "whole", ",", ...
Get a timestamp of `length` in string
[ "Get", "a", "timestamp", "of", "length", "in", "string" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/utils.py#L25-L30
shichao-an/115wangpan
u115/utils.py
mkdir_p
def mkdir_p(path): """mkdir -p path""" if PY3: return os.makedirs(path, exist_ok=True) try: os.makedirs(path) except OSError as exc: if exc.errno == errno.EEXIST and os.path.isdir(path): pass else: raise
python
def mkdir_p(path): """mkdir -p path""" if PY3: return os.makedirs(path, exist_ok=True) try: os.makedirs(path) except OSError as exc: if exc.errno == errno.EEXIST and os.path.isdir(path): pass else: raise
[ "def", "mkdir_p", "(", "path", ")", ":", "if", "PY3", ":", "return", "os", ".", "makedirs", "(", "path", ",", "exist_ok", "=", "True", ")", "try", ":", "os", ".", "makedirs", "(", "path", ")", "except", "OSError", "as", "exc", ":", "if", "exc", "...
mkdir -p path
[ "mkdir", "-", "p", "path" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/utils.py#L79-L89
tmc/gevent-zeromq
gevent_zeromq/__init__.py
monkey_patch
def monkey_patch(): """ Monkey patches `zmq.Context` and `zmq.Socket` If test_suite is True, the pyzmq test suite will be patched for compatibility as well. """ ozmq = __import__('zmq') ozmq.Socket = zmq.Socket ozmq.Context = zmq.Context ozmq.Poller = zmq.Poller ioloop = __impor...
python
def monkey_patch(): """ Monkey patches `zmq.Context` and `zmq.Socket` If test_suite is True, the pyzmq test suite will be patched for compatibility as well. """ ozmq = __import__('zmq') ozmq.Socket = zmq.Socket ozmq.Context = zmq.Context ozmq.Poller = zmq.Poller ioloop = __impor...
[ "def", "monkey_patch", "(", ")", ":", "ozmq", "=", "__import__", "(", "'zmq'", ")", "ozmq", ".", "Socket", "=", "zmq", ".", "Socket", "ozmq", ".", "Context", "=", "zmq", ".", "Context", "ozmq", ".", "Poller", "=", "zmq", ".", "Poller", "ioloop", "=",...
Monkey patches `zmq.Context` and `zmq.Socket` If test_suite is True, the pyzmq test suite will be patched for compatibility as well.
[ "Monkey", "patches", "zmq", ".", "Context", "and", "zmq", ".", "Socket" ]
train
https://github.com/tmc/gevent-zeromq/blob/b15d50deedda3d2cdb701106d4b315c7a06353e3/gevent_zeromq/__init__.py#L34-L46
konstantinstadler/pymrio
pymrio/core/mriosystem.py
concate_extension
def concate_extension(*extensions, name): """ Concatenate extensions Notes ---- The method assumes that the first index is the name of the stressor/impact/input type. To provide a consistent naming this is renamed to 'indicator' if they differ. All other index names ('compartments', ...) ar...
python
def concate_extension(*extensions, name): """ Concatenate extensions Notes ---- The method assumes that the first index is the name of the stressor/impact/input type. To provide a consistent naming this is renamed to 'indicator' if they differ. All other index names ('compartments', ...) ar...
[ "def", "concate_extension", "(", "*", "extensions", ",", "name", ")", ":", "if", "type", "(", "extensions", "[", "0", "]", ")", "is", "tuple", "or", "type", "(", "extensions", "[", "0", "]", ")", "is", "list", ":", "extensions", "=", "extensions", "[...
Concatenate extensions Notes ---- The method assumes that the first index is the name of the stressor/impact/input type. To provide a consistent naming this is renamed to 'indicator' if they differ. All other index names ('compartments', ...) are added to the concatenated extensions and set to ...
[ "Concatenate", "extensions" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L2031-L2163
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.reset_full
def reset_full(self, force=False, _meta=None): """ Remove all accounts which can be recalculated based on Z, Y, F, FY Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. Default: False _met...
python
def reset_full(self, force=False, _meta=None): """ Remove all accounts which can be recalculated based on Z, Y, F, FY Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. Default: False _met...
[ "def", "reset_full", "(", "self", ",", "force", "=", "False", ",", "_meta", "=", "None", ")", ":", "# Attriubtes to keep must be defined in the init: __basic__", "strwarn", "=", "None", "for", "df", "in", "self", ".", "__basic__", ":", "if", "(", "getattr", "(...
Remove all accounts which can be recalculated based on Z, Y, F, FY Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. Default: False _meta: MRIOMetaData, optional Metadata handler for ...
[ "Remove", "all", "accounts", "which", "can", "be", "recalculated", "based", "on", "Z", "Y", "F", "FY" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L83-L124
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.reset_to_flows
def reset_to_flows(self, force=False, _meta=None): """ Keeps only the absolute values. This removes all attributes which can not be aggregated and must be recalculated after the aggregation. Parameters ---------- force: boolean, optional If True, reset to f...
python
def reset_to_flows(self, force=False, _meta=None): """ Keeps only the absolute values. This removes all attributes which can not be aggregated and must be recalculated after the aggregation. Parameters ---------- force: boolean, optional If True, reset to f...
[ "def", "reset_to_flows", "(", "self", ",", "force", "=", "False", ",", "_meta", "=", "None", ")", ":", "# Development note: The attributes which should be removed are", "# defined in self.__non_agg_attributes__", "strwarn", "=", "None", "for", "df", "in", "self", ".", ...
Keeps only the absolute values. This removes all attributes which can not be aggregated and must be recalculated after the aggregation. Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. D...
[ "Keeps", "only", "the", "absolute", "values", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L126-L166
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.reset_to_coefficients
def reset_to_coefficients(self): """ Keeps only the coefficient. This can be used to recalculate the IO tables for a new finald demand. Note ----- The system can not be reconstructed after this steps because all absolute data is removed. Save the Y data in case ...
python
def reset_to_coefficients(self): """ Keeps only the coefficient. This can be used to recalculate the IO tables for a new finald demand. Note ----- The system can not be reconstructed after this steps because all absolute data is removed. Save the Y data in case ...
[ "def", "reset_to_coefficients", "(", "self", ")", ":", "# Development note: The coefficient attributes are", "# defined in self.__coefficients__", "[", "setattr", "(", "self", ",", "key", ",", "None", ")", "for", "key", "in", "self", ".", "get_DataFrame", "(", "data",...
Keeps only the coefficient. This can be used to recalculate the IO tables for a new finald demand. Note ----- The system can not be reconstructed after this steps because all absolute data is removed. Save the Y data in case a reconstruction might be necessary.
[ "Keeps", "only", "the", "coefficient", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L168-L189
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.copy
def copy(self, new_name=None): """ Returns a deep copy of the system Parameters ----------- new_name: str, optional Set a new meta name parameter. Default: <old_name>_copy """ _tmp = copy.deepcopy(self) if not new_name: new_na...
python
def copy(self, new_name=None): """ Returns a deep copy of the system Parameters ----------- new_name: str, optional Set a new meta name parameter. Default: <old_name>_copy """ _tmp = copy.deepcopy(self) if not new_name: new_na...
[ "def", "copy", "(", "self", ",", "new_name", "=", "None", ")", ":", "_tmp", "=", "copy", ".", "deepcopy", "(", "self", ")", "if", "not", "new_name", ":", "new_name", "=", "self", ".", "name", "+", "'_copy'", "if", "str", "(", "type", "(", "self", ...
Returns a deep copy of the system Parameters ----------- new_name: str, optional Set a new meta name parameter. Default: <old_name>_copy
[ "Returns", "a", "deep", "copy", "of", "the", "system" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L191-L210
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.get_Y_categories
def get_Y_categories(self, entries=None): """ Returns names of y cat. of the IOSystem as unique names in order Parameters ---------- entries : List, optional If given, retuns an list with None for all values not in entries. Returns ------- Index ...
python
def get_Y_categories(self, entries=None): """ Returns names of y cat. of the IOSystem as unique names in order Parameters ---------- entries : List, optional If given, retuns an list with None for all values not in entries. Returns ------- Index ...
[ "def", "get_Y_categories", "(", "self", ",", "entries", "=", "None", ")", ":", "possible_dataframes", "=", "[", "'Y'", ",", "'FY'", "]", "for", "df", "in", "possible_dataframes", ":", "if", "(", "df", "in", "self", ".", "__dict__", ")", "and", "(", "ge...
Returns names of y cat. of the IOSystem as unique names in order Parameters ---------- entries : List, optional If given, retuns an list with None for all values not in entries. Returns ------- Index List of categories, None if no attribute to de...
[ "Returns", "names", "of", "y", "cat", ".", "of", "the", "IOSystem", "as", "unique", "names", "in", "order" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L212-L245
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.get_index
def get_index(self, as_dict=False, grouping_pattern=None): """ Returns the index of the DataFrames in the system Parameters ---------- as_dict: boolean, optional If True, returns a 1:1 key-value matching for further processing prior to groupby functions. Otherwis...
python
def get_index(self, as_dict=False, grouping_pattern=None): """ Returns the index of the DataFrames in the system Parameters ---------- as_dict: boolean, optional If True, returns a 1:1 key-value matching for further processing prior to groupby functions. Otherwis...
[ "def", "get_index", "(", "self", ",", "as_dict", "=", "False", ",", "grouping_pattern", "=", "None", ")", ":", "possible_dataframes", "=", "[", "'A'", ",", "'L'", ",", "'Z'", ",", "'Y'", ",", "'F'", ",", "'FY'", ",", "'M'", ",", "'S'", ",", "'D_cba'"...
Returns the index of the DataFrames in the system Parameters ---------- as_dict: boolean, optional If True, returns a 1:1 key-value matching for further processing prior to groupby functions. Otherwise (default) the index is returned as pandas index. ...
[ "Returns", "the", "index", "of", "the", "DataFrames", "in", "the", "system" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L247-L295
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.set_index
def set_index(self, index): """ Sets the pd dataframe index of all dataframes in the system to index """ for df in self.get_DataFrame(data=True, with_population=False): df.index = index
python
def set_index(self, index): """ Sets the pd dataframe index of all dataframes in the system to index """ for df in self.get_DataFrame(data=True, with_population=False): df.index = index
[ "def", "set_index", "(", "self", ",", "index", ")", ":", "for", "df", "in", "self", ".", "get_DataFrame", "(", "data", "=", "True", ",", "with_population", "=", "False", ")", ":", "df", ".", "index", "=", "index" ]
Sets the pd dataframe index of all dataframes in the system to index
[ "Sets", "the", "pd", "dataframe", "index", "of", "all", "dataframes", "in", "the", "system", "to", "index" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L297-L301
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.get_DataFrame
def get_DataFrame(self, data=False, with_unit=True, with_population=True): """ Yields all panda.DataFrames or there names Notes ----- For IOSystem this does not include the DataFrames in the extensions. Parameters ---------- data : boolean, optional ...
python
def get_DataFrame(self, data=False, with_unit=True, with_population=True): """ Yields all panda.DataFrames or there names Notes ----- For IOSystem this does not include the DataFrames in the extensions. Parameters ---------- data : boolean, optional ...
[ "def", "get_DataFrame", "(", "self", ",", "data", "=", "False", ",", "with_unit", "=", "True", ",", "with_population", "=", "True", ")", ":", "for", "key", "in", "self", ".", "__dict__", ":", "if", "(", "key", "is", "'unit'", ")", "and", "not", "with...
Yields all panda.DataFrames or there names Notes ----- For IOSystem this does not include the DataFrames in the extensions. Parameters ---------- data : boolean, optional If True, returns a generator which yields the DataFrames. If False, returns...
[ "Yields", "all", "panda", ".", "DataFrames", "or", "there", "names" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L384-L422
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.save
def save(self, path, table_format='txt', sep='\t', table_ext=None, float_format='%.12g'): """ Saving the system to path Parameters ---------- path : pathlib.Path or string path for the saved data (will be created if necessary, data within will be ov...
python
def save(self, path, table_format='txt', sep='\t', table_ext=None, float_format='%.12g'): """ Saving the system to path Parameters ---------- path : pathlib.Path or string path for the saved data (will be created if necessary, data within will be ov...
[ "def", "save", "(", "self", ",", "path", ",", "table_format", "=", "'txt'", ",", "sep", "=", "'\\t'", ",", "table_ext", "=", "None", ",", "float_format", "=", "'%.12g'", ")", ":", "if", "type", "(", "path", ")", "is", "str", ":", "path", "=", "path...
Saving the system to path Parameters ---------- path : pathlib.Path or string path for the saved data (will be created if necessary, data within will be overwritten). table_format : string Format to save the DataFrames: - 'pkl' : Bi...
[ "Saving", "the", "system", "to", "path" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L424-L527
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.rename_regions
def rename_regions(self, regions): """ Sets new names for the regions Parameters ---------- regions : list or dict In case of dict: {'old_name' : 'new_name'} with a entry for each old_name which should be renamed In case of list: List of new name...
python
def rename_regions(self, regions): """ Sets new names for the regions Parameters ---------- regions : list or dict In case of dict: {'old_name' : 'new_name'} with a entry for each old_name which should be renamed In case of list: List of new name...
[ "def", "rename_regions", "(", "self", ",", "regions", ")", ":", "if", "type", "(", "regions", ")", "is", "list", ":", "regions", "=", "{", "old", ":", "new", "for", "old", ",", "new", "in", "zip", "(", "self", ".", "get_regions", "(", ")", ",", "...
Sets new names for the regions Parameters ---------- regions : list or dict In case of dict: {'old_name' : 'new_name'} with a entry for each old_name which should be renamed In case of list: List of new names in order and complete without...
[ "Sets", "new", "names", "for", "the", "regions" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L529-L557
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.rename_sectors
def rename_sectors(self, sectors): """ Sets new names for the sectors Parameters ---------- sectors : list or dict In case of dict: {'old_name' : 'new_name'} with an entry for each old_name which should be renamed In case of list: List of new nam...
python
def rename_sectors(self, sectors): """ Sets new names for the sectors Parameters ---------- sectors : list or dict In case of dict: {'old_name' : 'new_name'} with an entry for each old_name which should be renamed In case of list: List of new nam...
[ "def", "rename_sectors", "(", "self", ",", "sectors", ")", ":", "if", "type", "(", "sectors", ")", "is", "list", ":", "sectors", "=", "{", "old", ":", "new", "for", "old", ",", "new", "in", "zip", "(", "self", ".", "get_sectors", "(", ")", ",", "...
Sets new names for the sectors Parameters ---------- sectors : list or dict In case of dict: {'old_name' : 'new_name'} with an entry for each old_name which should be renamed In case of list: List of new names in order and complete withou...
[ "Sets", "new", "names", "for", "the", "sectors" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L559-L586
konstantinstadler/pymrio
pymrio/core/mriosystem.py
CoreSystem.rename_Y_categories
def rename_Y_categories(self, Y_categories): """ Sets new names for the Y_categories Parameters ---------- Y_categories : list or dict In case of dict: {'old_name' : 'new_name'} with an entry for each old_name which should be renamed In case of l...
python
def rename_Y_categories(self, Y_categories): """ Sets new names for the Y_categories Parameters ---------- Y_categories : list or dict In case of dict: {'old_name' : 'new_name'} with an entry for each old_name which should be renamed In case of l...
[ "def", "rename_Y_categories", "(", "self", ",", "Y_categories", ")", ":", "if", "type", "(", "Y_categories", ")", "is", "list", ":", "Y_categories", "=", "{", "old", ":", "new", "for", "old", ",", "new", "in", "zip", "(", "self", ".", "get_Y_categories",...
Sets new names for the Y_categories Parameters ---------- Y_categories : list or dict In case of dict: {'old_name' : 'new_name'} with an entry for each old_name which should be renamed In case of list: List of new names in order and compl...
[ "Sets", "new", "names", "for", "the", "Y_categories" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L588-L618
konstantinstadler/pymrio
pymrio/core/mriosystem.py
Extension.calc_system
def calc_system(self, x, Y, Y_agg=None, L=None, population=None): """ Calculates the missing part of the extension plus accounts This method allows to specify an aggregated Y_agg for the account calculation (see Y_agg below). However, the full Y needs to be specified for the calculation...
python
def calc_system(self, x, Y, Y_agg=None, L=None, population=None): """ Calculates the missing part of the extension plus accounts This method allows to specify an aggregated Y_agg for the account calculation (see Y_agg below). However, the full Y needs to be specified for the calculation...
[ "def", "calc_system", "(", "self", ",", "x", ",", "Y", ",", "Y_agg", "=", "None", ",", "L", "=", "None", ",", "population", "=", "None", ")", ":", "if", "Y_agg", "is", "None", ":", "try", ":", "Y_agg", "=", "Y", ".", "sum", "(", "level", "=", ...
Calculates the missing part of the extension plus accounts This method allows to specify an aggregated Y_agg for the account calculation (see Y_agg below). However, the full Y needs to be specified for the calculation of FY or SY. Calculates: - for each sector and country: ...
[ "Calculates", "the", "missing", "part", "of", "the", "extension", "plus", "accounts" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L727-L907
konstantinstadler/pymrio
pymrio/core/mriosystem.py
Extension.plot_account
def plot_account(self, row, per_capita=False, sector=None, file_name=False, file_dpi=600, population=None, **kwargs): """ Plots D_pba, D_cba, D_imp and D_exp for the specified row (account) Plot either the total country accounts or for a specific sector, ...
python
def plot_account(self, row, per_capita=False, sector=None, file_name=False, file_dpi=600, population=None, **kwargs): """ Plots D_pba, D_cba, D_imp and D_exp for the specified row (account) Plot either the total country accounts or for a specific sector, ...
[ "def", "plot_account", "(", "self", ",", "row", ",", "per_capita", "=", "False", ",", "sector", "=", "None", ",", "file_name", "=", "False", ",", "file_dpi", "=", "600", ",", "population", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# necessary if...
Plots D_pba, D_cba, D_imp and D_exp for the specified row (account) Plot either the total country accounts or for a specific sector, depending on the 'sector' parameter. Per default the accounts are plotted as bar charts. However, any valid keyword for the pandas.DataFrame.plot ...
[ "Plots", "D_pba", "D_cba", "D_imp", "and", "D_exp", "for", "the", "specified", "row", "(", "account", ")" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L909-L1063
konstantinstadler/pymrio
pymrio/core/mriosystem.py
Extension.report_accounts
def report_accounts(self, path, per_region=True, per_capita=False, pic_size=1000, format='rst', ffname=None, **kwargs): """ Writes a report to the given path for the regional accounts The report consists of a text file and a folder with the pics (both names following pa...
python
def report_accounts(self, path, per_region=True, per_capita=False, pic_size=1000, format='rst', ffname=None, **kwargs): """ Writes a report to the given path for the regional accounts The report consists of a text file and a folder with the pics (both names following pa...
[ "def", "report_accounts", "(", "self", ",", "path", ",", "per_region", "=", "True", ",", "per_capita", "=", "False", ",", "pic_size", "=", "1000", ",", "format", "=", "'rst'", ",", "ffname", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not"...
Writes a report to the given path for the regional accounts The report consists of a text file and a folder with the pics (both names following parameter name) Notes ---- This looks prettier with the seaborn module (import seaborn before calling this method) ...
[ "Writes", "a", "report", "to", "the", "given", "path", "for", "the", "regional", "accounts" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1065-L1237
konstantinstadler/pymrio
pymrio/core/mriosystem.py
Extension.get_rows
def get_rows(self): """ Returns the name of the rows of the extension""" possible_dataframes = ['F', 'FY', 'M', 'S', 'D_cba', 'D_pba', 'D_imp', 'D_exp', 'D_cba_reg', 'D_pba_reg', 'D_imp_reg', 'D_exp_reg', ...
python
def get_rows(self): """ Returns the name of the rows of the extension""" possible_dataframes = ['F', 'FY', 'M', 'S', 'D_cba', 'D_pba', 'D_imp', 'D_exp', 'D_cba_reg', 'D_pba_reg', 'D_imp_reg', 'D_exp_reg', ...
[ "def", "get_rows", "(", "self", ")", ":", "possible_dataframes", "=", "[", "'F'", ",", "'FY'", ",", "'M'", ",", "'S'", ",", "'D_cba'", ",", "'D_pba'", ",", "'D_imp'", ",", "'D_exp'", ",", "'D_cba_reg'", ",", "'D_pba_reg'", ",", "'D_imp_reg'", ",", "'D_ex...
Returns the name of the rows of the extension
[ "Returns", "the", "name", "of", "the", "rows", "of", "the", "extension" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1239-L1252
konstantinstadler/pymrio
pymrio/core/mriosystem.py
Extension.get_row_data
def get_row_data(self, row, name=None): """ Returns a dict with all available data for a row in the extension Parameters ---------- row : tuple, list, string A valid index for the extension DataFrames name : string, optional If given, adds a key 'name' wi...
python
def get_row_data(self, row, name=None): """ Returns a dict with all available data for a row in the extension Parameters ---------- row : tuple, list, string A valid index for the extension DataFrames name : string, optional If given, adds a key 'name' wi...
[ "def", "get_row_data", "(", "self", ",", "row", ",", "name", "=", "None", ")", ":", "retdict", "=", "{", "}", "for", "rowname", ",", "data", "in", "zip", "(", "self", ".", "get_DataFrame", "(", ")", ",", "self", ".", "get_DataFrame", "(", "data", "...
Returns a dict with all available data for a row in the extension Parameters ---------- row : tuple, list, string A valid index for the extension DataFrames name : string, optional If given, adds a key 'name' with the given value to the dict. In that ...
[ "Returns", "a", "dict", "with", "all", "available", "data", "for", "a", "row", "in", "the", "extension" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1254-L1276
konstantinstadler/pymrio
pymrio/core/mriosystem.py
Extension.diag_stressor
def diag_stressor(self, stressor, name=None): """ Diagonalize one row of the stressor matrix for a flow analysis. This method takes one row of the F matrix and diagonalize to the full region/sector format. Footprints calculation based on this matrix show the flow of embodied stressors f...
python
def diag_stressor(self, stressor, name=None): """ Diagonalize one row of the stressor matrix for a flow analysis. This method takes one row of the F matrix and diagonalize to the full region/sector format. Footprints calculation based on this matrix show the flow of embodied stressors f...
[ "def", "diag_stressor", "(", "self", ",", "stressor", ",", "name", "=", "None", ")", ":", "if", "type", "(", "stressor", ")", "is", "int", ":", "stressor", "=", "self", ".", "F", ".", "index", "[", "stressor", "]", "if", "len", "(", "stressor", ")"...
Diagonalize one row of the stressor matrix for a flow analysis. This method takes one row of the F matrix and diagonalize to the full region/sector format. Footprints calculation based on this matrix show the flow of embodied stressors from the source region/sector (row index) to the fi...
[ "Diagonalize", "one", "row", "of", "the", "stressor", "matrix", "for", "a", "flow", "analysis", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1278-L1333
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.calc_system
def calc_system(self): """ Calculates the missing part of the core IOSystem The method checks Z, x, A, L and calculates all which are None """ # Possible cases: # 1) Z given, rest can be None and calculated # 2) A and x given, rest can be calculated # 3)...
python
def calc_system(self): """ Calculates the missing part of the core IOSystem The method checks Z, x, A, L and calculates all which are None """ # Possible cases: # 1) Z given, rest can be None and calculated # 2) A and x given, rest can be calculated # 3)...
[ "def", "calc_system", "(", "self", ")", ":", "# Possible cases:", "# 1) Z given, rest can be None and calculated", "# 2) A and x given, rest can be calculated", "# 3) A and Y , calc L (if not given) - calc x and the rest", "# this catches case 3", "if", "self", ".", "x", "is", "None"...
Calculates the missing part of the core IOSystem The method checks Z, x, A, L and calculates all which are None
[ "Calculates", "the", "missing", "part", "of", "the", "core", "IOSystem" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1454-L1492
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.calc_extensions
def calc_extensions(self, extensions=None, Y_agg=None): """ Calculates the extension and their accounts For the calculation, y is aggregated across specified y categories The method calls .calc_system of each extension (or these given in the extensions parameter) Parameters ...
python
def calc_extensions(self, extensions=None, Y_agg=None): """ Calculates the extension and their accounts For the calculation, y is aggregated across specified y categories The method calls .calc_system of each extension (or these given in the extensions parameter) Parameters ...
[ "def", "calc_extensions", "(", "self", ",", "extensions", "=", "None", ",", "Y_agg", "=", "None", ")", ":", "ext_list", "=", "list", "(", "self", ".", "get_extensions", "(", "data", "=", "False", ")", ")", "extensions", "=", "extensions", "or", "ext_list...
Calculates the extension and their accounts For the calculation, y is aggregated across specified y categories The method calls .calc_system of each extension (or these given in the extensions parameter) Parameters ---------- extensions : list of strings, optional ...
[ "Calculates", "the", "extension", "and", "their", "accounts" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1494-L1527
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.report_accounts
def report_accounts(self, path, per_region=True, per_capita=False, pic_size=1000, format='rst', **kwargs): """ Generates a report to the given path for all extension This method calls .report_accounts for all extensions Notes ----- ...
python
def report_accounts(self, path, per_region=True, per_capita=False, pic_size=1000, format='rst', **kwargs): """ Generates a report to the given path for all extension This method calls .report_accounts for all extensions Notes ----- ...
[ "def", "report_accounts", "(", "self", ",", "path", ",", "per_region", "=", "True", ",", "per_capita", "=", "False", ",", "pic_size", "=", "1000", ",", "format", "=", "'rst'", ",", "*", "*", "kwargs", ")", ":", "for", "ext", "in", "self", ".", "get_e...
Generates a report to the given path for all extension This method calls .report_accounts for all extensions Notes ----- This looks prettier with the seaborn module (import seaborn before calling this method) Parameters ---------- path : string ...
[ "Generates", "a", "report", "to", "the", "given", "path", "for", "all", "extension" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1529-L1574
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.get_extensions
def get_extensions(self, data=False): """ Yields the extensions or their names Parameters ---------- data : boolean, optional If True, returns a generator which yields the extensions. If False, returns a generator which yields the names of the extensions...
python
def get_extensions(self, data=False): """ Yields the extensions or their names Parameters ---------- data : boolean, optional If True, returns a generator which yields the extensions. If False, returns a generator which yields the names of the extensions...
[ "def", "get_extensions", "(", "self", ",", "data", "=", "False", ")", ":", "ext_list", "=", "[", "key", "for", "key", "in", "self", ".", "__dict__", "if", "type", "(", "self", ".", "__dict__", "[", "key", "]", ")", "is", "Extension", "]", "for", "k...
Yields the extensions or their names Parameters ---------- data : boolean, optional If True, returns a generator which yields the extensions. If False, returns a generator which yields the names of the extensions (default) Returns ------- ...
[ "Yields", "the", "extensions", "or", "their", "names" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1576-L1598
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.reset_full
def reset_full(self, force=False): """ Remove all accounts which can be recalculated based on Z, Y, F, FY Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. Default: False """ super...
python
def reset_full(self, force=False): """ Remove all accounts which can be recalculated based on Z, Y, F, FY Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. Default: False """ super...
[ "def", "reset_full", "(", "self", ",", "force", "=", "False", ")", ":", "super", "(", ")", ".", "reset_full", "(", "force", "=", "force", ",", "_meta", "=", "self", ".", "meta", ")", "return", "self" ]
Remove all accounts which can be recalculated based on Z, Y, F, FY Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. Default: False
[ "Remove", "all", "accounts", "which", "can", "be", "recalculated", "based", "on", "Z", "Y", "F", "FY" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1600-L1611
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.reset_all_full
def reset_all_full(self, force=False): """ Removes all accounts that can be recalculated (IOSystem and extensions) This calls reset_full for the core system and all extension. Parameters ---------- force: boolean, optional If True, reset to flows although the syste...
python
def reset_all_full(self, force=False): """ Removes all accounts that can be recalculated (IOSystem and extensions) This calls reset_full for the core system and all extension. Parameters ---------- force: boolean, optional If True, reset to flows although the syste...
[ "def", "reset_all_full", "(", "self", ",", "force", "=", "False", ")", ":", "self", ".", "reset_full", "(", ")", "[", "ee", ".", "reset_full", "(", ")", "for", "ee", "in", "self", ".", "get_extensions", "(", "data", "=", "True", ")", "]", "self", "...
Removes all accounts that can be recalculated (IOSystem and extensions) This calls reset_full for the core system and all extension. Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. Default: Fal...
[ "Removes", "all", "accounts", "that", "can", "be", "recalculated", "(", "IOSystem", "and", "extensions", ")" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1613-L1629
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.reset_to_flows
def reset_to_flows(self, force=False): """ Keeps only the absolute values. This removes all attributes which can not be aggregated and must be recalculated after the aggregation. Parameters ---------- force: boolean, optional If True, reset to flows althoug...
python
def reset_to_flows(self, force=False): """ Keeps only the absolute values. This removes all attributes which can not be aggregated and must be recalculated after the aggregation. Parameters ---------- force: boolean, optional If True, reset to flows althoug...
[ "def", "reset_to_flows", "(", "self", ",", "force", "=", "False", ")", ":", "super", "(", ")", ".", "reset_to_flows", "(", "force", "=", "force", ",", "_meta", "=", "self", ".", "meta", ")", "return", "self" ]
Keeps only the absolute values. This removes all attributes which can not be aggregated and must be recalculated after the aggregation. Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalculated. D...
[ "Keeps", "only", "the", "absolute", "values", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1631-L1645
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.reset_all_to_flows
def reset_all_to_flows(self, force=False): """ Resets the IOSystem and all extensions to absolute flows This method calls reset_to_flows for the IOSystem and for all Extensions in the system. Parameters ---------- force: boolean, optional If True, reset to ...
python
def reset_all_to_flows(self, force=False): """ Resets the IOSystem and all extensions to absolute flows This method calls reset_to_flows for the IOSystem and for all Extensions in the system. Parameters ---------- force: boolean, optional If True, reset to ...
[ "def", "reset_all_to_flows", "(", "self", ",", "force", "=", "False", ")", ":", "self", ".", "reset_to_flows", "(", "force", "=", "force", ")", "[", "ee", ".", "reset_to_flows", "(", "force", "=", "force", ")", "for", "ee", "in", "self", ".", "get_exte...
Resets the IOSystem and all extensions to absolute flows This method calls reset_to_flows for the IOSystem and for all Extensions in the system. Parameters ---------- force: boolean, optional If True, reset to flows although the system can not be recalc...
[ "Resets", "the", "IOSystem", "and", "all", "extensions", "to", "absolute", "flows" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1647-L1665
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.reset_all_to_coefficients
def reset_all_to_coefficients(self): """ Resets the IOSystem and all extensions to coefficients. This method calls reset_to_coefficients for the IOSystem and for all Extensions in the system Note ----- The system can not be reconstructed after this steps becaus...
python
def reset_all_to_coefficients(self): """ Resets the IOSystem and all extensions to coefficients. This method calls reset_to_coefficients for the IOSystem and for all Extensions in the system Note ----- The system can not be reconstructed after this steps becaus...
[ "def", "reset_all_to_coefficients", "(", "self", ")", ":", "self", ".", "reset_to_coefficients", "(", ")", "[", "ee", ".", "reset_to_coefficients", "(", ")", "for", "ee", "in", "self", ".", "get_extensions", "(", "data", "=", "True", ")", "]", "self", ".",...
Resets the IOSystem and all extensions to coefficients. This method calls reset_to_coefficients for the IOSystem and for all Extensions in the system Note ----- The system can not be reconstructed after this steps because all absolute data is removed. Save the Y data i...
[ "Resets", "the", "IOSystem", "and", "all", "extensions", "to", "coefficients", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1667-L1684
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.save_all
def save_all(self, path, table_format='txt', sep='\t', table_ext=None, float_format='%.12g'): """ Saves the system and all extensions Extensions are saved in separate folders (names based on extension) Parameters are passed to the .save methods of the IOSystem and Exte...
python
def save_all(self, path, table_format='txt', sep='\t', table_ext=None, float_format='%.12g'): """ Saves the system and all extensions Extensions are saved in separate folders (names based on extension) Parameters are passed to the .save methods of the IOSystem and Exte...
[ "def", "save_all", "(", "self", ",", "path", ",", "table_format", "=", "'txt'", ",", "sep", "=", "'\\t'", ",", "table_ext", "=", "None", ",", "float_format", "=", "'%.12g'", ")", ":", "if", "type", "(", "path", ")", "is", "str", ":", "path", "=", "...
Saves the system and all extensions Extensions are saved in separate folders (names based on extension) Parameters are passed to the .save methods of the IOSystem and Extensions. See parameters description there.
[ "Saves", "the", "system", "and", "all", "extensions" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1686-L1717
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.aggregate
def aggregate(self, region_agg=None, sector_agg=None, region_names=None, sector_names=None, inplace=True, pre_aggregation=False): """ Aggregates the IO system. Aggregation can be given as vector (use pymrio.build_agg_vec) or aggregation matrix. In the...
python
def aggregate(self, region_agg=None, sector_agg=None, region_names=None, sector_names=None, inplace=True, pre_aggregation=False): """ Aggregates the IO system. Aggregation can be given as vector (use pymrio.build_agg_vec) or aggregation matrix. In the...
[ "def", "aggregate", "(", "self", ",", "region_agg", "=", "None", ",", "sector_agg", "=", "None", ",", "region_names", "=", "None", ",", "sector_names", "=", "None", ",", "inplace", "=", "True", ",", "pre_aggregation", "=", "False", ")", ":", "# Development...
Aggregates the IO system. Aggregation can be given as vector (use pymrio.build_agg_vec) or aggregation matrix. In the case of a vector this must be of length self.get_regions() / self.get_sectors() respectively with the new position as integer or a string of the new name...
[ "Aggregates", "the", "IO", "system", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1719-L1995
konstantinstadler/pymrio
pymrio/core/mriosystem.py
IOSystem.remove_extension
def remove_extension(self, ext=None): """ Remove extension from IOSystem For single Extensions the same can be achieved with del IOSystem_name.Extension_name Parameters ---------- ext : string or list, optional The extension to remove, this can be given as t...
python
def remove_extension(self, ext=None): """ Remove extension from IOSystem For single Extensions the same can be achieved with del IOSystem_name.Extension_name Parameters ---------- ext : string or list, optional The extension to remove, this can be given as t...
[ "def", "remove_extension", "(", "self", ",", "ext", "=", "None", ")", ":", "if", "ext", "is", "None", ":", "ext", "=", "list", "(", "self", ".", "get_extensions", "(", ")", ")", "if", "type", "(", "ext", ")", "is", "str", ":", "ext", "=", "[", ...
Remove extension from IOSystem For single Extensions the same can be achieved with del IOSystem_name.Extension_name Parameters ---------- ext : string or list, optional The extension to remove, this can be given as the name of the instance or of Extensio...
[ "Remove", "extension", "from", "IOSystem" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/core/mriosystem.py#L1997-L2028
konstantinstadler/pymrio
pymrio/tools/ioutil.py
is_vector
def is_vector(inp): """ Returns true if the input can be interpreted as a 'true' vector Note ---- Does only check dimensions, not if type is numeric Parameters ---------- inp : numpy.ndarray or something that can be converted into ndarray Returns ------- Boolean True f...
python
def is_vector(inp): """ Returns true if the input can be interpreted as a 'true' vector Note ---- Does only check dimensions, not if type is numeric Parameters ---------- inp : numpy.ndarray or something that can be converted into ndarray Returns ------- Boolean True f...
[ "def", "is_vector", "(", "inp", ")", ":", "inp", "=", "np", ".", "asarray", "(", "inp", ")", "nr_dim", "=", "np", ".", "ndim", "(", "inp", ")", "if", "nr_dim", "==", "1", ":", "return", "True", "elif", "(", "nr_dim", "==", "2", ")", "and", "(",...
Returns true if the input can be interpreted as a 'true' vector Note ---- Does only check dimensions, not if type is numeric Parameters ---------- inp : numpy.ndarray or something that can be converted into ndarray Returns ------- Boolean True for vectors: ndim = 1 or ndim...
[ "Returns", "true", "if", "the", "input", "can", "be", "interpreted", "as", "a", "true", "vector" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L19-L43
konstantinstadler/pymrio
pymrio/tools/ioutil.py
get_repo_content
def get_repo_content(path): """ List of files in a repo (path or zip) Parameters ---------- path: string or pathlib.Path Returns ------- Returns a namedtuple with .iszip and .filelist The path in filelist are pure strings. """ path = Path(path) if zipfile.is_zipfile(st...
python
def get_repo_content(path): """ List of files in a repo (path or zip) Parameters ---------- path: string or pathlib.Path Returns ------- Returns a namedtuple with .iszip and .filelist The path in filelist are pure strings. """ path = Path(path) if zipfile.is_zipfile(st...
[ "def", "get_repo_content", "(", "path", ")", ":", "path", "=", "Path", "(", "path", ")", "if", "zipfile", ".", "is_zipfile", "(", "str", "(", "path", ")", ")", ":", "with", "zipfile", ".", "ZipFile", "(", "str", "(", "path", ")", ")", "as", "zz", ...
List of files in a repo (path or zip) Parameters ---------- path: string or pathlib.Path Returns ------- Returns a namedtuple with .iszip and .filelist The path in filelist are pure strings.
[ "List", "of", "files", "in", "a", "repo", "(", "path", "or", "zip", ")" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L46-L71
konstantinstadler/pymrio
pymrio/tools/ioutil.py
get_file_para
def get_file_para(path, path_in_arc=''): """ Generic method to read the file parameter file Helper function to consistently read the file parameter file, which can either be uncompressed or included in a zip archive. By default, the file name is to be expected as set in DEFAULT_FILE_NAMES['filepara'] ...
python
def get_file_para(path, path_in_arc=''): """ Generic method to read the file parameter file Helper function to consistently read the file parameter file, which can either be uncompressed or included in a zip archive. By default, the file name is to be expected as set in DEFAULT_FILE_NAMES['filepara'] ...
[ "def", "get_file_para", "(", "path", ",", "path_in_arc", "=", "''", ")", ":", "if", "type", "(", "path", ")", "is", "str", ":", "path", "=", "Path", "(", "path", ".", "rstrip", "(", "'\\\\'", ")", ")", "if", "zipfile", ".", "is_zipfile", "(", "str"...
Generic method to read the file parameter file Helper function to consistently read the file parameter file, which can either be uncompressed or included in a zip archive. By default, the file name is to be expected as set in DEFAULT_FILE_NAMES['filepara'] (currently file_parameters.json), but can def...
[ "Generic", "method", "to", "read", "the", "file", "parameter", "file" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L74-L151
konstantinstadler/pymrio
pymrio/tools/ioutil.py
build_agg_matrix
def build_agg_matrix(agg_vector, pos_dict=None): """ Agg. matrix based on mapping given in input as numerical or str vector. The aggregation matrix has the from nxm with -n new classificaction -m old classification Parameters ---------- agg_vector : list or vector like numpy ndarray...
python
def build_agg_matrix(agg_vector, pos_dict=None): """ Agg. matrix based on mapping given in input as numerical or str vector. The aggregation matrix has the from nxm with -n new classificaction -m old classification Parameters ---------- agg_vector : list or vector like numpy ndarray...
[ "def", "build_agg_matrix", "(", "agg_vector", ",", "pos_dict", "=", "None", ")", ":", "if", "isinstance", "(", "agg_vector", ",", "np", ".", "ndarray", ")", ":", "agg_vector", "=", "agg_vector", ".", "flatten", "(", ")", ".", "tolist", "(", ")", "if", ...
Agg. matrix based on mapping given in input as numerical or str vector. The aggregation matrix has the from nxm with -n new classificaction -m old classification Parameters ---------- agg_vector : list or vector like numpy ndarray This can be row or column vector. ...
[ "Agg", ".", "matrix", "based", "on", "mapping", "given", "in", "input", "as", "numerical", "or", "str", "vector", "." ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L154-L230
konstantinstadler/pymrio
pymrio/tools/ioutil.py
diagonalize_blocks
def diagonalize_blocks(arr, blocksize): """ Diagonalize sections of columns of an array for the whole array Parameters ---------- arr : numpy array Input array blocksize : int number of rows/colums forming one block Returns ------- numpy ndarray with shape (columns 'a...
python
def diagonalize_blocks(arr, blocksize): """ Diagonalize sections of columns of an array for the whole array Parameters ---------- arr : numpy array Input array blocksize : int number of rows/colums forming one block Returns ------- numpy ndarray with shape (columns 'a...
[ "def", "diagonalize_blocks", "(", "arr", ",", "blocksize", ")", ":", "nr_col", "=", "arr", ".", "shape", "[", "1", "]", "nr_row", "=", "arr", ".", "shape", "[", "0", "]", "if", "np", ".", "mod", "(", "nr_row", ",", "blocksize", ")", ":", "raise", ...
Diagonalize sections of columns of an array for the whole array Parameters ---------- arr : numpy array Input array blocksize : int number of rows/colums forming one block Returns ------- numpy ndarray with shape (columns 'arr' * blocksize, c...
[ "Diagonalize", "sections", "of", "columns", "of", "an", "array", "for", "the", "whole", "array" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L233-L280
konstantinstadler/pymrio
pymrio/tools/ioutil.py
set_block
def set_block(arr, arr_block): """ Sets the diagonal blocks of an array to an given array Parameters ---------- arr : numpy ndarray the original array block_arr : numpy ndarray the block array for the new diagonal Returns ------- numpy ndarray (the modified array) ...
python
def set_block(arr, arr_block): """ Sets the diagonal blocks of an array to an given array Parameters ---------- arr : numpy ndarray the original array block_arr : numpy ndarray the block array for the new diagonal Returns ------- numpy ndarray (the modified array) ...
[ "def", "set_block", "(", "arr", ",", "arr_block", ")", ":", "nr_col", "=", "arr", ".", "shape", "[", "1", "]", "nr_row", "=", "arr", ".", "shape", "[", "0", "]", "nr_col_block", "=", "arr_block", ".", "shape", "[", "1", "]", "nr_row_block", "=", "a...
Sets the diagonal blocks of an array to an given array Parameters ---------- arr : numpy ndarray the original array block_arr : numpy ndarray the block array for the new diagonal Returns ------- numpy ndarray (the modified array)
[ "Sets", "the", "diagonal", "blocks", "of", "an", "array", "to", "an", "given", "array" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L283-L321
konstantinstadler/pymrio
pymrio/tools/ioutil.py
unique_element
def unique_element(ll): """ returns unique elements from a list preserving the original order """ seen = {} result = [] for item in ll: if item in seen: continue seen[item] = 1 result.append(item) return result
python
def unique_element(ll): """ returns unique elements from a list preserving the original order """ seen = {} result = [] for item in ll: if item in seen: continue seen[item] = 1 result.append(item) return result
[ "def", "unique_element", "(", "ll", ")", ":", "seen", "=", "{", "}", "result", "=", "[", "]", "for", "item", "in", "ll", ":", "if", "item", "in", "seen", ":", "continue", "seen", "[", "item", "]", "=", "1", "result", ".", "append", "(", "item", ...
returns unique elements from a list preserving the original order
[ "returns", "unique", "elements", "from", "a", "list", "preserving", "the", "original", "order" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L324-L333
konstantinstadler/pymrio
pymrio/tools/ioutil.py
build_agg_vec
def build_agg_vec(agg_vec, **source): """ Builds an combined aggregation vector based on various classifications This function build an aggregation vector based on the order in agg_vec. The naming and actual mapping is given in source, either explicitly or by pointing to a folder with the mapping. ...
python
def build_agg_vec(agg_vec, **source): """ Builds an combined aggregation vector based on various classifications This function build an aggregation vector based on the order in agg_vec. The naming and actual mapping is given in source, either explicitly or by pointing to a folder with the mapping. ...
[ "def", "build_agg_vec", "(", "agg_vec", ",", "*", "*", "source", ")", ":", "# build a dict with aggregation vectors in source and folder", "if", "type", "(", "agg_vec", ")", "is", "str", ":", "agg_vec", "=", "[", "agg_vec", "]", "agg_dict", "=", "dict", "(", "...
Builds an combined aggregation vector based on various classifications This function build an aggregation vector based on the order in agg_vec. The naming and actual mapping is given in source, either explicitly or by pointing to a folder with the mapping. >>> build_agg_vec(['EU', 'OECD'], path = 'tes...
[ "Builds", "an", "combined", "aggregation", "vector", "based", "on", "various", "classifications" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L336-L444
konstantinstadler/pymrio
pymrio/tools/ioutil.py
find_first_number
def find_first_number(ll): """ Returns nr of first entry parseable to float in ll, None otherwise""" for nr, entry in enumerate(ll): try: float(entry) except (ValueError, TypeError) as e: pass else: return nr return None
python
def find_first_number(ll): """ Returns nr of first entry parseable to float in ll, None otherwise""" for nr, entry in enumerate(ll): try: float(entry) except (ValueError, TypeError) as e: pass else: return nr return None
[ "def", "find_first_number", "(", "ll", ")", ":", "for", "nr", ",", "entry", "in", "enumerate", "(", "ll", ")", ":", "try", ":", "float", "(", "entry", ")", "except", "(", "ValueError", ",", "TypeError", ")", "as", "e", ":", "pass", "else", ":", "re...
Returns nr of first entry parseable to float in ll, None otherwise
[ "Returns", "nr", "of", "first", "entry", "parseable", "to", "float", "in", "ll", "None", "otherwise" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L447-L456
konstantinstadler/pymrio
pymrio/tools/ioutil.py
sniff_csv_format
def sniff_csv_format(csv_file, potential_sep=['\t', ',', ';', '|', '-', '_'], max_test_lines=10, zip_file=None): """ Tries to get the separator, nr of index cols and header rows in a csv file Parameters ---------- csv_file: str Pat...
python
def sniff_csv_format(csv_file, potential_sep=['\t', ',', ';', '|', '-', '_'], max_test_lines=10, zip_file=None): """ Tries to get the separator, nr of index cols and header rows in a csv file Parameters ---------- csv_file: str Pat...
[ "def", "sniff_csv_format", "(", "csv_file", ",", "potential_sep", "=", "[", "'\\t'", ",", "','", ",", "';'", ",", "'|'", ",", "'-'", ",", "'_'", "]", ",", "max_test_lines", "=", "10", ",", "zip_file", "=", "None", ")", ":", "def", "read_first_lines", "...
Tries to get the separator, nr of index cols and header rows in a csv file Parameters ---------- csv_file: str Path to a csv file potential_sep: list, optional List of potential separators (delimiters) to test. Default: '\t', ',', ';', '|', '-', '_' max_test_lines: int, o...
[ "Tries", "to", "get", "the", "separator", "nr", "of", "index", "cols", "and", "header", "rows", "in", "a", "csv", "file" ]
train
https://github.com/konstantinstadler/pymrio/blob/d764aa0dd2150200e867a9713a98ddae203e12d4/pymrio/tools/ioutil.py#L459-L540
tmc/gevent-zeromq
gevent_zeromq/poll.py
GreenPoller._get_descriptors
def _get_descriptors(self): """Returns three elements tuple with socket descriptors ready for gevent.select.select """ rlist = [] wlist = [] xlist = [] for socket, flags in self.sockets.items(): if isinstance(socket, zmq.Socket): rlist...
python
def _get_descriptors(self): """Returns three elements tuple with socket descriptors ready for gevent.select.select """ rlist = [] wlist = [] xlist = [] for socket, flags in self.sockets.items(): if isinstance(socket, zmq.Socket): rlist...
[ "def", "_get_descriptors", "(", "self", ")", ":", "rlist", "=", "[", "]", "wlist", "=", "[", "]", "xlist", "=", "[", "]", "for", "socket", ",", "flags", "in", "self", ".", "sockets", ".", "items", "(", ")", ":", "if", "isinstance", "(", "socket", ...
Returns three elements tuple with socket descriptors ready for gevent.select.select
[ "Returns", "three", "elements", "tuple", "with", "socket", "descriptors", "ready", "for", "gevent", ".", "select", ".", "select" ]
train
https://github.com/tmc/gevent-zeromq/blob/b15d50deedda3d2cdb701106d4b315c7a06353e3/gevent_zeromq/poll.py#L14-L44
tmc/gevent-zeromq
gevent_zeromq/poll.py
GreenPoller.poll
def poll(self, timeout=-1): """Overridden method to ensure that the green version of Poller is used. Behaves the same as :meth:`zmq.core.Poller.poll` """ if timeout is None: timeout = -1 if timeout < 0: timeout = -1 rlist = None ...
python
def poll(self, timeout=-1): """Overridden method to ensure that the green version of Poller is used. Behaves the same as :meth:`zmq.core.Poller.poll` """ if timeout is None: timeout = -1 if timeout < 0: timeout = -1 rlist = None ...
[ "def", "poll", "(", "self", ",", "timeout", "=", "-", "1", ")", ":", "if", "timeout", "is", "None", ":", "timeout", "=", "-", "1", "if", "timeout", "<", "0", ":", "timeout", "=", "-", "1", "rlist", "=", "None", "wlist", "=", "None", "xlist", "=...
Overridden method to ensure that the green version of Poller is used. Behaves the same as :meth:`zmq.core.Poller.poll`
[ "Overridden", "method", "to", "ensure", "that", "the", "green", "version", "of", "Poller", "is", "used", "." ]
train
https://github.com/tmc/gevent-zeromq/blob/b15d50deedda3d2cdb701106d4b315c7a06353e3/gevent_zeromq/poll.py#L46-L83
shichao-an/115wangpan
u115/api.py
_instantiate_task
def _instantiate_task(api, kwargs): """Create a Task object from raw kwargs""" file_id = kwargs['file_id'] kwargs['file_id'] = file_id if str(file_id).strip() else None kwargs['cid'] = kwargs['file_id'] or None kwargs['rate_download'] = kwargs['rateDownload'] kwargs['percent_done'] = kwargs['per...
python
def _instantiate_task(api, kwargs): """Create a Task object from raw kwargs""" file_id = kwargs['file_id'] kwargs['file_id'] = file_id if str(file_id).strip() else None kwargs['cid'] = kwargs['file_id'] or None kwargs['rate_download'] = kwargs['rateDownload'] kwargs['percent_done'] = kwargs['per...
[ "def", "_instantiate_task", "(", "api", ",", "kwargs", ")", ":", "file_id", "=", "kwargs", "[", "'file_id'", "]", "kwargs", "[", "'file_id'", "]", "=", "file_id", "if", "str", "(", "file_id", ")", ".", "strip", "(", ")", "else", "None", "kwargs", "[", ...
Create a Task object from raw kwargs
[ "Create", "a", "Task", "object", "from", "raw", "kwargs" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1740-L1764
shichao-an/115wangpan
u115/api.py
RequestHandler.get
def get(self, url, params=None): """ Initiate a GET request """ r = self.session.get(url, params=params) return self._response_parser(r, expect_json=False)
python
def get(self, url, params=None): """ Initiate a GET request """ r = self.session.get(url, params=params) return self._response_parser(r, expect_json=False)
[ "def", "get", "(", "self", ",", "url", ",", "params", "=", "None", ")", ":", "r", "=", "self", ".", "session", ".", "get", "(", "url", ",", "params", "=", "params", ")", "return", "self", ".", "_response_parser", "(", "r", ",", "expect_json", "=", ...
Initiate a GET request
[ "Initiate", "a", "GET", "request" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L56-L61
shichao-an/115wangpan
u115/api.py
RequestHandler.post
def post(self, url, data, params=None): """ Initiate a POST request """ r = self.session.post(url, data=data, params=params) return self._response_parser(r, expect_json=False)
python
def post(self, url, data, params=None): """ Initiate a POST request """ r = self.session.post(url, data=data, params=params) return self._response_parser(r, expect_json=False)
[ "def", "post", "(", "self", ",", "url", ",", "data", ",", "params", "=", "None", ")", ":", "r", "=", "self", ".", "session", ".", "post", "(", "url", ",", "data", "=", "data", ",", "params", "=", "params", ")", "return", "self", ".", "_response_p...
Initiate a POST request
[ "Initiate", "a", "POST", "request" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L63-L68
shichao-an/115wangpan
u115/api.py
RequestHandler.send
def send(self, request, expect_json=True, ignore_content=False): """ Send a formatted API request :param request: a formatted request object :type request: :class:`.Request` :param bool expect_json: if True, raise :class:`.InvalidAPIAccess` if response is not in JSON...
python
def send(self, request, expect_json=True, ignore_content=False): """ Send a formatted API request :param request: a formatted request object :type request: :class:`.Request` :param bool expect_json: if True, raise :class:`.InvalidAPIAccess` if response is not in JSON...
[ "def", "send", "(", "self", ",", "request", ",", "expect_json", "=", "True", ",", "ignore_content", "=", "False", ")", ":", "r", "=", "self", ".", "session", ".", "request", "(", "method", "=", "request", ".", "method", ",", "url", "=", "request", "....
Send a formatted API request :param request: a formatted request object :type request: :class:`.Request` :param bool expect_json: if True, raise :class:`.InvalidAPIAccess` if response is not in JSON format :param bool ignore_content: whether to ignore setting content of the ...
[ "Send", "a", "formatted", "API", "request" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L70-L87
shichao-an/115wangpan
u115/api.py
RequestHandler._response_parser
def _response_parser(self, r, expect_json=True, ignore_content=False): """ :param :class:`requests.Response` r: a response object of the Requests library :param bool expect_json: if True, raise :class:`.InvalidAPIAccess` if response is not in JSON format :param bo...
python
def _response_parser(self, r, expect_json=True, ignore_content=False): """ :param :class:`requests.Response` r: a response object of the Requests library :param bool expect_json: if True, raise :class:`.InvalidAPIAccess` if response is not in JSON format :param bo...
[ "def", "_response_parser", "(", "self", ",", "r", ",", "expect_json", "=", "True", ",", "ignore_content", "=", "False", ")", ":", "if", "r", ".", "ok", ":", "try", ":", "j", "=", "r", ".", "json", "(", ")", "return", "Response", "(", "j", ".", "g...
:param :class:`requests.Response` r: a response object of the Requests library :param bool expect_json: if True, raise :class:`.InvalidAPIAccess` if response is not in JSON format :param bool ignore_content: whether to ignore setting content of the Response object
[ ":", "param", ":", "class", ":", "requests", ".", "Response", "r", ":", "a", "response", "object", "of", "the", "Requests", "library", ":", "param", "bool", "expect_json", ":", "if", "True", "raise", ":", "class", ":", ".", "InvalidAPIAccess", "if", "res...
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L89-L115
shichao-an/115wangpan
u115/api.py
API.load_cookies
def load_cookies(self, ignore_discard=True, ignore_expires=True): """Load cookies from the file :attr:`.API.cookies_filename`""" self._init_cookies() if os.path.exists(self.cookies.filename): self.cookies.load(ignore_discard=ignore_discard, ignore_expire...
python
def load_cookies(self, ignore_discard=True, ignore_expires=True): """Load cookies from the file :attr:`.API.cookies_filename`""" self._init_cookies() if os.path.exists(self.cookies.filename): self.cookies.load(ignore_discard=ignore_discard, ignore_expire...
[ "def", "load_cookies", "(", "self", ",", "ignore_discard", "=", "True", ",", "ignore_expires", "=", "True", ")", ":", "self", ".", "_init_cookies", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "cookies", ".", "filename", ")", ":"...
Load cookies from the file :attr:`.API.cookies_filename`
[ "Load", "cookies", "from", "the", "file", ":", "attr", ":", ".", "API", ".", "cookies_filename" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L250-L256
shichao-an/115wangpan
u115/api.py
API.save_cookies
def save_cookies(self, ignore_discard=True, ignore_expires=True): """Save cookies to the file :attr:`.API.cookies_filename`""" if not isinstance(self.cookies, cookielib.FileCookieJar): m = 'Cookies must be a cookielib.FileCookieJar object to be saved.' raise APIError(m) s...
python
def save_cookies(self, ignore_discard=True, ignore_expires=True): """Save cookies to the file :attr:`.API.cookies_filename`""" if not isinstance(self.cookies, cookielib.FileCookieJar): m = 'Cookies must be a cookielib.FileCookieJar object to be saved.' raise APIError(m) s...
[ "def", "save_cookies", "(", "self", ",", "ignore_discard", "=", "True", ",", "ignore_expires", "=", "True", ")", ":", "if", "not", "isinstance", "(", "self", ".", "cookies", ",", "cookielib", ".", "FileCookieJar", ")", ":", "m", "=", "'Cookies must be a cook...
Save cookies to the file :attr:`.API.cookies_filename`
[ "Save", "cookies", "to", "the", "file", ":", "attr", ":", ".", "API", ".", "cookies_filename" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L258-L264
shichao-an/115wangpan
u115/api.py
API.login
def login(self, username=None, password=None, section='default'): """ Created the passport with ``username`` and ``password`` and log in. If either ``username`` or ``password`` is None or omitted, the credentials file will be parsed. :param str username: username t...
python
def login(self, username=None, password=None, section='default'): """ Created the passport with ``username`` and ``password`` and log in. If either ``username`` or ``password`` is None or omitted, the credentials file will be parsed. :param str username: username t...
[ "def", "login", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ",", "section", "=", "'default'", ")", ":", "if", "self", ".", "has_logged_in", ":", "return", "True", "if", "username", "is", "None", "or", "password", "is", "Non...
Created the passport with ``username`` and ``password`` and log in. If either ``username`` or ``password`` is None or omitted, the credentials file will be parsed. :param str username: username to login (email, phone number or user ID) :param str password: password :param str se...
[ "Created", "the", "passport", "with", "username", "and", "password", "and", "log", "in", ".", "If", "either", "username", "or", "password", "is", "None", "or", "omitted", "the", "credentials", "file", "will", "be", "parsed", "." ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L280-L315
shichao-an/115wangpan
u115/api.py
API.user_id
def user_id(self): """ User id of the current API user """ if self._user_id is None: if self.has_logged_in: self._user_id = self._req_get_user_aq()['data']['uid'] else: raise AuthenticationError('Not logged in.') return self...
python
def user_id(self): """ User id of the current API user """ if self._user_id is None: if self.has_logged_in: self._user_id = self._req_get_user_aq()['data']['uid'] else: raise AuthenticationError('Not logged in.') return self...
[ "def", "user_id", "(", "self", ")", ":", "if", "self", ".", "_user_id", "is", "None", ":", "if", "self", ".", "has_logged_in", ":", "self", ".", "_user_id", "=", "self", ".", "_req_get_user_aq", "(", ")", "[", "'data'", "]", "[", "'uid'", "]", "else"...
User id of the current API user
[ "User", "id", "of", "the", "current", "API", "user" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L328-L337
shichao-an/115wangpan
u115/api.py
API.username
def username(self): """ Username of the current API user """ if self._username is None: if self.has_logged_in: self._username = self._get_username() else: raise AuthenticationError('Not logged in.') return self._username
python
def username(self): """ Username of the current API user """ if self._username is None: if self.has_logged_in: self._username = self._get_username() else: raise AuthenticationError('Not logged in.') return self._username
[ "def", "username", "(", "self", ")", ":", "if", "self", ".", "_username", "is", "None", ":", "if", "self", ".", "has_logged_in", ":", "self", ".", "_username", "=", "self", ".", "_get_username", "(", ")", "else", ":", "raise", "AuthenticationError", "(",...
Username of the current API user
[ "Username", "of", "the", "current", "API", "user" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L340-L349
shichao-an/115wangpan
u115/api.py
API.has_logged_in
def has_logged_in(self): """Check whether the API has logged in""" r = self.http.get(CHECKPOINT_URL) if r.state is False: return True # If logged out, flush cache self._reset_cache() return False
python
def has_logged_in(self): """Check whether the API has logged in""" r = self.http.get(CHECKPOINT_URL) if r.state is False: return True # If logged out, flush cache self._reset_cache() return False
[ "def", "has_logged_in", "(", "self", ")", ":", "r", "=", "self", ".", "http", ".", "get", "(", "CHECKPOINT_URL", ")", "if", "r", ".", "state", "is", "False", ":", "return", "True", "# If logged out, flush cache", "self", ".", "_reset_cache", "(", ")", "r...
Check whether the API has logged in
[ "Check", "whether", "the", "API", "has", "logged", "in" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L352-L359
shichao-an/115wangpan
u115/api.py
API.receiver_directory
def receiver_directory(self): """Parent directory of the downloads directory""" if self._receiver_directory is None: self._receiver_directory = self.downloads_directory.parent return self._receiver_directory
python
def receiver_directory(self): """Parent directory of the downloads directory""" if self._receiver_directory is None: self._receiver_directory = self.downloads_directory.parent return self._receiver_directory
[ "def", "receiver_directory", "(", "self", ")", ":", "if", "self", ".", "_receiver_directory", "is", "None", ":", "self", ".", "_receiver_directory", "=", "self", ".", "downloads_directory", ".", "parent", "return", "self", ".", "_receiver_directory" ]
Parent directory of the downloads directory
[ "Parent", "directory", "of", "the", "downloads", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L382-L386
shichao-an/115wangpan
u115/api.py
API.add_task_bt
def add_task_bt(self, filename, select=False): """ Add a new BT task :param str filename: path to torrent file to upload :param bool select: whether to select files in the torrent. * True: it returns the opened torrent (:class:`.Torrent`) and can then iterat...
python
def add_task_bt(self, filename, select=False): """ Add a new BT task :param str filename: path to torrent file to upload :param bool select: whether to select files in the torrent. * True: it returns the opened torrent (:class:`.Torrent`) and can then iterat...
[ "def", "add_task_bt", "(", "self", ",", "filename", ",", "select", "=", "False", ")", ":", "filename", "=", "eval_path", "(", "filename", ")", "u", "=", "self", ".", "upload", "(", "filename", ",", "self", ".", "torrents_directory", ")", "t", "=", "sel...
Add a new BT task :param str filename: path to torrent file to upload :param bool select: whether to select files in the torrent. * True: it returns the opened torrent (:class:`.Torrent`) and can then iterate files in :attr:`.Torrent.files` and select/unsele...
[ "Add", "a", "new", "BT", "task" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L421-L439
shichao-an/115wangpan
u115/api.py
API.get_storage_info
def get_storage_info(self, human=False): """ Get storage info :param bool human: whether return human-readable size :return: total and used storage :rtype: dict """ res = self._req_get_storage_info() if human: res['total'] = humanize.naturals...
python
def get_storage_info(self, human=False): """ Get storage info :param bool human: whether return human-readable size :return: total and used storage :rtype: dict """ res = self._req_get_storage_info() if human: res['total'] = humanize.naturals...
[ "def", "get_storage_info", "(", "self", ",", "human", "=", "False", ")", ":", "res", "=", "self", ".", "_req_get_storage_info", "(", ")", "if", "human", ":", "res", "[", "'total'", "]", "=", "humanize", ".", "naturalsize", "(", "res", "[", "'total'", "...
Get storage info :param bool human: whether return human-readable size :return: total and used storage :rtype: dict
[ "Get", "storage", "info" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L450-L463
shichao-an/115wangpan
u115/api.py
API.upload
def upload(self, filename, directory=None): """ Upload a file ``filename`` to ``directory`` :param str filename: path to the file to upload :param directory: destionation :class:`.Directory`, defaults to :attribute:`.API.downloads_directory` if None :return: the uplo...
python
def upload(self, filename, directory=None): """ Upload a file ``filename`` to ``directory`` :param str filename: path to the file to upload :param directory: destionation :class:`.Directory`, defaults to :attribute:`.API.downloads_directory` if None :return: the uplo...
[ "def", "upload", "(", "self", ",", "filename", ",", "directory", "=", "None", ")", ":", "filename", "=", "eval_path", "(", "filename", ")", "if", "directory", "is", "None", ":", "directory", "=", "self", ".", "downloads_directory", "# First request", "res1",...
Upload a file ``filename`` to ``directory`` :param str filename: path to the file to upload :param directory: destionation :class:`.Directory`, defaults to :attribute:`.API.downloads_directory` if None :return: the uploaded file :rtype: :class:`.File`
[ "Upload", "a", "file", "filename", "to", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L465-L488
shichao-an/115wangpan
u115/api.py
API.download
def download(self, obj, path=None, show_progress=True, resume=True, auto_retry=True, proapi=False): """ Download a file :param obj: :class:`.File` object :param str path: local path :param bool show_progress: whether to show download progress :param bool...
python
def download(self, obj, path=None, show_progress=True, resume=True, auto_retry=True, proapi=False): """ Download a file :param obj: :class:`.File` object :param str path: local path :param bool show_progress: whether to show download progress :param bool...
[ "def", "download", "(", "self", ",", "obj", ",", "path", "=", "None", ",", "show_progress", "=", "True", ",", "resume", "=", "True", ",", "auto_retry", "=", "True", ",", "proapi", "=", "False", ")", ":", "url", "=", "obj", ".", "get_download_url", "(...
Download a file :param obj: :class:`.File` object :param str path: local path :param bool show_progress: whether to show download progress :param bool resume: whether to resume on unfinished downloads identified by filename :param bool auto_retry: whether to retry au...
[ "Download", "a", "file" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L490-L507
shichao-an/115wangpan
u115/api.py
API.search
def search(self, keyword, count=30): """ Search files or directories :param str keyword: keyword :param int count: number of entries to be listed """ kwargs = {} kwargs['search_value'] = keyword root = self.root_directory entries = root._load_entr...
python
def search(self, keyword, count=30): """ Search files or directories :param str keyword: keyword :param int count: number of entries to be listed """ kwargs = {} kwargs['search_value'] = keyword root = self.root_directory entries = root._load_entr...
[ "def", "search", "(", "self", ",", "keyword", ",", "count", "=", "30", ")", ":", "kwargs", "=", "{", "}", "kwargs", "[", "'search_value'", "]", "=", "keyword", "root", "=", "self", ".", "root_directory", "entries", "=", "root", ".", "_load_entries", "(...
Search files or directories :param str keyword: keyword :param int count: number of entries to be listed
[ "Search", "files", "or", "directories" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L509-L528
shichao-an/115wangpan
u115/api.py
API.move
def move(self, entries, directory): """ Move one or more entries (file or directory) to the destination directory :param list entries: a list of source entries (:class:`.BaseFile` object) :param directory: destination directory :return: whether the action is ...
python
def move(self, entries, directory): """ Move one or more entries (file or directory) to the destination directory :param list entries: a list of source entries (:class:`.BaseFile` object) :param directory: destination directory :return: whether the action is ...
[ "def", "move", "(", "self", ",", "entries", ",", "directory", ")", ":", "fcids", "=", "[", "]", "for", "entry", "in", "entries", ":", "if", "isinstance", "(", "entry", ",", "File", ")", ":", "fcid", "=", "entry", ".", "fid", "elif", "isinstance", "...
Move one or more entries (file or directory) to the destination directory :param list entries: a list of source entries (:class:`.BaseFile` object) :param directory: destination directory :return: whether the action is successful :raise: :class:`.APIError` if somethi...
[ "Move", "one", "or", "more", "entries", "(", "file", "or", "directory", ")", "to", "the", "destination", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L530-L559
shichao-an/115wangpan
u115/api.py
API.edit
def edit(self, entry, name, mark=False): """ Edit an entry (file or directory) :param entry: :class:`.BaseFile` object :param str name: new name for the entry :param bool mark: whether to bookmark the entry """ fcid = None if isinstance(entry, File): ...
python
def edit(self, entry, name, mark=False): """ Edit an entry (file or directory) :param entry: :class:`.BaseFile` object :param str name: new name for the entry :param bool mark: whether to bookmark the entry """ fcid = None if isinstance(entry, File): ...
[ "def", "edit", "(", "self", ",", "entry", ",", "name", ",", "mark", "=", "False", ")", ":", "fcid", "=", "None", "if", "isinstance", "(", "entry", ",", "File", ")", ":", "fcid", "=", "entry", ".", "fid", "elif", "isinstance", "(", "entry", ",", "...
Edit an entry (file or directory) :param entry: :class:`.BaseFile` object :param str name: new name for the entry :param bool mark: whether to bookmark the entry
[ "Edit", "an", "entry", "(", "file", "or", "directory", ")" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L561-L583
shichao-an/115wangpan
u115/api.py
API.mkdir
def mkdir(self, parent, name): """ Create a directory :param parent: the parent directory :param str name: the name of the new directory :return: the new directory :rtype: :class:`.Directory` """ pid = None cid = None if isinstance(parent...
python
def mkdir(self, parent, name): """ Create a directory :param parent: the parent directory :param str name: the name of the new directory :return: the new directory :rtype: :class:`.Directory` """ pid = None cid = None if isinstance(parent...
[ "def", "mkdir", "(", "self", ",", "parent", ",", "name", ")", ":", "pid", "=", "None", "cid", "=", "None", "if", "isinstance", "(", "parent", ",", "Directory", ")", ":", "pid", "=", "parent", ".", "cid", "else", ":", "raise", "(", "'Invalid Directory...
Create a directory :param parent: the parent directory :param str name: the name of the new directory :return: the new directory :rtype: :class:`.Directory`
[ "Create", "a", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L585-L602
shichao-an/115wangpan
u115/api.py
API._req_offline_space
def _req_offline_space(self): """Required before accessing lixian tasks""" url = 'http://115.com/' params = { 'ct': 'offline', 'ac': 'space', '_': get_timestamp(13) } _sign = os.environ.get('U115_BROWSER_SIGN') if _sign is not None: ...
python
def _req_offline_space(self): """Required before accessing lixian tasks""" url = 'http://115.com/' params = { 'ct': 'offline', 'ac': 'space', '_': get_timestamp(13) } _sign = os.environ.get('U115_BROWSER_SIGN') if _sign is not None: ...
[ "def", "_req_offline_space", "(", "self", ")", ":", "url", "=", "'http://115.com/'", "params", "=", "{", "'ct'", ":", "'offline'", ",", "'ac'", ":", "'space'", ",", "'_'", ":", "get_timestamp", "(", "13", ")", "}", "_sign", "=", "os", ".", "environ", "...
Required before accessing lixian tasks
[ "Required", "before", "accessing", "lixian", "tasks" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L604-L628
shichao-an/115wangpan
u115/api.py
API._req_lixian_task_lists
def _req_lixian_task_lists(self, page=1): """ This request will cause the system to create a default downloads directory if it does not exist """ url = 'http://115.com/lixian/' params = {'ct': 'lixian', 'ac': 'task_lists'} self._load_signatures() data = { ...
python
def _req_lixian_task_lists(self, page=1): """ This request will cause the system to create a default downloads directory if it does not exist """ url = 'http://115.com/lixian/' params = {'ct': 'lixian', 'ac': 'task_lists'} self._load_signatures() data = { ...
[ "def", "_req_lixian_task_lists", "(", "self", ",", "page", "=", "1", ")", ":", "url", "=", "'http://115.com/lixian/'", "params", "=", "{", "'ct'", ":", "'lixian'", ",", "'ac'", ":", "'task_lists'", "}", "self", ".", "_load_signatures", "(", ")", "data", "=...
This request will cause the system to create a default downloads directory if it does not exist
[ "This", "request", "will", "cause", "the", "system", "to", "create", "a", "default", "downloads", "directory", "if", "it", "does", "not", "exist" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L630-L652
shichao-an/115wangpan
u115/api.py
API._req_lixian_get_id
def _req_lixian_get_id(self, torrent=False): """Get `cid` of lixian space directory""" url = 'http://115.com/' params = { 'ct': 'lixian', 'ac': 'get_id', 'torrent': 1 if torrent else None, '_': get_timestamp(13) } req = Request(meth...
python
def _req_lixian_get_id(self, torrent=False): """Get `cid` of lixian space directory""" url = 'http://115.com/' params = { 'ct': 'lixian', 'ac': 'get_id', 'torrent': 1 if torrent else None, '_': get_timestamp(13) } req = Request(meth...
[ "def", "_req_lixian_get_id", "(", "self", ",", "torrent", "=", "False", ")", ":", "url", "=", "'http://115.com/'", "params", "=", "{", "'ct'", ":", "'lixian'", ",", "'ac'", ":", "'get_id'", ",", "'torrent'", ":", "1", "if", "torrent", "else", "None", ","...
Get `cid` of lixian space directory
[ "Get", "cid", "of", "lixian", "space", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L654-L665
shichao-an/115wangpan
u115/api.py
API._req_lixian_torrent
def _req_lixian_torrent(self, u): """ :param u: uploaded torrent file """ self._load_signatures() url = 'http://115.com/lixian/' params = { 'ct': 'lixian', 'ac': 'torrent', } data = { 'pickcode': u.pickcode, ...
python
def _req_lixian_torrent(self, u): """ :param u: uploaded torrent file """ self._load_signatures() url = 'http://115.com/lixian/' params = { 'ct': 'lixian', 'ac': 'torrent', } data = { 'pickcode': u.pickcode, ...
[ "def", "_req_lixian_torrent", "(", "self", ",", "u", ")", ":", "self", ".", "_load_signatures", "(", ")", "url", "=", "'http://115.com/lixian/'", "params", "=", "{", "'ct'", ":", "'lixian'", ",", "'ac'", ":", "'torrent'", ",", "}", "data", "=", "{", "'pi...
:param u: uploaded torrent file
[ ":", "param", "u", ":", "uploaded", "torrent", "file" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L667-L692
shichao-an/115wangpan
u115/api.py
API._req_aps_natsort_files
def _req_aps_natsort_files(self, cid, offset, limit, o='file_name', asc=1, aid=1, show_dir=1, code=None, scid=None, snap=0, natsort=1, source=None, type=0, format='json', star=None, is_share=None): """ When :met...
python
def _req_aps_natsort_files(self, cid, offset, limit, o='file_name', asc=1, aid=1, show_dir=1, code=None, scid=None, snap=0, natsort=1, source=None, type=0, format='json', star=None, is_share=None): """ When :met...
[ "def", "_req_aps_natsort_files", "(", "self", ",", "cid", ",", "offset", ",", "limit", ",", "o", "=", "'file_name'", ",", "asc", "=", "1", ",", "aid", "=", "1", ",", "show_dir", "=", "1", ",", "code", "=", "None", ",", "scid", "=", "None", ",", "...
When :meth:`.API._req_files` is called with `o='filename'` and `natsort=1`, API access will fail and :meth:`.API._req_aps_natsort_files` is subsequently called with the same kwargs. Refer to the implementation in :meth:`.Directory.list`
[ "When", ":", "meth", ":", ".", "API", ".", "_req_files", "is", "called", "with", "o", "=", "filename", "and", "natsort", "=", "1", "API", "access", "will", "fail", "and", ":", "meth", ":", ".", "API", ".", "_req_aps_natsort_files", "is", "subsequently", ...
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L770-L788
shichao-an/115wangpan
u115/api.py
API._req_files_edit
def _req_files_edit(self, fid, file_name=None, is_mark=0): """Edit a file or directory""" url = self.web_api_url + '/edit' data = locals() del data['self'] req = Request(method='POST', url=url, data=data) res = self.http.send(req) if res.state: return ...
python
def _req_files_edit(self, fid, file_name=None, is_mark=0): """Edit a file or directory""" url = self.web_api_url + '/edit' data = locals() del data['self'] req = Request(method='POST', url=url, data=data) res = self.http.send(req) if res.state: return ...
[ "def", "_req_files_edit", "(", "self", ",", "fid", ",", "file_name", "=", "None", ",", "is_mark", "=", "0", ")", ":", "url", "=", "self", ".", "web_api_url", "+", "'/edit'", "data", "=", "locals", "(", ")", "del", "data", "[", "'self'", "]", "req", ...
Edit a file or directory
[ "Edit", "a", "file", "or", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L830-L840
shichao-an/115wangpan
u115/api.py
API._req_files_add
def _req_files_add(self, pid, cname): """ Add a directory :param str pid: parent directory id :param str cname: directory name """ url = self.web_api_url + '/add' data = locals() del data['self'] req = Request(method='POST', url=url, data=data) ...
python
def _req_files_add(self, pid, cname): """ Add a directory :param str pid: parent directory id :param str cname: directory name """ url = self.web_api_url + '/add' data = locals() del data['self'] req = Request(method='POST', url=url, data=data) ...
[ "def", "_req_files_add", "(", "self", ",", "pid", ",", "cname", ")", ":", "url", "=", "self", ".", "web_api_url", "+", "'/add'", "data", "=", "locals", "(", ")", "del", "data", "[", "'self'", "]", "req", "=", "Request", "(", "method", "=", "'POST'", ...
Add a directory :param str pid: parent directory id :param str cname: directory name
[ "Add", "a", "directory", ":", "param", "str", "pid", ":", "parent", "directory", "id", ":", "param", "str", "cname", ":", "directory", "name" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L842-L856
shichao-an/115wangpan
u115/api.py
API._req_files_move
def _req_files_move(self, pid, fids): """ Move files or directories :param str pid: destination directory id :param list fids: a list of ids of files or directories to be moved """ url = self.web_api_url + '/move' data = {} data['pid'] = pid for i,...
python
def _req_files_move(self, pid, fids): """ Move files or directories :param str pid: destination directory id :param list fids: a list of ids of files or directories to be moved """ url = self.web_api_url + '/move' data = {} data['pid'] = pid for i,...
[ "def", "_req_files_move", "(", "self", ",", "pid", ",", "fids", ")", ":", "url", "=", "self", ".", "web_api_url", "+", "'/move'", "data", "=", "{", "}", "data", "[", "'pid'", "]", "=", "pid", "for", "i", ",", "fid", "in", "enumerate", "(", "fids", ...
Move files or directories :param str pid: destination directory id :param list fids: a list of ids of files or directories to be moved
[ "Move", "files", "or", "directories", ":", "param", "str", "pid", ":", "destination", "directory", "id", ":", "param", "list", "fids", ":", "a", "list", "of", "ids", "of", "files", "or", "directories", "to", "be", "moved" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L858-L874
shichao-an/115wangpan
u115/api.py
API._req_directory
def _req_directory(self, cid): """Return name and pid of by cid""" res = self._req_files(cid=cid, offset=0, limit=1, show_dir=1) path = res['path'] count = res['count'] for d in path: if str(d['cid']) == str(cid): res = { 'cid': d['...
python
def _req_directory(self, cid): """Return name and pid of by cid""" res = self._req_files(cid=cid, offset=0, limit=1, show_dir=1) path = res['path'] count = res['count'] for d in path: if str(d['cid']) == str(cid): res = { 'cid': d['...
[ "def", "_req_directory", "(", "self", ",", "cid", ")", ":", "res", "=", "self", ".", "_req_files", "(", "cid", "=", "cid", ",", "offset", "=", "0", ",", "limit", "=", "1", ",", "show_dir", "=", "1", ")", "path", "=", "res", "[", "'path'", "]", ...
Return name and pid of by cid
[ "Return", "name", "and", "pid", "of", "by", "cid" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L886-L901
shichao-an/115wangpan
u115/api.py
API._req_upload
def _req_upload(self, filename, directory): """Raw request to upload a file ``filename``""" self._upload_url = self._load_upload_url() self.http.get('http://upload.115.com/crossdomain.xml') b = os.path.basename(filename) target = 'U_1_' + str(directory.cid) files = { ...
python
def _req_upload(self, filename, directory): """Raw request to upload a file ``filename``""" self._upload_url = self._load_upload_url() self.http.get('http://upload.115.com/crossdomain.xml') b = os.path.basename(filename) target = 'U_1_' + str(directory.cid) files = { ...
[ "def", "_req_upload", "(", "self", ",", "filename", ",", "directory", ")", ":", "self", ".", "_upload_url", "=", "self", ".", "_load_upload_url", "(", ")", "self", ".", "http", ".", "get", "(", "'http://upload.115.com/crossdomain.xml'", ")", "b", "=", "os", ...
Raw request to upload a file ``filename``
[ "Raw", "request", "to", "upload", "a", "file", "filename" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L938-L960
shichao-an/115wangpan
u115/api.py
API._load_root_directory
def _load_root_directory(self): """ Load root directory, which has a cid of 0 """ kwargs = self._req_directory(0) self._root_directory = Directory(api=self, **kwargs)
python
def _load_root_directory(self): """ Load root directory, which has a cid of 0 """ kwargs = self._req_directory(0) self._root_directory = Directory(api=self, **kwargs)
[ "def", "_load_root_directory", "(", "self", ")", ":", "kwargs", "=", "self", ".", "_req_directory", "(", "0", ")", "self", ".", "_root_directory", "=", "Directory", "(", "api", "=", "self", ",", "*", "*", "kwargs", ")" ]
Load root directory, which has a cid of 0
[ "Load", "root", "directory", "which", "has", "a", "cid", "of", "0" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1016-L1021
shichao-an/115wangpan
u115/api.py
API._load_torrents_directory
def _load_torrents_directory(self): """ Load torrents directory If it does not exist yet, this request will cause the system to create one """ r = self._req_lixian_get_id(torrent=True) self._downloads_directory = self._load_directory(r['cid'])
python
def _load_torrents_directory(self): """ Load torrents directory If it does not exist yet, this request will cause the system to create one """ r = self._req_lixian_get_id(torrent=True) self._downloads_directory = self._load_directory(r['cid'])
[ "def", "_load_torrents_directory", "(", "self", ")", ":", "r", "=", "self", ".", "_req_lixian_get_id", "(", "torrent", "=", "True", ")", "self", ".", "_downloads_directory", "=", "self", ".", "_load_directory", "(", "r", "[", "'cid'", "]", ")" ]
Load torrents directory If it does not exist yet, this request will cause the system to create one
[ "Load", "torrents", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1023-L1031
shichao-an/115wangpan
u115/api.py
API._load_downloads_directory
def _load_downloads_directory(self): """ Load downloads directory If it does not exist yet, this request will cause the system to create one """ r = self._req_lixian_get_id(torrent=False) self._downloads_directory = self._load_directory(r['cid'])
python
def _load_downloads_directory(self): """ Load downloads directory If it does not exist yet, this request will cause the system to create one """ r = self._req_lixian_get_id(torrent=False) self._downloads_directory = self._load_directory(r['cid'])
[ "def", "_load_downloads_directory", "(", "self", ")", ":", "r", "=", "self", ".", "_req_lixian_get_id", "(", "torrent", "=", "False", ")", "self", ".", "_downloads_directory", "=", "self", ".", "_load_directory", "(", "r", "[", "'cid'", "]", ")" ]
Load downloads directory If it does not exist yet, this request will cause the system to create one
[ "Load", "downloads", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1033-L1041
shichao-an/115wangpan
u115/api.py
API._parse_src_js_var
def _parse_src_js_var(self, variable): """Parse JavaScript variables in the source page""" src_url = 'http://115.com' r = self.http.get(src_url) soup = BeautifulSoup(r.content) scripts = [script.text for script in soup.find_all('script')] text = '\n'.join(scripts) ...
python
def _parse_src_js_var(self, variable): """Parse JavaScript variables in the source page""" src_url = 'http://115.com' r = self.http.get(src_url) soup = BeautifulSoup(r.content) scripts = [script.text for script in soup.find_all('script')] text = '\n'.join(scripts) ...
[ "def", "_parse_src_js_var", "(", "self", ",", "variable", ")", ":", "src_url", "=", "'http://115.com'", "r", "=", "self", ".", "http", ".", "get", "(", "src_url", ")", "soup", "=", "BeautifulSoup", "(", "r", ".", "content", ")", "scripts", "=", "[", "s...
Parse JavaScript variables in the source page
[ "Parse", "JavaScript", "variables", "in", "the", "source", "page" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1051-L1064
shichao-an/115wangpan
u115/api.py
BaseFile.delete
def delete(self): """ Delete this file or directory :return: whether deletion is successful :raise: :class:`.APIError` if this file or directory is already deleted """ fcid = None pid = None if isinstance(self, File): fcid = self.fid ...
python
def delete(self): """ Delete this file or directory :return: whether deletion is successful :raise: :class:`.APIError` if this file or directory is already deleted """ fcid = None pid = None if isinstance(self, File): fcid = self.fid ...
[ "def", "delete", "(", "self", ")", ":", "fcid", "=", "None", "pid", "=", "None", "if", "isinstance", "(", "self", ",", "File", ")", ":", "fcid", "=", "self", ".", "fid", "pid", "=", "self", ".", "cid", "elif", "isinstance", "(", "self", ",", "Dir...
Delete this file or directory :return: whether deletion is successful :raise: :class:`.APIError` if this file or directory is already deleted
[ "Delete", "this", "file", "or", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1158-L1183
shichao-an/115wangpan
u115/api.py
BaseFile.edit
def edit(self, name, mark=False): """ Edit this file or directory :param str name: new name for this entry :param bool mark: whether to bookmark this entry """ self.api.edit(self, name, mark)
python
def edit(self, name, mark=False): """ Edit this file or directory :param str name: new name for this entry :param bool mark: whether to bookmark this entry """ self.api.edit(self, name, mark)
[ "def", "edit", "(", "self", ",", "name", ",", "mark", "=", "False", ")", ":", "self", ".", "api", ".", "edit", "(", "self", ",", "name", ",", "mark", ")" ]
Edit this file or directory :param str name: new name for this entry :param bool mark: whether to bookmark this entry
[ "Edit", "this", "file", "or", "directory" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1195-L1202
shichao-an/115wangpan
u115/api.py
File.directory
def directory(self): """Directory that holds this file""" if self._directory is None: self._directory = self.api._load_directory(self.cid) return self._directory
python
def directory(self): """Directory that holds this file""" if self._directory is None: self._directory = self.api._load_directory(self.cid) return self._directory
[ "def", "directory", "(", "self", ")", ":", "if", "self", ".", "_directory", "is", "None", ":", "self", ".", "_directory", "=", "self", ".", "api", ".", "_load_directory", "(", "self", ".", "cid", ")", "return", "self", ".", "_directory" ]
Directory that holds this file
[ "Directory", "that", "holds", "this", "file" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1258-L1262
shichao-an/115wangpan
u115/api.py
File.get_download_url
def get_download_url(self, proapi=False): """ Get this file's download URL :param bool proapi: whether to use pro API """ if self._download_url is None: self._download_url = \ self.api._req_files_download_url(self.pickcode, proapi) return sel...
python
def get_download_url(self, proapi=False): """ Get this file's download URL :param bool proapi: whether to use pro API """ if self._download_url is None: self._download_url = \ self.api._req_files_download_url(self.pickcode, proapi) return sel...
[ "def", "get_download_url", "(", "self", ",", "proapi", "=", "False", ")", ":", "if", "self", ".", "_download_url", "is", "None", ":", "self", ".", "_download_url", "=", "self", ".", "api", ".", "_req_files_download_url", "(", "self", ".", "pickcode", ",", ...
Get this file's download URL :param bool proapi: whether to use pro API
[ "Get", "this", "file", "s", "download", "URL" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1264-L1274
shichao-an/115wangpan
u115/api.py
File.download
def download(self, path=None, show_progress=True, resume=True, auto_retry=True, proapi=False): """Download this file""" self.api.download(self, path, show_progress, resume, auto_retry, proapi)
python
def download(self, path=None, show_progress=True, resume=True, auto_retry=True, proapi=False): """Download this file""" self.api.download(self, path, show_progress, resume, auto_retry, proapi)
[ "def", "download", "(", "self", ",", "path", "=", "None", ",", "show_progress", "=", "True", ",", "resume", "=", "True", ",", "auto_retry", "=", "True", ",", "proapi", "=", "False", ")", ":", "self", ".", "api", ".", "download", "(", "self", ",", "...
Download this file
[ "Download", "this", "file" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1281-L1285
shichao-an/115wangpan
u115/api.py
File.reload
def reload(self): """ Reload file info and metadata * name * sha * pickcode """ res = self.api._req_file(self.fid) data = res['data'][0] self.name = data['file_name'] self.sha = data['sha1'] self.pickcode = data['pick_code']
python
def reload(self): """ Reload file info and metadata * name * sha * pickcode """ res = self.api._req_file(self.fid) data = res['data'][0] self.name = data['file_name'] self.sha = data['sha1'] self.pickcode = data['pick_code']
[ "def", "reload", "(", "self", ")", ":", "res", "=", "self", ".", "api", ".", "_req_file", "(", "self", ".", "fid", ")", "data", "=", "res", "[", "'data'", "]", "[", "0", "]", "self", ".", "name", "=", "data", "[", "'file_name'", "]", "self", "....
Reload file info and metadata * name * sha * pickcode
[ "Reload", "file", "info", "and", "metadata" ]
train
https://github.com/shichao-an/115wangpan/blob/e7cc935313f675e886bceca831fcffcdedf1e880/u115/api.py#L1302-L1315