repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
fedora-infra/datanommer | datanommer.models/alembic/versions/1d4feffd78fe_add_historic_user_an.py | _page | def _page(q, chunk=1000):
""" Quick utility to page a query, 1000 items at a time.
We need this so we don't OOM (out of memory) ourselves loading the world.
"""
offset = 0
while True:
r = False
for elem in q.limit(chunk).offset(offset):
r = True
yield elem
... | python | def _page(q, chunk=1000):
""" Quick utility to page a query, 1000 items at a time.
We need this so we don't OOM (out of memory) ourselves loading the world.
"""
offset = 0
while True:
r = False
for elem in q.limit(chunk).offset(offset):
r = True
yield elem
... | [
"def",
"_page",
"(",
"q",
",",
"chunk",
"=",
"1000",
")",
":",
"offset",
"=",
"0",
"while",
"True",
":",
"r",
"=",
"False",
"for",
"elem",
"in",
"q",
".",
"limit",
"(",
"chunk",
")",
".",
"offset",
"(",
"offset",
")",
":",
"r",
"=",
"True",
"... | Quick utility to page a query, 1000 items at a time.
We need this so we don't OOM (out of memory) ourselves loading the world. | [
"Quick",
"utility",
"to",
"page",
"a",
"query",
"1000",
"items",
"at",
"a",
"time",
".",
"We",
"need",
"this",
"so",
"we",
"don",
"t",
"OOM",
"(",
"out",
"of",
"memory",
")",
"ourselves",
"loading",
"the",
"world",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/datanommer.models/alembic/versions/1d4feffd78fe_add_historic_user_an.py#L48-L61 |
fedora-infra/datanommer | datanommer.models/alembic/versions/1d4feffd78fe_add_historic_user_an.py | upgrade | def upgrade():
""" This takes a *really* long time. Like, hours. """
config_paths = context.config.get_main_option('fedmsg_config_dir')
filenames = fedmsg.config._gather_configs_in(config_paths)
config = fedmsg.config.load_config(filenames=filenames)
make_processors(**config)
engine = op.ge... | python | def upgrade():
""" This takes a *really* long time. Like, hours. """
config_paths = context.config.get_main_option('fedmsg_config_dir')
filenames = fedmsg.config._gather_configs_in(config_paths)
config = fedmsg.config.load_config(filenames=filenames)
make_processors(**config)
engine = op.ge... | [
"def",
"upgrade",
"(",
")",
":",
"config_paths",
"=",
"context",
".",
"config",
".",
"get_main_option",
"(",
"'fedmsg_config_dir'",
")",
"filenames",
"=",
"fedmsg",
".",
"config",
".",
"_gather_configs_in",
"(",
"config_paths",
")",
"config",
"=",
"fedmsg",
".... | This takes a *really* long time. Like, hours. | [
"This",
"takes",
"a",
"*",
"really",
"*",
"long",
"time",
".",
"Like",
"hours",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/datanommer.models/alembic/versions/1d4feffd78fe_add_historic_user_an.py#L64-L107 |
fedora-infra/datanommer | tools/gource/datanommer2gitlog.py | run | def run(cmd):
""" Execute a shell command.
Both envoy and python-sh failed me...
commands, although deprecated, feels like the easiest tool to use.
"""
status, output = commands.getstatusoutput(cmd)
if status:
print(output)
return status == 0 | python | def run(cmd):
""" Execute a shell command.
Both envoy and python-sh failed me...
commands, although deprecated, feels like the easiest tool to use.
"""
status, output = commands.getstatusoutput(cmd)
if status:
print(output)
return status == 0 | [
"def",
"run",
"(",
"cmd",
")",
":",
"status",
",",
"output",
"=",
"commands",
".",
"getstatusoutput",
"(",
"cmd",
")",
"if",
"status",
":",
"print",
"(",
"output",
")",
"return",
"status",
"==",
"0"
] | Execute a shell command.
Both envoy and python-sh failed me...
commands, although deprecated, feels like the easiest tool to use. | [
"Execute",
"a",
"shell",
"command",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/tools/gource/datanommer2gitlog.py#L43-L53 |
fedora-infra/datanommer | tools/gource/datanommer2gitlog.py | read_datanommer_entries_from_filedump | def read_datanommer_entries_from_filedump():
""" Read in all datanommer entries from a file created with:
$ datanommer-dump > myfile.json
"""
# TODO -- un-hardcode this filename when I need to run this next time.
#filename = "../myfile.json"
filename = "../datanommer-dump-2012-11-22.json"
... | python | def read_datanommer_entries_from_filedump():
""" Read in all datanommer entries from a file created with:
$ datanommer-dump > myfile.json
"""
# TODO -- un-hardcode this filename when I need to run this next time.
#filename = "../myfile.json"
filename = "../datanommer-dump-2012-11-22.json"
... | [
"def",
"read_datanommer_entries_from_filedump",
"(",
")",
":",
"# TODO -- un-hardcode this filename when I need to run this next time.",
"#filename = \"../myfile.json\"",
"filename",
"=",
"\"../datanommer-dump-2012-11-22.json\"",
"print",
"(",
"\"Reading %s\"",
"%",
"filename",
")",
... | Read in all datanommer entries from a file created with:
$ datanommer-dump > myfile.json | [
"Read",
"in",
"all",
"datanommer",
"entries",
"from",
"a",
"file",
"created",
"with",
":"
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/tools/gource/datanommer2gitlog.py#L56-L90 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/factories/factory_interface.py | FactoryInterface.create_or_update | def create_or_update(self,
identifier: Identifier,
data: Dict[str, Any],
) -> Tuple[object, bool]:
"""
Create or update a model.
:param identifier: An object with :attr:`class_name` and :attr:`key`
... | python | def create_or_update(self,
identifier: Identifier,
data: Dict[str, Any],
) -> Tuple[object, bool]:
"""
Create or update a model.
:param identifier: An object with :attr:`class_name` and :attr:`key`
... | [
"def",
"create_or_update",
"(",
"self",
",",
"identifier",
":",
"Identifier",
",",
"data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
")",
"->",
"Tuple",
"[",
"object",
",",
"bool",
"]",
":",
"raise",
"NotImplementedError"
] | Create or update a model.
:param identifier: An object with :attr:`class_name` and :attr:`key`
attributes
:param data: A dictionary keyed by column name, with values being the
converted values to set on the model instance
:return: A two-tuple of m... | [
"Create",
"or",
"update",
"a",
"model",
"."
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/factories/factory_interface.py#L15-L28 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/factories/factory_interface.py | FactoryInterface.maybe_convert_values | def maybe_convert_values(self,
identifier: Identifier,
data: Dict[str, Any],
) -> Dict[str, Any]:
"""
Takes a dictionary of raw values for a specific identifier, as parsed
from the YAML file, and depending upo... | python | def maybe_convert_values(self,
identifier: Identifier,
data: Dict[str, Any],
) -> Dict[str, Any]:
"""
Takes a dictionary of raw values for a specific identifier, as parsed
from the YAML file, and depending upo... | [
"def",
"maybe_convert_values",
"(",
"self",
",",
"identifier",
":",
"Identifier",
",",
"data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"raise",
"NotImplementedError"
] | Takes a dictionary of raw values for a specific identifier, as parsed
from the YAML file, and depending upon the type of db column the data
is meant for, decides what to do with the value (eg leave it alone,
convert a string to a date/time instance, or convert identifiers to
model instan... | [
"Takes",
"a",
"dictionary",
"of",
"raw",
"values",
"for",
"a",
"specific",
"identifier",
"as",
"parsed",
"from",
"the",
"YAML",
"file",
"and",
"depending",
"upon",
"the",
"type",
"of",
"db",
"column",
"the",
"data",
"is",
"meant",
"for",
"decides",
"what",... | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/factories/factory_interface.py#L40-L58 |
Accelize/pycosio | pycosio/storage/azure_file.py | _AzureFileSystem.copy | def copy(self, src, dst, other_system=None):
"""
Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio.storage.azure._AzureBaseSystem subclass):
The source storage system.
"""
... | python | def copy(self, src, dst, other_system=None):
"""
Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio.storage.azure._AzureBaseSystem subclass):
The source storage system.
"""
... | [
"def",
"copy",
"(",
"self",
",",
"src",
",",
"dst",
",",
"other_system",
"=",
"None",
")",
":",
"with",
"_handle_azure_exception",
"(",
")",
":",
"self",
".",
"client",
".",
"copy_file",
"(",
"copy_source",
"=",
"(",
"other_system",
"or",
"self",
")",
... | Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio.storage.azure._AzureBaseSystem subclass):
The source storage system. | [
"Copy",
"object",
"of",
"the",
"same",
"storage",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L30-L43 |
Accelize/pycosio | pycosio/storage/azure_file.py | _AzureFileSystem.get_client_kwargs | def get_client_kwargs(self, path):
"""
Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args
"""
# Remove query string from URL
path = path.split('?', 1)[0]
... | python | def get_client_kwargs(self, path):
"""
Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args
"""
# Remove query string from URL
path = path.split('?', 1)[0]
... | [
"def",
"get_client_kwargs",
"(",
"self",
",",
"path",
")",
":",
"# Remove query string from URL",
"path",
"=",
"path",
".",
"split",
"(",
"'?'",
",",
"1",
")",
"[",
"0",
"]",
"share_name",
",",
"relpath",
"=",
"self",
".",
"split_locator",
"(",
"path",
"... | Get base keyword arguments for client for a
specific path.
Args:
path (str): Absolute path or URL.
Returns:
dict: client args | [
"Get",
"base",
"keyword",
"arguments",
"for",
"client",
"for",
"a",
"specific",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L56-L87 |
Accelize/pycosio | pycosio/storage/azure_file.py | _AzureFileSystem._head | def _head(self, client_kwargs):
"""
Returns object or bucket HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
with _handle_azure_exception():
# File
if 'file_name' in client_kwargs... | python | def _head(self, client_kwargs):
"""
Returns object or bucket HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
with _handle_azure_exception():
# File
if 'file_name' in client_kwargs... | [
"def",
"_head",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_azure_exception",
"(",
")",
":",
"# File",
"if",
"'file_name'",
"in",
"client_kwargs",
":",
"result",
"=",
"self",
".",
"client",
".",
"get_file_properties",
"(",
"*",
"*",
"client... | Returns object or bucket HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header. | [
"Returns",
"object",
"or",
"bucket",
"HTTP",
"header",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L112-L135 |
Accelize/pycosio | pycosio/storage/azure_file.py | _AzureFileSystem._list_locators | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_azure_exception():
for share in self.client.list_shares():
yield share.name, self._model_to_dict(share) | python | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_azure_exception():
for share in self.client.list_shares():
yield share.name, self._model_to_dict(share) | [
"def",
"_list_locators",
"(",
"self",
")",
":",
"with",
"_handle_azure_exception",
"(",
")",
":",
"for",
"share",
"in",
"self",
".",
"client",
".",
"list_shares",
"(",
")",
":",
"yield",
"share",
".",
"name",
",",
"self",
".",
"_model_to_dict",
"(",
"sha... | Lists locators.
Returns:
generator of tuple: locator name str, locator header dict | [
"Lists",
"locators",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L137-L146 |
Accelize/pycosio | pycosio/storage/azure_file.py | _AzureFileSystem._list_objects | def _list_objects(self, client_kwargs, max_request_entries):
"""
Lists objects.
args:
client_kwargs (dict): Client arguments.
max_request_entries (int): If specified, maximum entries returned
by request.
Returns:
generator of tuple: o... | python | def _list_objects(self, client_kwargs, max_request_entries):
"""
Lists objects.
args:
client_kwargs (dict): Client arguments.
max_request_entries (int): If specified, maximum entries returned
by request.
Returns:
generator of tuple: o... | [
"def",
"_list_objects",
"(",
"self",
",",
"client_kwargs",
",",
"max_request_entries",
")",
":",
"client_kwargs",
"=",
"self",
".",
"_update_listing_client_kwargs",
"(",
"client_kwargs",
",",
"max_request_entries",
")",
"with",
"_handle_azure_exception",
"(",
")",
":"... | Lists objects.
args:
client_kwargs (dict): Client arguments.
max_request_entries (int): If specified, maximum entries returned
by request.
Returns:
generator of tuple: object name str, object header dict,
directory bool | [
"Lists",
"objects",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L148-L167 |
Accelize/pycosio | pycosio/storage/azure_file.py | _AzureFileSystem._make_dir | def _make_dir(self, client_kwargs):
"""
Make a directory.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_azure_exception():
# Directory
if 'directory_name' in client_kwargs:
return self.client.create_directory(
... | python | def _make_dir(self, client_kwargs):
"""
Make a directory.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_azure_exception():
# Directory
if 'directory_name' in client_kwargs:
return self.client.create_directory(
... | [
"def",
"_make_dir",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_azure_exception",
"(",
")",
":",
"# Directory",
"if",
"'directory_name'",
"in",
"client_kwargs",
":",
"return",
"self",
".",
"client",
".",
"create_directory",
"(",
"share_name",
"... | Make a directory.
args:
client_kwargs (dict): Client arguments. | [
"Make",
"a",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L169-L184 |
Accelize/pycosio | pycosio/storage/azure_file.py | _AzureFileSystem._remove | def _remove(self, client_kwargs):
"""
Remove an object.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_azure_exception():
# File
if 'file_name' in client_kwargs:
return self.client.delete_file(
... | python | def _remove(self, client_kwargs):
"""
Remove an object.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_azure_exception():
# File
if 'file_name' in client_kwargs:
return self.client.delete_file(
... | [
"def",
"_remove",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_azure_exception",
"(",
")",
":",
"# File",
"if",
"'file_name'",
"in",
"client_kwargs",
":",
"return",
"self",
".",
"client",
".",
"delete_file",
"(",
"share_name",
"=",
"client_kwa... | Remove an object.
args:
client_kwargs (dict): Client arguments. | [
"Remove",
"an",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L186-L209 |
Accelize/pycosio | pycosio/storage/azure_file.py | AzureFileRawIO._update_range | def _update_range(self, data, **kwargs):
"""
Update range with data
Args:
data (bytes): data.
"""
self._client.update_range(data=data, **kwargs) | python | def _update_range(self, data, **kwargs):
"""
Update range with data
Args:
data (bytes): data.
"""
self._client.update_range(data=data, **kwargs) | [
"def",
"_update_range",
"(",
"self",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_client",
".",
"update_range",
"(",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | Update range with data
Args:
data (bytes): data. | [
"Update",
"range",
"with",
"data"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L267-L274 |
fedora-infra/datanommer | tools/active-contrib.py | handle_bodhi | def handle_bodhi(msg):
""" Given a bodhi message, return the FAS username. """
if 'bodhi.update.comment' in msg.topic:
username = msg.msg['comment']['author']
elif 'bodhi.buildroot_override' in msg.topic:
username = msg.msg['override']['submitter']
else:
username = msg.msg.get('... | python | def handle_bodhi(msg):
""" Given a bodhi message, return the FAS username. """
if 'bodhi.update.comment' in msg.topic:
username = msg.msg['comment']['author']
elif 'bodhi.buildroot_override' in msg.topic:
username = msg.msg['override']['submitter']
else:
username = msg.msg.get('... | [
"def",
"handle_bodhi",
"(",
"msg",
")",
":",
"if",
"'bodhi.update.comment'",
"in",
"msg",
".",
"topic",
":",
"username",
"=",
"msg",
".",
"msg",
"[",
"'comment'",
"]",
"[",
"'author'",
"]",
"elif",
"'bodhi.buildroot_override'",
"in",
"msg",
".",
"topic",
"... | Given a bodhi message, return the FAS username. | [
"Given",
"a",
"bodhi",
"message",
"return",
"the",
"FAS",
"username",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/tools/active-contrib.py#L64-L73 |
fedora-infra/datanommer | tools/active-contrib.py | handle_wiki | def handle_wiki(msg):
""" Given a wiki message, return the FAS username. """
if 'wiki.article.edit' in msg.topic:
username = msg.msg['user']
elif 'wiki.upload.complete' in msg.topic:
username = msg.msg['user_text']
else:
raise ValueError("Unhandled topic.")
return username | python | def handle_wiki(msg):
""" Given a wiki message, return the FAS username. """
if 'wiki.article.edit' in msg.topic:
username = msg.msg['user']
elif 'wiki.upload.complete' in msg.topic:
username = msg.msg['user_text']
else:
raise ValueError("Unhandled topic.")
return username | [
"def",
"handle_wiki",
"(",
"msg",
")",
":",
"if",
"'wiki.article.edit'",
"in",
"msg",
".",
"topic",
":",
"username",
"=",
"msg",
".",
"msg",
"[",
"'user'",
"]",
"elif",
"'wiki.upload.complete'",
"in",
"msg",
".",
"topic",
":",
"username",
"=",
"msg",
"."... | Given a wiki message, return the FAS username. | [
"Given",
"a",
"wiki",
"message",
"return",
"the",
"FAS",
"username",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/tools/active-contrib.py#L76-L86 |
Accelize/pycosio | pycosio/_core/functions_core.py | is_storage | def is_storage(url, storage=None):
"""
Check if file is a local file or a storage file.
File is considered local if:
- URL is a local path.
- URL starts by "file://"
- a "storage" is provided.
Args:
url (str): file path or URL
storage (str): Storage name.
R... | python | def is_storage(url, storage=None):
"""
Check if file is a local file or a storage file.
File is considered local if:
- URL is a local path.
- URL starts by "file://"
- a "storage" is provided.
Args:
url (str): file path or URL
storage (str): Storage name.
R... | [
"def",
"is_storage",
"(",
"url",
",",
"storage",
"=",
"None",
")",
":",
"if",
"storage",
":",
"return",
"True",
"split_url",
"=",
"url",
".",
"split",
"(",
"'://'",
",",
"1",
")",
"if",
"len",
"(",
"split_url",
")",
"==",
"2",
"and",
"split_url",
"... | Check if file is a local file or a storage file.
File is considered local if:
- URL is a local path.
- URL starts by "file://"
- a "storage" is provided.
Args:
url (str): file path or URL
storage (str): Storage name.
Returns:
bool: return True if file is lo... | [
"Check",
"if",
"file",
"is",
"a",
"local",
"file",
"or",
"a",
"storage",
"file",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_core.py#L10-L31 |
Accelize/pycosio | pycosio/_core/functions_core.py | format_and_is_storage | def format_and_is_storage(path):
"""
Checks if path is storage and format it.
If path is an opened file-like object, returns is storage as True.
Args:
path (path-like object or file-like object):
Returns:
tuple: str or file-like object (Updated path),
bool (True if is ... | python | def format_and_is_storage(path):
"""
Checks if path is storage and format it.
If path is an opened file-like object, returns is storage as True.
Args:
path (path-like object or file-like object):
Returns:
tuple: str or file-like object (Updated path),
bool (True if is ... | [
"def",
"format_and_is_storage",
"(",
"path",
")",
":",
"if",
"not",
"hasattr",
"(",
"path",
",",
"'read'",
")",
":",
"path",
"=",
"fsdecode",
"(",
"path",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"return",
"path",
",",
"is_storage",
"(",
... | Checks if path is storage and format it.
If path is an opened file-like object, returns is storage as True.
Args:
path (path-like object or file-like object):
Returns:
tuple: str or file-like object (Updated path),
bool (True if is storage). | [
"Checks",
"if",
"path",
"is",
"storage",
"and",
"format",
"it",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_core.py#L34-L50 |
Accelize/pycosio | pycosio/_core/functions_core.py | equivalent_to | def equivalent_to(std_function):
"""
Decorates a cloud object compatible function
to provides fall back to standard function if
used on local files.
Args:
std_function (function): standard function to
used with local files.
Returns:
function: new function
"""
... | python | def equivalent_to(std_function):
"""
Decorates a cloud object compatible function
to provides fall back to standard function if
used on local files.
Args:
std_function (function): standard function to
used with local files.
Returns:
function: new function
"""
... | [
"def",
"equivalent_to",
"(",
"std_function",
")",
":",
"def",
"decorate",
"(",
"cos_function",
")",
":",
"\"\"\"Decorator argument handler\"\"\"",
"@",
"wraps",
"(",
"cos_function",
")",
"def",
"decorated",
"(",
"path",
",",
"*",
"args",
",",
"*",
"*",
"kwargs... | Decorates a cloud object compatible function
to provides fall back to standard function if
used on local files.
Args:
std_function (function): standard function to
used with local files.
Returns:
function: new function | [
"Decorates",
"a",
"cloud",
"object",
"compatible",
"function",
"to",
"provides",
"fall",
"back",
"to",
"standard",
"function",
"if",
"used",
"on",
"local",
"files",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_core.py#L53-L88 |
Accelize/pycosio | pycosio/storage/oss.py | _handle_oss_error | def _handle_oss_error():
"""
Handle OSS exception and convert to class IO exceptions
Raises:
OSError subclasses: IO error.
"""
try:
yield
except _OssError as exception:
if exception.status in _ERROR_CODES:
raise _ERROR_CODES[exception.status](
... | python | def _handle_oss_error():
"""
Handle OSS exception and convert to class IO exceptions
Raises:
OSError subclasses: IO error.
"""
try:
yield
except _OssError as exception:
if exception.status in _ERROR_CODES:
raise _ERROR_CODES[exception.status](
... | [
"def",
"_handle_oss_error",
"(",
")",
":",
"try",
":",
"yield",
"except",
"_OssError",
"as",
"exception",
":",
"if",
"exception",
".",
"status",
"in",
"_ERROR_CODES",
":",
"raise",
"_ERROR_CODES",
"[",
"exception",
".",
"status",
"]",
"(",
"exception",
".",
... | Handle OSS exception and convert to class IO exceptions
Raises:
OSError subclasses: IO error. | [
"Handle",
"OSS",
"exception",
"and",
"convert",
"to",
"class",
"IO",
"exceptions"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L25-L39 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem.copy | def copy(self, src, dst, other_system=None):
"""
Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused.
"""
copy_source = self.get_client_kwarg... | python | def copy(self, src, dst, other_system=None):
"""
Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused.
"""
copy_source = self.get_client_kwarg... | [
"def",
"copy",
"(",
"self",
",",
"src",
",",
"dst",
",",
"other_system",
"=",
"None",
")",
":",
"copy_source",
"=",
"self",
".",
"get_client_kwargs",
"(",
"src",
")",
"copy_destination",
"=",
"self",
".",
"get_client_kwargs",
"(",
"dst",
")",
"with",
"_h... | Copy object of the same storage.
Args:
src (str): Path or URL.
dst (str): Path or URL.
other_system (pycosio._core.io_system.SystemBase subclass): Unused. | [
"Copy",
"object",
"of",
"the",
"same",
"storage",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L67-L83 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._get_client | def _get_client(self):
"""
OSS2 Auth client
Returns:
oss2.Auth or oss2.StsAuth: client
"""
return (_oss.StsAuth if 'security_token' in self._storage_parameters
else _oss.Auth if self._storage_parameters
else _oss.AnonymousAuth)(**self.... | python | def _get_client(self):
"""
OSS2 Auth client
Returns:
oss2.Auth or oss2.StsAuth: client
"""
return (_oss.StsAuth if 'security_token' in self._storage_parameters
else _oss.Auth if self._storage_parameters
else _oss.AnonymousAuth)(**self.... | [
"def",
"_get_client",
"(",
"self",
")",
":",
"return",
"(",
"_oss",
".",
"StsAuth",
"if",
"'security_token'",
"in",
"self",
".",
"_storage_parameters",
"else",
"_oss",
".",
"Auth",
"if",
"self",
".",
"_storage_parameters",
"else",
"_oss",
".",
"AnonymousAuth",... | OSS2 Auth client
Returns:
oss2.Auth or oss2.StsAuth: client | [
"OSS2",
"Auth",
"client"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L102-L111 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._get_roots | def _get_roots(self):
"""
Return URL roots for this storage.
Returns:
tuple of str or re.Pattern: URL roots
"""
return (
# OSS Scheme
# - oss://<bucket>/<key>
'oss://',
# URL (With common aliyuncs.com endpoint):
... | python | def _get_roots(self):
"""
Return URL roots for this storage.
Returns:
tuple of str or re.Pattern: URL roots
"""
return (
# OSS Scheme
# - oss://<bucket>/<key>
'oss://',
# URL (With common aliyuncs.com endpoint):
... | [
"def",
"_get_roots",
"(",
"self",
")",
":",
"return",
"(",
"# OSS Scheme",
"# - oss://<bucket>/<key>",
"'oss://'",
",",
"# URL (With common aliyuncs.com endpoint):",
"# - http://<bucket>.oss-<region>.aliyuncs.com/<key>",
"# - https://<bucket>.oss-<region>.aliyuncs.com/<key>",
"# Note: ... | Return URL roots for this storage.
Returns:
tuple of str or re.Pattern: URL roots | [
"Return",
"URL",
"roots",
"for",
"this",
"storage",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L113-L134 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._get_bucket | def _get_bucket(self, client_kwargs):
"""
Get bucket object.
Returns:
oss2.Bucket
"""
return _oss.Bucket(self.client, endpoint=self._endpoint,
bucket_name=client_kwargs['bucket_name']) | python | def _get_bucket(self, client_kwargs):
"""
Get bucket object.
Returns:
oss2.Bucket
"""
return _oss.Bucket(self.client, endpoint=self._endpoint,
bucket_name=client_kwargs['bucket_name']) | [
"def",
"_get_bucket",
"(",
"self",
",",
"client_kwargs",
")",
":",
"return",
"_oss",
".",
"Bucket",
"(",
"self",
".",
"client",
",",
"endpoint",
"=",
"self",
".",
"_endpoint",
",",
"bucket_name",
"=",
"client_kwargs",
"[",
"'bucket_name'",
"]",
")"
] | Get bucket object.
Returns:
oss2.Bucket | [
"Get",
"bucket",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L136-L144 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem.islink | def islink(self, path=None, header=None):
"""
Returns True if object is a symbolic link.
Args:
path (str): File path or URL.
header (dict): Object header.
Returns:
bool: True if object is Symlink.
"""
if header is None:
he... | python | def islink(self, path=None, header=None):
"""
Returns True if object is a symbolic link.
Args:
path (str): File path or URL.
header (dict): Object header.
Returns:
bool: True if object is Symlink.
"""
if header is None:
he... | [
"def",
"islink",
"(",
"self",
",",
"path",
"=",
"None",
",",
"header",
"=",
"None",
")",
":",
"if",
"header",
"is",
"None",
":",
"header",
"=",
"self",
".",
"_head",
"(",
"self",
".",
"get_client_kwargs",
"(",
"path",
")",
")",
"for",
"key",
"in",
... | Returns True if object is a symbolic link.
Args:
path (str): File path or URL.
header (dict): Object header.
Returns:
bool: True if object is Symlink. | [
"Returns",
"True",
"if",
"object",
"is",
"a",
"symbolic",
"link",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L146-L165 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._head | def _head(self, client_kwargs):
"""
Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
with _handle_oss_error():
bucket = self._get_bucket(client_kwargs)
# Object
... | python | def _head(self, client_kwargs):
"""
Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header.
"""
with _handle_oss_error():
bucket = self._get_bucket(client_kwargs)
# Object
... | [
"def",
"_head",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_oss_error",
"(",
")",
":",
"bucket",
"=",
"self",
".",
"_get_bucket",
"(",
"client_kwargs",
")",
"# Object",
"if",
"'key'",
"in",
"client_kwargs",
":",
"return",
"bucket",
".",
"... | Returns object HTTP header.
Args:
client_kwargs (dict): Client arguments.
Returns:
dict: HTTP header. | [
"Returns",
"object",
"HTTP",
"header",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L167-L186 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._make_dir | def _make_dir(self, client_kwargs):
"""
Make a directory.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_oss_error():
bucket = self._get_bucket(client_kwargs)
# Object
if 'key' in client_kwargs:
ret... | python | def _make_dir(self, client_kwargs):
"""
Make a directory.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_oss_error():
bucket = self._get_bucket(client_kwargs)
# Object
if 'key' in client_kwargs:
ret... | [
"def",
"_make_dir",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_oss_error",
"(",
")",
":",
"bucket",
"=",
"self",
".",
"_get_bucket",
"(",
"client_kwargs",
")",
"# Object",
"if",
"'key'",
"in",
"client_kwargs",
":",
"return",
"bucket",
".",... | Make a directory.
args:
client_kwargs (dict): Client arguments. | [
"Make",
"a",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L188-L204 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._remove | def _remove(self, client_kwargs):
"""
Remove an object.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_oss_error():
bucket = self._get_bucket(client_kwargs)
# Object
if 'key' in client_kwargs:
retur... | python | def _remove(self, client_kwargs):
"""
Remove an object.
args:
client_kwargs (dict): Client arguments.
"""
with _handle_oss_error():
bucket = self._get_bucket(client_kwargs)
# Object
if 'key' in client_kwargs:
retur... | [
"def",
"_remove",
"(",
"self",
",",
"client_kwargs",
")",
":",
"with",
"_handle_oss_error",
"(",
")",
":",
"bucket",
"=",
"self",
".",
"_get_bucket",
"(",
"client_kwargs",
")",
"# Object",
"if",
"'key'",
"in",
"client_kwargs",
":",
"return",
"bucket",
".",
... | Remove an object.
args:
client_kwargs (dict): Client arguments. | [
"Remove",
"an",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L206-L221 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._model_to_dict | def _model_to_dict(model, ignore):
"""
Convert OSS model to dict.
Args:
model (oss2.models.RequestResult): Model.
ignore (tuple of str): Keys to not insert to dict.
Returns:
dict: Model dict version.
"""
return {attr: value for attr, ... | python | def _model_to_dict(model, ignore):
"""
Convert OSS model to dict.
Args:
model (oss2.models.RequestResult): Model.
ignore (tuple of str): Keys to not insert to dict.
Returns:
dict: Model dict version.
"""
return {attr: value for attr, ... | [
"def",
"_model_to_dict",
"(",
"model",
",",
"ignore",
")",
":",
"return",
"{",
"attr",
":",
"value",
"for",
"attr",
",",
"value",
"in",
"model",
".",
"__dict__",
".",
"items",
"(",
")",
"if",
"not",
"attr",
".",
"startswith",
"(",
"'_'",
")",
"and",
... | Convert OSS model to dict.
Args:
model (oss2.models.RequestResult): Model.
ignore (tuple of str): Keys to not insert to dict.
Returns:
dict: Model dict version. | [
"Convert",
"OSS",
"model",
"to",
"dict",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L224-L236 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._list_locators | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_oss_error():
response = _oss.Service(
self.client, endpoint=self._endpoint).list_buckets()
for bucke... | python | def _list_locators(self):
"""
Lists locators.
Returns:
generator of tuple: locator name str, locator header dict
"""
with _handle_oss_error():
response = _oss.Service(
self.client, endpoint=self._endpoint).list_buckets()
for bucke... | [
"def",
"_list_locators",
"(",
"self",
")",
":",
"with",
"_handle_oss_error",
"(",
")",
":",
"response",
"=",
"_oss",
".",
"Service",
"(",
"self",
".",
"client",
",",
"endpoint",
"=",
"self",
".",
"_endpoint",
")",
".",
"list_buckets",
"(",
")",
"for",
... | Lists locators.
Returns:
generator of tuple: locator name str, locator header dict | [
"Lists",
"locators",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L238-L250 |
Accelize/pycosio | pycosio/storage/oss.py | _OSSSystem._list_objects | def _list_objects(self, client_kwargs, path, max_request_entries):
"""
Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
... | python | def _list_objects(self, client_kwargs, path, max_request_entries):
"""
Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
... | [
"def",
"_list_objects",
"(",
"self",
",",
"client_kwargs",
",",
"path",
",",
"max_request_entries",
")",
":",
"kwargs",
"=",
"dict",
"(",
")",
"if",
"max_request_entries",
":",
"kwargs",
"[",
"'max_keys'",
"]",
"=",
"max_request_entries",
"bucket",
"=",
"self"... | Lists objects.
args:
client_kwargs (dict): Client arguments.
path (str): Path relative to current locator.
max_request_entries (int): If specified, maximum entries returned
by request.
Returns:
generator of tuple: object name str, object ... | [
"Lists",
"objects",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L252-L288 |
Accelize/pycosio | pycosio/storage/oss.py | OSSRawIO._read_range | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
if star... | python | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
if star... | [
"def",
"_read_range",
"(",
"self",
",",
"start",
",",
"end",
"=",
"0",
")",
":",
"if",
"start",
">=",
"self",
".",
"_size",
":",
"# EOF. Do not detect using 416 (Out of range) error, 200 returned.",
"return",
"bytes",
"(",
")",
"# Get object bytes range",
"with",
... | Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read | [
"Read",
"a",
"range",
"of",
"bytes",
"in",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L327-L351 |
Accelize/pycosio | pycosio/storage/oss.py | OSSRawIO._readall | def _readall(self):
"""
Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content
"""
with _handle_oss_error():
return self._bucket.get_object(key=self._key).read() | python | def _readall(self):
"""
Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content
"""
with _handle_oss_error():
return self._bucket.get_object(key=self._key).read() | [
"def",
"_readall",
"(",
"self",
")",
":",
"with",
"_handle_oss_error",
"(",
")",
":",
"return",
"self",
".",
"_bucket",
".",
"get_object",
"(",
"key",
"=",
"self",
".",
"_key",
")",
".",
"read",
"(",
")"
] | Read and return all the bytes from the stream until EOF.
Returns:
bytes: Object content | [
"Read",
"and",
"return",
"all",
"the",
"bytes",
"from",
"the",
"stream",
"until",
"EOF",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L353-L361 |
Accelize/pycosio | pycosio/storage/oss.py | OSSRawIO._flush | def _flush(self, buffer):
"""
Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
"""
with _handle_oss_error():
self._bucket.put_object(key=self._key, data=buffer.tobytes()) | python | def _flush(self, buffer):
"""
Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content.
"""
with _handle_oss_error():
self._bucket.put_object(key=self._key, data=buffer.tobytes()) | [
"def",
"_flush",
"(",
"self",
",",
"buffer",
")",
":",
"with",
"_handle_oss_error",
"(",
")",
":",
"self",
".",
"_bucket",
".",
"put_object",
"(",
"key",
"=",
"self",
".",
"_key",
",",
"data",
"=",
"buffer",
".",
"tobytes",
"(",
")",
")"
] | Flush the write buffers of the stream if applicable.
Args:
buffer (memoryview): Buffer content. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"if",
"applicable",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L363-L371 |
Accelize/pycosio | pycosio/storage/oss.py | OSSBufferedIO._flush | def _flush(self):
"""
Flush the write buffers of the stream.
"""
# Initialize multipart upload
if self._upload_id is None:
with _handle_oss_error():
self._upload_id = self._bucket.init_multipart_upload(
self._key).upload_id
... | python | def _flush(self):
"""
Flush the write buffers of the stream.
"""
# Initialize multipart upload
if self._upload_id is None:
with _handle_oss_error():
self._upload_id = self._bucket.init_multipart_upload(
self._key).upload_id
... | [
"def",
"_flush",
"(",
"self",
")",
":",
"# Initialize multipart upload",
"if",
"self",
".",
"_upload_id",
"is",
"None",
":",
"with",
"_handle_oss_error",
"(",
")",
":",
"self",
".",
"_upload_id",
"=",
"self",
".",
"_bucket",
".",
"init_multipart_upload",
"(",
... | Flush the write buffers of the stream. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L403-L420 |
Accelize/pycosio | pycosio/storage/oss.py | OSSBufferedIO._close_writable | def _close_writable(self):
"""
Close the object in write mode.
"""
# Wait parts upload completion
parts = [_PartInfo(part_number=future['part_number'],
etag=future['response'].result().etag)
for future in self._write_futures]
#... | python | def _close_writable(self):
"""
Close the object in write mode.
"""
# Wait parts upload completion
parts = [_PartInfo(part_number=future['part_number'],
etag=future['response'].result().etag)
for future in self._write_futures]
#... | [
"def",
"_close_writable",
"(",
"self",
")",
":",
"# Wait parts upload completion",
"parts",
"=",
"[",
"_PartInfo",
"(",
"part_number",
"=",
"future",
"[",
"'part_number'",
"]",
",",
"etag",
"=",
"future",
"[",
"'response'",
"]",
".",
"result",
"(",
")",
".",... | Close the object in write mode. | [
"Close",
"the",
"object",
"in",
"write",
"mode",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/oss.py#L422-L440 |
Accelize/pycosio | pycosio/_core/functions_io.py | cos_open | def cos_open(file, mode='r', buffering=-1, encoding=None, errors=None,
newline=None, storage=None, storage_parameters=None, unsecure=None,
**kwargs):
"""
Open file and return a corresponding file object.
Equivalent to "io.open" or builtin "open".
File can also be binary opene... | python | def cos_open(file, mode='r', buffering=-1, encoding=None, errors=None,
newline=None, storage=None, storage_parameters=None, unsecure=None,
**kwargs):
"""
Open file and return a corresponding file object.
Equivalent to "io.open" or builtin "open".
File can also be binary opene... | [
"def",
"cos_open",
"(",
"file",
",",
"mode",
"=",
"'r'",
",",
"buffering",
"=",
"-",
"1",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"None",
",",
"newline",
"=",
"None",
",",
"storage",
"=",
"None",
",",
"storage_parameters",
"=",
"None",
",",... | Open file and return a corresponding file object.
Equivalent to "io.open" or builtin "open".
File can also be binary opened file-like object.
Args:
file (path-like object or file-like object): File path, object URL or
opened file-like object.
mode (str): mode in which the file... | [
"Open",
"file",
"and",
"return",
"a",
"corresponding",
"file",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_io.py#L12-L85 |
Accelize/pycosio | pycosio/_core/functions_io.py | _text_io_wrapper | def _text_io_wrapper(stream, mode, encoding, errors, newline):
"""Wrap a binary stream to Text stream.
Args:
stream (file-like object): binary stream.
mode (str): Open mode.
encoding (str): Stream encoding.
errors (str): Decoding error handling.
newline (str): Universal ... | python | def _text_io_wrapper(stream, mode, encoding, errors, newline):
"""Wrap a binary stream to Text stream.
Args:
stream (file-like object): binary stream.
mode (str): Open mode.
encoding (str): Stream encoding.
errors (str): Decoding error handling.
newline (str): Universal ... | [
"def",
"_text_io_wrapper",
"(",
"stream",
",",
"mode",
",",
"encoding",
",",
"errors",
",",
"newline",
")",
":",
"# Text mode, if not already a text stream",
"# That has the \"encoding\" attribute",
"if",
"\"t\"",
"in",
"mode",
"and",
"not",
"hasattr",
"(",
"stream",
... | Wrap a binary stream to Text stream.
Args:
stream (file-like object): binary stream.
mode (str): Open mode.
encoding (str): Stream encoding.
errors (str): Decoding error handling.
newline (str): Universal newlines | [
"Wrap",
"a",
"binary",
"stream",
"to",
"Text",
"stream",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_io.py#L89-L109 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/utils.py | random_model | def random_model(ctx, model_class_name):
"""
Get a random model identifier by class name. For example::
# db/fixtures/Category.yml
{% for i in range(0, 10) %}
category{{ i }}:
name: {{ faker.name() }}
{% endfor %}
# db/fixtures/Post.yml
a_blog_post:
... | python | def random_model(ctx, model_class_name):
"""
Get a random model identifier by class name. For example::
# db/fixtures/Category.yml
{% for i in range(0, 10) %}
category{{ i }}:
name: {{ faker.name() }}
{% endfor %}
# db/fixtures/Post.yml
a_blog_post:
... | [
"def",
"random_model",
"(",
"ctx",
",",
"model_class_name",
")",
":",
"model_identifiers",
"=",
"ctx",
"[",
"'model_identifiers'",
"]",
"[",
"model_class_name",
"]",
"if",
"not",
"model_identifiers",
":",
"return",
"'None'",
"idx",
"=",
"random",
".",
"randrange... | Get a random model identifier by class name. For example::
# db/fixtures/Category.yml
{% for i in range(0, 10) %}
category{{ i }}:
name: {{ faker.name() }}
{% endfor %}
# db/fixtures/Post.yml
a_blog_post:
category: {{ random_model('Category') }}
... | [
"Get",
"a",
"random",
"model",
"identifier",
"by",
"class",
"name",
".",
"For",
"example",
"::"
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/utils.py#L28-L55 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/utils.py | random_models | def random_models(ctx, model_class_name, min_count=0, max_count=3):
"""
Get a random model identifier by class name. Example usage::
# db/fixtures/Tag.yml
{% for i in range(0, 10) %}
tag{{ i }}:
name: {{ faker.name() }}
{% endfor %}
# db/fixtures/Post.yml
... | python | def random_models(ctx, model_class_name, min_count=0, max_count=3):
"""
Get a random model identifier by class name. Example usage::
# db/fixtures/Tag.yml
{% for i in range(0, 10) %}
tag{{ i }}:
name: {{ faker.name() }}
{% endfor %}
# db/fixtures/Post.yml
... | [
"def",
"random_models",
"(",
"ctx",
",",
"model_class_name",
",",
"min_count",
"=",
"0",
",",
"max_count",
"=",
"3",
")",
":",
"model_identifiers",
"=",
"ctx",
"[",
"'model_identifiers'",
"]",
"[",
"model_class_name",
"]",
"num_models",
"=",
"random",
".",
"... | Get a random model identifier by class name. Example usage::
# db/fixtures/Tag.yml
{% for i in range(0, 10) %}
tag{{ i }}:
name: {{ faker.name() }}
{% endfor %}
# db/fixtures/Post.yml
a_blog_post:
tags: {{ random_models('Tag') }}
Will render... | [
"Get",
"a",
"random",
"model",
"identifier",
"by",
"class",
"name",
".",
"Example",
"usage",
"::"
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/utils.py#L58-L92 |
Accelize/pycosio | pycosio/_core/io_file_system.py | FileSystemBase.list_objects | def list_objects(self, path='', relative=False, first_level=False,
max_request_entries=None):
"""
List objects.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
first_level (bool): It True, returns only fi... | python | def list_objects(self, path='', relative=False, first_level=False,
max_request_entries=None):
"""
List objects.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
first_level (bool): It True, returns only fi... | [
"def",
"list_objects",
"(",
"self",
",",
"path",
"=",
"''",
",",
"relative",
"=",
"False",
",",
"first_level",
"=",
"False",
",",
"max_request_entries",
"=",
"None",
")",
":",
"entries",
"=",
"0",
"next_values",
"=",
"[",
"]",
"max_request_entries_arg",
"=... | List objects.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
first_level (bool): It True, returns only first level objects.
Else, returns full tree.
max_request_entries (int): If specified, maximum entries return... | [
"List",
"objects",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_file_system.py#L13-L82 |
fedora-infra/datanommer | tools/first-week-of-datanommer/tstamptobuckets.py | CollisionDict.hash_key | def hash_key(self, key):
""" "Hash" all keys in a timerange to the same value. """
for i, destination_key in enumerate(self._dict):
if key < destination_key:
return destination_key
return key | python | def hash_key(self, key):
""" "Hash" all keys in a timerange to the same value. """
for i, destination_key in enumerate(self._dict):
if key < destination_key:
return destination_key
return key | [
"def",
"hash_key",
"(",
"self",
",",
"key",
")",
":",
"for",
"i",
",",
"destination_key",
"in",
"enumerate",
"(",
"self",
".",
"_dict",
")",
":",
"if",
"key",
"<",
"destination_key",
":",
"return",
"destination_key",
"return",
"key"
] | "Hash" all keys in a timerange to the same value. | [
"Hash",
"all",
"keys",
"in",
"a",
"timerange",
"to",
"the",
"same",
"value",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/tools/first-week-of-datanommer/tstamptobuckets.py#L31-L37 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/fixtures_loader.py | FixturesLoader.create_all | def create_all(self, progress_callback: Optional[callable] = None) -> Dict[str, object]:
"""
Creates all the models discovered from fixture files in :attr:`fixtures_dir`.
:param progress_callback: An optional function to track progress. It must take three
paramete... | python | def create_all(self, progress_callback: Optional[callable] = None) -> Dict[str, object]:
"""
Creates all the models discovered from fixture files in :attr:`fixtures_dir`.
:param progress_callback: An optional function to track progress. It must take three
paramete... | [
"def",
"create_all",
"(",
"self",
",",
"progress_callback",
":",
"Optional",
"[",
"callable",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"object",
"]",
":",
"if",
"not",
"self",
".",
"_loaded",
":",
"self",
".",
"_load_data",
"(",
")",
"# ... | Creates all the models discovered from fixture files in :attr:`fixtures_dir`.
:param progress_callback: An optional function to track progress. It must take three
parameters:
- an :class:`Identifier`
- the model inst... | [
"Creates",
"all",
"the",
"models",
"discovered",
"from",
"fixture",
"files",
"in",
":",
"attr",
":",
"fixtures_dir",
"."
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L53-L95 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/fixtures_loader.py | FixturesLoader.convert_identifiers | def convert_identifiers(self, identifiers: Union[Identifier, List[Identifier]]):
"""
Convert an individual :class:`Identifier` to a model instance,
or a list of Identifiers to a list of model instances.
"""
if not identifiers:
return identifiers
def _create_o... | python | def convert_identifiers(self, identifiers: Union[Identifier, List[Identifier]]):
"""
Convert an individual :class:`Identifier` to a model instance,
or a list of Identifiers to a list of model instances.
"""
if not identifiers:
return identifiers
def _create_o... | [
"def",
"convert_identifiers",
"(",
"self",
",",
"identifiers",
":",
"Union",
"[",
"Identifier",
",",
"List",
"[",
"Identifier",
"]",
"]",
")",
":",
"if",
"not",
"identifiers",
":",
"return",
"identifiers",
"def",
"_create_or_update",
"(",
"identifier",
")",
... | Convert an individual :class:`Identifier` to a model instance,
or a list of Identifiers to a list of model instances. | [
"Convert",
"an",
"individual",
":",
"class",
":",
"Identifier",
"to",
"a",
"model",
"instance",
"or",
"a",
"list",
"of",
"Identifiers",
"to",
"a",
"list",
"of",
"model",
"instances",
"."
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L97-L114 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/fixtures_loader.py | FixturesLoader._load_data | def _load_data(self):
"""
Load all fixtures from :attr:`fixtures_dir`
"""
filenames = []
model_identifiers = defaultdict(list)
# attempt to load fixture files from given directories (first pass)
# for each valid model fixture file, read it into the cache and get ... | python | def _load_data(self):
"""
Load all fixtures from :attr:`fixtures_dir`
"""
filenames = []
model_identifiers = defaultdict(list)
# attempt to load fixture files from given directories (first pass)
# for each valid model fixture file, read it into the cache and get ... | [
"def",
"_load_data",
"(",
"self",
")",
":",
"filenames",
"=",
"[",
"]",
"model_identifiers",
"=",
"defaultdict",
"(",
"list",
")",
"# attempt to load fixture files from given directories (first pass)",
"# for each valid model fixture file, read it into the cache and get the",
"# ... | Load all fixtures from :attr:`fixtures_dir` | [
"Load",
"all",
"fixtures",
"from",
":",
"attr",
":",
"fixtures_dir"
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L116-L150 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/fixtures_loader.py | FixturesLoader._load_from_yaml | def _load_from_yaml(self, filename: str, model_identifiers: Dict[str, List[str]]):
"""
Load fixtures from the given filename
"""
class_name = filename[:filename.rfind('.')]
rendered_yaml = self.env.get_template(filename).render(
model_identifiers=model_identifiers)
... | python | def _load_from_yaml(self, filename: str, model_identifiers: Dict[str, List[str]]):
"""
Load fixtures from the given filename
"""
class_name = filename[:filename.rfind('.')]
rendered_yaml = self.env.get_template(filename).render(
model_identifiers=model_identifiers)
... | [
"def",
"_load_from_yaml",
"(",
"self",
",",
"filename",
":",
"str",
",",
"model_identifiers",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
")",
":",
"class_name",
"=",
"filename",
"[",
":",
"filename",
".",
"rfind",
"(",
"'.'",
")",
"]... | Load fixtures from the given filename | [
"Load",
"fixtures",
"from",
"the",
"given",
"filename"
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L152-L164 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/fixtures_loader.py | FixturesLoader._post_process_yaml_data | def _post_process_yaml_data(self,
fixture_data: Dict[str, Dict[str, Any]],
relationship_columns: Set[str],
) -> Tuple[Dict[str, Dict[str, Any]], List[str]]:
"""
Convert and normalize identifier strings to Ide... | python | def _post_process_yaml_data(self,
fixture_data: Dict[str, Dict[str, Any]],
relationship_columns: Set[str],
) -> Tuple[Dict[str, Dict[str, Any]], List[str]]:
"""
Convert and normalize identifier strings to Ide... | [
"def",
"_post_process_yaml_data",
"(",
"self",
",",
"fixture_data",
":",
"Dict",
"[",
"str",
",",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"relationship_columns",
":",
"Set",
"[",
"str",
"]",
",",
")",
"->",
"Tuple",
"[",
"Dict",
"[",
"str",
",... | Convert and normalize identifier strings to Identifiers, as well as determine
class relationships. | [
"Convert",
"and",
"normalize",
"identifier",
"strings",
"to",
"Identifiers",
"as",
"well",
"as",
"determine",
"class",
"relationships",
"."
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L166-L196 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/fixtures_loader.py | FixturesLoader._ensure_env | def _ensure_env(self, env: Union[jinja2.Environment, None]):
"""
Make sure the jinja environment is minimally configured.
"""
if not env:
env = jinja2.Environment()
if not env.loader:
env.loader = jinja2.FunctionLoader(lambda filename: self._cache[filename... | python | def _ensure_env(self, env: Union[jinja2.Environment, None]):
"""
Make sure the jinja environment is minimally configured.
"""
if not env:
env = jinja2.Environment()
if not env.loader:
env.loader = jinja2.FunctionLoader(lambda filename: self._cache[filename... | [
"def",
"_ensure_env",
"(",
"self",
",",
"env",
":",
"Union",
"[",
"jinja2",
".",
"Environment",
",",
"None",
"]",
")",
":",
"if",
"not",
"env",
":",
"env",
"=",
"jinja2",
".",
"Environment",
"(",
")",
"if",
"not",
"env",
".",
"loader",
":",
"env",
... | Make sure the jinja environment is minimally configured. | [
"Make",
"sure",
"the",
"jinja",
"environment",
"is",
"minimally",
"configured",
"."
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L198-L214 |
briancappello/py-yaml-fixtures | py_yaml_fixtures/fixtures_loader.py | FixturesLoader._preloading_env | def _preloading_env(self):
"""
A "stripped" jinja environment.
"""
ctx = self.env.globals
try:
ctx['random_model'] = lambda *a, **kw: None
ctx['random_models'] = lambda *a, **kw: None
yield self.env
finally:
ctx['random_mode... | python | def _preloading_env(self):
"""
A "stripped" jinja environment.
"""
ctx = self.env.globals
try:
ctx['random_model'] = lambda *a, **kw: None
ctx['random_models'] = lambda *a, **kw: None
yield self.env
finally:
ctx['random_mode... | [
"def",
"_preloading_env",
"(",
"self",
")",
":",
"ctx",
"=",
"self",
".",
"env",
".",
"globals",
"try",
":",
"ctx",
"[",
"'random_model'",
"]",
"=",
"lambda",
"*",
"a",
",",
"*",
"*",
"kw",
":",
"None",
"ctx",
"[",
"'random_models'",
"]",
"=",
"lam... | A "stripped" jinja environment. | [
"A",
"stripped",
"jinja",
"environment",
"."
] | train | https://github.com/briancappello/py-yaml-fixtures/blob/60c37daf58ec3b1c4bba637889949523a69b8a73/py_yaml_fixtures/fixtures_loader.py#L217-L228 |
Accelize/pycosio | pycosio/_core/storage_manager.py | get_instance | def get_instance(name, cls='system', storage=None, storage_parameters=None,
unsecure=None, *args, **kwargs):
"""
Get a cloud object storage instance.
Args:
name (str): File name, path or URL.
cls (str): Type of class to instantiate.
'raw', 'buffered' or 'system'... | python | def get_instance(name, cls='system', storage=None, storage_parameters=None,
unsecure=None, *args, **kwargs):
"""
Get a cloud object storage instance.
Args:
name (str): File name, path or URL.
cls (str): Type of class to instantiate.
'raw', 'buffered' or 'system'... | [
"def",
"get_instance",
"(",
"name",
",",
"cls",
"=",
"'system'",
",",
"storage",
"=",
"None",
",",
"storage_parameters",
"=",
"None",
",",
"unsecure",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"system_parameters",
"=",
"_system_pa... | Get a cloud object storage instance.
Args:
name (str): File name, path or URL.
cls (str): Type of class to instantiate.
'raw', 'buffered' or 'system'.
storage (str): Storage name.
storage_parameters (dict): Storage configuration parameters.
Generally, client ... | [
"Get",
"a",
"cloud",
"object",
"storage",
"instance",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/storage_manager.py#L30-L99 |
Accelize/pycosio | pycosio/_core/storage_manager.py | mount | def mount(storage=None, name='', storage_parameters=None,
unsecure=None, extra_root=None):
"""
Mount a new storage.
Args:
storage (str): Storage name.
name (str): File URL. If storage is not specified,
URL scheme will be used as storage value.
storage_parameter... | python | def mount(storage=None, name='', storage_parameters=None,
unsecure=None, extra_root=None):
"""
Mount a new storage.
Args:
storage (str): Storage name.
name (str): File URL. If storage is not specified,
URL scheme will be used as storage value.
storage_parameter... | [
"def",
"mount",
"(",
"storage",
"=",
"None",
",",
"name",
"=",
"''",
",",
"storage_parameters",
"=",
"None",
",",
"unsecure",
"=",
"None",
",",
"extra_root",
"=",
"None",
")",
":",
"# Tries to infer storage from name",
"if",
"storage",
"is",
"None",
":",
"... | Mount a new storage.
Args:
storage (str): Storage name.
name (str): File URL. If storage is not specified,
URL scheme will be used as storage value.
storage_parameters (dict): Storage configuration parameters.
Generally, client configuration and credentials.
... | [
"Mount",
"a",
"new",
"storage",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/storage_manager.py#L102-L223 |
Accelize/pycosio | pycosio/_core/storage_manager.py | _system_parameters | def _system_parameters(**kwargs):
"""
Returns system keyword arguments removing Nones.
Args:
kwargs: system keyword arguments.
Returns:
dict: system keyword arguments.
"""
return {key: value for key, value in kwargs.items()
if (value is not None or value == {})} | python | def _system_parameters(**kwargs):
"""
Returns system keyword arguments removing Nones.
Args:
kwargs: system keyword arguments.
Returns:
dict: system keyword arguments.
"""
return {key: value for key, value in kwargs.items()
if (value is not None or value == {})} | [
"def",
"_system_parameters",
"(",
"*",
"*",
"kwargs",
")",
":",
"return",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
"if",
"(",
"value",
"is",
"not",
"None",
"or",
"value",
"==",
"{",
"}",
")",
"... | Returns system keyword arguments removing Nones.
Args:
kwargs: system keyword arguments.
Returns:
dict: system keyword arguments. | [
"Returns",
"system",
"keyword",
"arguments",
"removing",
"Nones",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/storage_manager.py#L226-L237 |
asottile/pymonkey | pymonkey.py | manual_argument_parsing | def manual_argument_parsing(argv):
"""sadness because argparse doesn't quite do what we want."""
# Special case these for a better error message
if not argv or argv == ['-h'] or argv == ['--help']:
print_help_and_exit()
try:
dashdash_index = argv.index('--')
except ValueError:
... | python | def manual_argument_parsing(argv):
"""sadness because argparse doesn't quite do what we want."""
# Special case these for a better error message
if not argv or argv == ['-h'] or argv == ['--help']:
print_help_and_exit()
try:
dashdash_index = argv.index('--')
except ValueError:
... | [
"def",
"manual_argument_parsing",
"(",
"argv",
")",
":",
"# Special case these for a better error message",
"if",
"not",
"argv",
"or",
"argv",
"==",
"[",
"'-h'",
"]",
"or",
"argv",
"==",
"[",
"'--help'",
"]",
":",
"print_help_and_exit",
"(",
")",
"try",
":",
"... | sadness because argparse doesn't quite do what we want. | [
"sadness",
"because",
"argparse",
"doesn",
"t",
"quite",
"do",
"what",
"we",
"want",
"."
] | train | https://github.com/asottile/pymonkey/blob/f2e55590c7064019e928eddc41dad5d288722ce6/pymonkey.py#L57-L90 |
asottile/pymonkey | pymonkey.py | make_entry_point | def make_entry_point(patches, original_entry_point):
"""Use this to make a console_script entry point for your application
which applies patches.
:param patches: iterable of pymonkey patches to apply. Ex: ('my-patch,)
:param original_entry_point: Such as 'pip'
"""
def entry(argv=None):
... | python | def make_entry_point(patches, original_entry_point):
"""Use this to make a console_script entry point for your application
which applies patches.
:param patches: iterable of pymonkey patches to apply. Ex: ('my-patch,)
:param original_entry_point: Such as 'pip'
"""
def entry(argv=None):
... | [
"def",
"make_entry_point",
"(",
"patches",
",",
"original_entry_point",
")",
":",
"def",
"entry",
"(",
"argv",
"=",
"None",
")",
":",
"argv",
"=",
"argv",
"if",
"argv",
"is",
"not",
"None",
"else",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"return",
"m... | Use this to make a console_script entry point for your application
which applies patches.
:param patches: iterable of pymonkey patches to apply. Ex: ('my-patch,)
:param original_entry_point: Such as 'pip' | [
"Use",
"this",
"to",
"make",
"a",
"console_script",
"entry",
"point",
"for",
"your",
"application",
"which",
"applies",
"patches",
".",
":",
"param",
"patches",
":",
"iterable",
"of",
"pymonkey",
"patches",
"to",
"apply",
".",
"Ex",
":",
"(",
"my",
"-",
... | train | https://github.com/asottile/pymonkey/blob/f2e55590c7064019e928eddc41dad5d288722ce6/pymonkey.py#L252-L264 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.client | def client(self):
"""
Storage client
Returns:
client
"""
if self._client is None:
self._client = self._get_client()
return self._client | python | def client(self):
"""
Storage client
Returns:
client
"""
if self._client is None:
self._client = self._get_client()
return self._client | [
"def",
"client",
"(",
"self",
")",
":",
"if",
"self",
".",
"_client",
"is",
"None",
":",
"self",
".",
"_client",
"=",
"self",
".",
"_get_client",
"(",
")",
"return",
"self",
".",
"_client"
] | Storage client
Returns:
client | [
"Storage",
"client"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L85-L94 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.exists | def exists(self, path=None, client_kwargs=None, assume_exists=None):
"""
Return True if path refers to an existing path.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
assume_exists (bool or None): This value define the value to return... | python | def exists(self, path=None, client_kwargs=None, assume_exists=None):
"""
Return True if path refers to an existing path.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
assume_exists (bool or None): This value define the value to return... | [
"def",
"exists",
"(",
"self",
",",
"path",
"=",
"None",
",",
"client_kwargs",
"=",
"None",
",",
"assume_exists",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"head",
"(",
"path",
",",
"client_kwargs",
")",
"except",
"ObjectNotFoundError",
":",
"return... | Return True if path refers to an existing path.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
assume_exists (bool or None): This value define the value to return
in the case there is no enough permission to determinate the
... | [
"Return",
"True",
"if",
"path",
"refers",
"to",
"an",
"existing",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L123-L147 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.getctime | def getctime(self, path=None, client_kwargs=None, header=None):
"""
Return the creation time of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
float: The number of ... | python | def getctime(self, path=None, client_kwargs=None, header=None):
"""
Return the creation time of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
float: The number of ... | [
"def",
"getctime",
"(",
"self",
",",
"path",
"=",
"None",
",",
"client_kwargs",
"=",
"None",
",",
"header",
"=",
"None",
")",
":",
"return",
"self",
".",
"_getctime_from_header",
"(",
"self",
".",
"head",
"(",
"path",
",",
"client_kwargs",
",",
"header",... | Return the creation time of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
float: The number of seconds since the epoch
(see the time module). | [
"Return",
"the",
"creation",
"time",
"of",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L171-L185 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.getmtime | def getmtime(self, path=None, client_kwargs=None, header=None):
"""
Return the time of last access of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
float: The numb... | python | def getmtime(self, path=None, client_kwargs=None, header=None):
"""
Return the time of last access of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
float: The numb... | [
"def",
"getmtime",
"(",
"self",
",",
"path",
"=",
"None",
",",
"client_kwargs",
"=",
"None",
",",
"header",
"=",
"None",
")",
":",
"return",
"self",
".",
"_getmtime_from_header",
"(",
"self",
".",
"head",
"(",
"path",
",",
"client_kwargs",
",",
"header",... | Return the time of last access of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
float: The number of seconds since the epoch
(see the time module). | [
"Return",
"the",
"time",
"of",
"last",
"access",
"of",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L199-L213 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase._get_time | def _get_time(header, keys, name):
"""
Get time from header
Args:
header (dict): Object header.
keys (tuple of str): Header keys.
name (str): Method name.
Returns:
float: The number of seconds since the epoch
"""
for key i... | python | def _get_time(header, keys, name):
"""
Get time from header
Args:
header (dict): Object header.
keys (tuple of str): Header keys.
name (str): Method name.
Returns:
float: The number of seconds since the epoch
"""
for key i... | [
"def",
"_get_time",
"(",
"header",
",",
"keys",
",",
"name",
")",
":",
"for",
"key",
"in",
"keys",
":",
"try",
":",
"date_value",
"=",
"header",
".",
"pop",
"(",
"key",
")",
"except",
"KeyError",
":",
"continue",
"try",
":",
"# String to convert",
"ret... | Get time from header
Args:
header (dict): Object header.
keys (tuple of str): Header keys.
name (str): Method name.
Returns:
float: The number of seconds since the epoch | [
"Get",
"time",
"from",
"header"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L228-L251 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.getsize | def getsize(self, path=None, client_kwargs=None, header=None):
"""
Return the size, in bytes, of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
int: Size in bytes.
... | python | def getsize(self, path=None, client_kwargs=None, header=None):
"""
Return the size, in bytes, of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
int: Size in bytes.
... | [
"def",
"getsize",
"(",
"self",
",",
"path",
"=",
"None",
",",
"client_kwargs",
"=",
"None",
",",
"header",
"=",
"None",
")",
":",
"return",
"self",
".",
"_getsize_from_header",
"(",
"self",
".",
"head",
"(",
"path",
",",
"client_kwargs",
",",
"header",
... | Return the size, in bytes, of path.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
int: Size in bytes. | [
"Return",
"the",
"size",
"in",
"bytes",
"of",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L262-L274 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase._getsize_from_header | def _getsize_from_header(self, header):
"""
Return the size from header
Args:
header (dict): Object header.
Returns:
int: Size in bytes.
"""
# By default, assumes that information are in a standard HTTP header
for key in self._SIZE_KEYS:
... | python | def _getsize_from_header(self, header):
"""
Return the size from header
Args:
header (dict): Object header.
Returns:
int: Size in bytes.
"""
# By default, assumes that information are in a standard HTTP header
for key in self._SIZE_KEYS:
... | [
"def",
"_getsize_from_header",
"(",
"self",
",",
"header",
")",
":",
"# By default, assumes that information are in a standard HTTP header",
"for",
"key",
"in",
"self",
".",
"_SIZE_KEYS",
":",
"try",
":",
"return",
"int",
"(",
"header",
".",
"pop",
"(",
"key",
")"... | Return the size from header
Args:
header (dict): Object header.
Returns:
int: Size in bytes. | [
"Return",
"the",
"size",
"from",
"header"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L276-L293 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.isdir | def isdir(self, path=None, client_kwargs=None, virtual_dir=True,
assume_exists=None):
"""
Return True if path is an existing directory.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
virtual_dir (bool): If True, checks if... | python | def isdir(self, path=None, client_kwargs=None, virtual_dir=True,
assume_exists=None):
"""
Return True if path is an existing directory.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
virtual_dir (bool): If True, checks if... | [
"def",
"isdir",
"(",
"self",
",",
"path",
"=",
"None",
",",
"client_kwargs",
"=",
"None",
",",
"virtual_dir",
"=",
"True",
",",
"assume_exists",
"=",
"None",
")",
":",
"relative",
"=",
"self",
".",
"relpath",
"(",
"path",
")",
"if",
"not",
"relative",
... | Return True if path is an existing directory.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
virtual_dir (bool): If True, checks if directory exists virtually
if an object path if not exists as a specific object.
assume_exi... | [
"Return",
"True",
"if",
"path",
"is",
"an",
"existing",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L295-L335 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.isfile | def isfile(self, path=None, client_kwargs=None, assume_exists=None):
"""
Return True if path is an existing regular file.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
assume_exists (bool or None): This value define the value to retur... | python | def isfile(self, path=None, client_kwargs=None, assume_exists=None):
"""
Return True if path is an existing regular file.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
assume_exists (bool or None): This value define the value to retur... | [
"def",
"isfile",
"(",
"self",
",",
"path",
"=",
"None",
",",
"client_kwargs",
"=",
"None",
",",
"assume_exists",
"=",
"None",
")",
":",
"relative",
"=",
"self",
".",
"relpath",
"(",
"path",
")",
"if",
"not",
"relative",
":",
"# Root always exists and is a ... | Return True if path is an existing regular file.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
assume_exists (bool or None): This value define the value to return
in the case there is no enough permission to determinate the
... | [
"Return",
"True",
"if",
"path",
"is",
"an",
"existing",
"regular",
"file",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L337-L361 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.head | def head(self, path=None, client_kwargs=None, header=None):
"""
Returns object HTTP header.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
dict: HTTP header.
"""
... | python | def head(self, path=None, client_kwargs=None, header=None):
"""
Returns object HTTP header.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
dict: HTTP header.
"""
... | [
"def",
"head",
"(",
"self",
",",
"path",
"=",
"None",
",",
"client_kwargs",
"=",
"None",
",",
"header",
"=",
"None",
")",
":",
"if",
"header",
"is",
"not",
"None",
":",
"return",
"header",
"elif",
"client_kwargs",
"is",
"None",
":",
"client_kwargs",
"=... | Returns object HTTP header.
Args:
path (str): Path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
dict: HTTP header. | [
"Returns",
"object",
"HTTP",
"header",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L385-L401 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.relpath | def relpath(self, path):
"""
Get path relative to storage.
args:
path (str): Absolute path or URL.
Returns:
str: relative path.
"""
for root in self.roots:
# Root is regex, convert to matching root string
if isinstance(roo... | python | def relpath(self, path):
"""
Get path relative to storage.
args:
path (str): Absolute path or URL.
Returns:
str: relative path.
"""
for root in self.roots:
# Root is regex, convert to matching root string
if isinstance(roo... | [
"def",
"relpath",
"(",
"self",
",",
"path",
")",
":",
"for",
"root",
"in",
"self",
".",
"roots",
":",
"# Root is regex, convert to matching root string",
"if",
"isinstance",
"(",
"root",
",",
"Pattern",
")",
":",
"match",
"=",
"root",
".",
"match",
"(",
"p... | Get path relative to storage.
args:
path (str): Absolute path or URL.
Returns:
str: relative path. | [
"Get",
"path",
"relative",
"to",
"storage",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L423-L450 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.is_locator | def is_locator(self, path, relative=False):
"""
Returns True if path refer to a locator.
Depending the storage, locator may be a bucket or container name,
a hostname, ...
args:
path (str): path or URL.
relative (bool): Path is relative to current root.
... | python | def is_locator(self, path, relative=False):
"""
Returns True if path refer to a locator.
Depending the storage, locator may be a bucket or container name,
a hostname, ...
args:
path (str): path or URL.
relative (bool): Path is relative to current root.
... | [
"def",
"is_locator",
"(",
"self",
",",
"path",
",",
"relative",
"=",
"False",
")",
":",
"if",
"not",
"relative",
":",
"path",
"=",
"self",
".",
"relpath",
"(",
"path",
")",
"# Bucket is the main directory",
"return",
"path",
"and",
"'/'",
"not",
"in",
"p... | Returns True if path refer to a locator.
Depending the storage, locator may be a bucket or container name,
a hostname, ...
args:
path (str): path or URL.
relative (bool): Path is relative to current root.
Returns:
bool: True if locator. | [
"Returns",
"True",
"if",
"path",
"refer",
"to",
"a",
"locator",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L452-L469 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.split_locator | def split_locator(self, path):
"""
Split the path into a pair (locator, path).
args:
path (str): Absolute path or URL.
Returns:
tuple of str: locator, path.
"""
relative = self.relpath(path)
try:
locator, tail = relative.split... | python | def split_locator(self, path):
"""
Split the path into a pair (locator, path).
args:
path (str): Absolute path or URL.
Returns:
tuple of str: locator, path.
"""
relative = self.relpath(path)
try:
locator, tail = relative.split... | [
"def",
"split_locator",
"(",
"self",
",",
"path",
")",
":",
"relative",
"=",
"self",
".",
"relpath",
"(",
"path",
")",
"try",
":",
"locator",
",",
"tail",
"=",
"relative",
".",
"split",
"(",
"'/'",
",",
"1",
")",
"except",
"ValueError",
":",
"locator... | Split the path into a pair (locator, path).
args:
path (str): Absolute path or URL.
Returns:
tuple of str: locator, path. | [
"Split",
"the",
"path",
"into",
"a",
"pair",
"(",
"locator",
"path",
")",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L471-L487 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.make_dir | def make_dir(self, path, relative=False):
"""
Make a directory.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
"""
if not relative:
path = self.relpath(path)
self._make_dir(self.get_client_kwargs(self... | python | def make_dir(self, path, relative=False):
"""
Make a directory.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
"""
if not relative:
path = self.relpath(path)
self._make_dir(self.get_client_kwargs(self... | [
"def",
"make_dir",
"(",
"self",
",",
"path",
",",
"relative",
"=",
"False",
")",
":",
"if",
"not",
"relative",
":",
"path",
"=",
"self",
".",
"relpath",
"(",
"path",
")",
"self",
".",
"_make_dir",
"(",
"self",
".",
"get_client_kwargs",
"(",
"self",
"... | Make a directory.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root. | [
"Make",
"a",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L489-L500 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.remove | def remove(self, path, relative=False):
"""
Remove an object.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
"""
if not relative:
path = self.relpath(path)
self._remove(self.get_client_kwargs(path)) | python | def remove(self, path, relative=False):
"""
Remove an object.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
"""
if not relative:
path = self.relpath(path)
self._remove(self.get_client_kwargs(path)) | [
"def",
"remove",
"(",
"self",
",",
"path",
",",
"relative",
"=",
"False",
")",
":",
"if",
"not",
"relative",
":",
"path",
"=",
"self",
".",
"relpath",
"(",
"path",
")",
"self",
".",
"_remove",
"(",
"self",
".",
"get_client_kwargs",
"(",
"path",
")",
... | Remove an object.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root. | [
"Remove",
"an",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L511-L521 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.ensure_dir_path | def ensure_dir_path(self, path, relative=False):
"""
Ensure the path is a dir path.
Should end with '/' except for schemes and locators.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
Returns:
path: dir pat... | python | def ensure_dir_path(self, path, relative=False):
"""
Ensure the path is a dir path.
Should end with '/' except for schemes and locators.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
Returns:
path: dir pat... | [
"def",
"ensure_dir_path",
"(",
"self",
",",
"path",
",",
"relative",
"=",
"False",
")",
":",
"if",
"not",
"relative",
":",
"rel_path",
"=",
"self",
".",
"relpath",
"(",
"path",
")",
"else",
":",
"rel_path",
"=",
"path",
"# Locator",
"if",
"self",
".",
... | Ensure the path is a dir path.
Should end with '/' except for schemes and locators.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
Returns:
path: dir path | [
"Ensure",
"the",
"path",
"is",
"a",
"dir",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L532-L558 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.list_objects | def list_objects(self, path='', relative=False, first_level=False,
max_request_entries=None):
"""
List objects.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
first_level (bool): It True, returns only fi... | python | def list_objects(self, path='', relative=False, first_level=False,
max_request_entries=None):
"""
List objects.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
first_level (bool): It True, returns only fi... | [
"def",
"list_objects",
"(",
"self",
",",
"path",
"=",
"''",
",",
"relative",
"=",
"False",
",",
"first_level",
"=",
"False",
",",
"max_request_entries",
"=",
"None",
")",
":",
"entries",
"=",
"0",
"max_request_entries_arg",
"=",
"None",
"if",
"not",
"relat... | List objects.
Args:
path (str): Path or URL.
relative (bool): Path is relative to current root.
first_level (bool): It True, returns only first level objects.
Else, returns full tree.
max_request_entries (int): If specified, maximum entries return... | [
"List",
"objects",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L560-L678 |
Accelize/pycosio | pycosio/_core/io_base_system.py | SystemBase.stat | def stat(self, path=None, client_kwargs=None, header=None):
"""
Get the status of an object.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
os.stat_result: Stat result ob... | python | def stat(self, path=None, client_kwargs=None, header=None):
"""
Get the status of an object.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
os.stat_result: Stat result ob... | [
"def",
"stat",
"(",
"self",
",",
"path",
"=",
"None",
",",
"client_kwargs",
"=",
"None",
",",
"header",
"=",
"None",
")",
":",
"# Should contain at least the strict minimum of os.stat_result",
"stat",
"=",
"OrderedDict",
"(",
"(",
"(",
"\"st_mode\"",
",",
"0",
... | Get the status of an object.
Args:
path (str): File path or URL.
client_kwargs (dict): Client arguments.
header (dict): Object header.
Returns:
os.stat_result: Stat result object | [
"Get",
"the",
"status",
"of",
"an",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_system.py#L718-L768 |
fedora-infra/datanommer | datanommer.models/datanommer/models/__init__.py | init | def init(uri=None, alembic_ini=None, engine=None, create=False):
""" Initialize a connection. Create tables if requested."""
if uri and engine:
raise ValueError("uri and engine cannot both be specified")
if uri is None and not engine:
uri = 'sqlite:////tmp/datanommer.db'
log.warni... | python | def init(uri=None, alembic_ini=None, engine=None, create=False):
""" Initialize a connection. Create tables if requested."""
if uri and engine:
raise ValueError("uri and engine cannot both be specified")
if uri is None and not engine:
uri = 'sqlite:////tmp/datanommer.db'
log.warni... | [
"def",
"init",
"(",
"uri",
"=",
"None",
",",
"alembic_ini",
"=",
"None",
",",
"engine",
"=",
"None",
",",
"create",
"=",
"False",
")",
":",
"if",
"uri",
"and",
"engine",
":",
"raise",
"ValueError",
"(",
"\"uri and engine cannot both be specified\"",
")",
"... | Initialize a connection. Create tables if requested. | [
"Initialize",
"a",
"connection",
".",
"Create",
"tables",
"if",
"requested",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/datanommer.models/datanommer/models/__init__.py#L65-L112 |
fedora-infra/datanommer | datanommer.models/datanommer/models/__init__.py | add | def add(envelope):
""" Take a dict-like fedmsg envelope and store the headers and message
in the table.
"""
message = envelope['body']
timestamp = message.get('timestamp', None)
try:
if timestamp:
timestamp = datetime.datetime.utcfromtimestamp(timestamp)
else:
... | python | def add(envelope):
""" Take a dict-like fedmsg envelope and store the headers and message
in the table.
"""
message = envelope['body']
timestamp = message.get('timestamp', None)
try:
if timestamp:
timestamp = datetime.datetime.utcfromtimestamp(timestamp)
else:
... | [
"def",
"add",
"(",
"envelope",
")",
":",
"message",
"=",
"envelope",
"[",
"'body'",
"]",
"timestamp",
"=",
"message",
".",
"get",
"(",
"'timestamp'",
",",
"None",
")",
"try",
":",
"if",
"timestamp",
":",
"timestamp",
"=",
"datetime",
".",
"datetime",
"... | Take a dict-like fedmsg envelope and store the headers and message
in the table. | [
"Take",
"a",
"dict",
"-",
"like",
"fedmsg",
"envelope",
"and",
"store",
"the",
"headers",
"and",
"message",
"in",
"the",
"table",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/datanommer.models/datanommer/models/__init__.py#L115-L205 |
fedora-infra/datanommer | datanommer.models/datanommer/models/__init__.py | Singleton.get_or_create | def get_or_create(cls, name):
"""
Return the instance of the class with the specified name. If it doesn't
already exist, create it.
"""
obj = cls.query.filter_by(name=name).one_or_none()
if obj:
return obj
try:
with session.begin_nested():
... | python | def get_or_create(cls, name):
"""
Return the instance of the class with the specified name. If it doesn't
already exist, create it.
"""
obj = cls.query.filter_by(name=name).one_or_none()
if obj:
return obj
try:
with session.begin_nested():
... | [
"def",
"get_or_create",
"(",
"cls",
",",
"name",
")",
":",
"obj",
"=",
"cls",
".",
"query",
".",
"filter_by",
"(",
"name",
"=",
"name",
")",
".",
"one_or_none",
"(",
")",
"if",
"obj",
":",
"return",
"obj",
"try",
":",
"with",
"session",
".",
"begin... | Return the instance of the class with the specified name. If it doesn't
already exist, create it. | [
"Return",
"the",
"instance",
"of",
"the",
"class",
"with",
"the",
"specified",
"name",
".",
"If",
"it",
"doesn",
"t",
"already",
"exist",
"create",
"it",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/datanommer.models/datanommer/models/__init__.py#L295-L312 |
fedora-infra/datanommer | datanommer.models/datanommer/models/__init__.py | Message.grep | def grep(cls, start=None, end=None,
page=1, rows_per_page=100,
order="asc", msg_id=None,
users=None, not_users=None,
packages=None, not_packages=None,
categories=None, not_categories=None,
topics=None, not_topics=None,
contains=N... | python | def grep(cls, start=None, end=None,
page=1, rows_per_page=100,
order="asc", msg_id=None,
users=None, not_users=None,
packages=None, not_packages=None,
categories=None, not_categories=None,
topics=None, not_topics=None,
contains=N... | [
"def",
"grep",
"(",
"cls",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"page",
"=",
"1",
",",
"rows_per_page",
"=",
"100",
",",
"order",
"=",
"\"asc\"",
",",
"msg_id",
"=",
"None",
",",
"users",
"=",
"None",
",",
"not_users",
"=",
"N... | Flexible query interface for messages.
Arguments are filters. start and end should be :mod:`datetime` objs.
Other filters should be lists of strings. They are applied in a
conjunctive-normal-form (CNF) kind of way
for example, the following::
users = ['ralph', 'lmacken']
... | [
"Flexible",
"query",
"interface",
"for",
"messages",
"."
] | train | https://github.com/fedora-infra/datanommer/blob/4a20e216bb404b14f76c7065518fd081e989764d/datanommer.models/datanommer/models/__init__.py#L335-L464 |
Accelize/pycosio | pycosio/_core/functions_os_path.py | isdir | def isdir(path):
"""
Return True if path is an existing directory.
Equivalent to "os.path.isdir".
Args:
path (path-like object): Path or URL.
Returns:
bool: True if directory exists.
"""
system = get_instance(path)
# User may use directory path without trailing '/'
... | python | def isdir(path):
"""
Return True if path is an existing directory.
Equivalent to "os.path.isdir".
Args:
path (path-like object): Path or URL.
Returns:
bool: True if directory exists.
"""
system = get_instance(path)
# User may use directory path without trailing '/'
... | [
"def",
"isdir",
"(",
"path",
")",
":",
"system",
"=",
"get_instance",
"(",
"path",
")",
"# User may use directory path without trailing '/'",
"# like on standard file systems",
"return",
"system",
".",
"isdir",
"(",
"system",
".",
"ensure_dir_path",
"(",
"path",
")",
... | Return True if path is an existing directory.
Equivalent to "os.path.isdir".
Args:
path (path-like object): Path or URL.
Returns:
bool: True if directory exists. | [
"Return",
"True",
"if",
"path",
"is",
"an",
"existing",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os_path.py#L108-L124 |
Accelize/pycosio | pycosio/_core/functions_os_path.py | relpath | def relpath(path, start=None):
"""
Return a relative file path to path either from the
current directory or from an optional start directory.
For storage objects, "path" and "start" are relative to
storage root.
"/" are not stripped on storage objects path. The ending slash is required
on ... | python | def relpath(path, start=None):
"""
Return a relative file path to path either from the
current directory or from an optional start directory.
For storage objects, "path" and "start" are relative to
storage root.
"/" are not stripped on storage objects path. The ending slash is required
on ... | [
"def",
"relpath",
"(",
"path",
",",
"start",
"=",
"None",
")",
":",
"relative",
"=",
"get_instance",
"(",
"path",
")",
".",
"relpath",
"(",
"path",
")",
"if",
"start",
":",
"# Storage relative path",
"# Replaces \"\\\" by \"/\" for Windows.",
"return",
"os_path_... | Return a relative file path to path either from the
current directory or from an optional start directory.
For storage objects, "path" and "start" are relative to
storage root.
"/" are not stripped on storage objects path. The ending slash is required
on some storage to signify that target is a di... | [
"Return",
"a",
"relative",
"file",
"path",
"to",
"path",
"either",
"from",
"the",
"current",
"directory",
"or",
"from",
"an",
"optional",
"start",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os_path.py#L176-L202 |
Accelize/pycosio | pycosio/_core/functions_os_path.py | samefile | def samefile(path1, path2):
"""
Return True if both pathname arguments refer to the same file or directory.
Equivalent to "os.path.samefile".
Args:
path1 (path-like object): Path or URL.
path2 (path-like object): Path or URL.
Returns:
bool: True if same file or directory.
... | python | def samefile(path1, path2):
"""
Return True if both pathname arguments refer to the same file or directory.
Equivalent to "os.path.samefile".
Args:
path1 (path-like object): Path or URL.
path2 (path-like object): Path or URL.
Returns:
bool: True if same file or directory.
... | [
"def",
"samefile",
"(",
"path1",
",",
"path2",
")",
":",
"# Handles path-like objects and checks if storage",
"path1",
",",
"path1_is_storage",
"=",
"format_and_is_storage",
"(",
"path1",
")",
"path2",
",",
"path2_is_storage",
"=",
"format_and_is_storage",
"(",
"path2",... | Return True if both pathname arguments refer to the same file or directory.
Equivalent to "os.path.samefile".
Args:
path1 (path-like object): Path or URL.
path2 (path-like object): Path or URL.
Returns:
bool: True if same file or directory. | [
"Return",
"True",
"if",
"both",
"pathname",
"arguments",
"refer",
"to",
"the",
"same",
"file",
"or",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os_path.py#L205-L241 |
Accelize/pycosio | pycosio/_core/functions_os_path.py | splitdrive | def splitdrive(path):
"""
Split the path into a pair (drive, tail) where drive is either a
mount point or the empty string. On systems which do not use drive
specifications, drive will always be the empty string.
In all cases, drive + tail will be the same as path.
Equivalent to "os.path.split... | python | def splitdrive(path):
"""
Split the path into a pair (drive, tail) where drive is either a
mount point or the empty string. On systems which do not use drive
specifications, drive will always be the empty string.
In all cases, drive + tail will be the same as path.
Equivalent to "os.path.split... | [
"def",
"splitdrive",
"(",
"path",
")",
":",
"relative",
"=",
"get_instance",
"(",
"path",
")",
".",
"relpath",
"(",
"path",
")",
"drive",
"=",
"path",
".",
"rsplit",
"(",
"relative",
",",
"1",
")",
"[",
"0",
"]",
"if",
"drive",
"and",
"not",
"drive... | Split the path into a pair (drive, tail) where drive is either a
mount point or the empty string. On systems which do not use drive
specifications, drive will always be the empty string.
In all cases, drive + tail will be the same as path.
Equivalent to "os.path.splitdrive".
Args:
path (p... | [
"Split",
"the",
"path",
"into",
"a",
"pair",
"(",
"drive",
"tail",
")",
"where",
"drive",
"is",
"either",
"a",
"mount",
"point",
"or",
"the",
"empty",
"string",
".",
"On",
"systems",
"which",
"do",
"not",
"use",
"drive",
"specifications",
"drive",
"will"... | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os_path.py#L245-L267 |
Accelize/pycosio | pycosio/_core/exceptions.py | handle_os_exceptions | def handle_os_exceptions():
"""
Handles pycosio exceptions and raise standard OS exceptions.
"""
try:
yield
# Convert pycosio exception to equivalent OSError
except ObjectException:
exc_type, exc_value, _ = exc_info()
raise _OS_EXCEPTIONS.get(exc_type, OSError)(exc_value... | python | def handle_os_exceptions():
"""
Handles pycosio exceptions and raise standard OS exceptions.
"""
try:
yield
# Convert pycosio exception to equivalent OSError
except ObjectException:
exc_type, exc_value, _ = exc_info()
raise _OS_EXCEPTIONS.get(exc_type, OSError)(exc_value... | [
"def",
"handle_os_exceptions",
"(",
")",
":",
"try",
":",
"yield",
"# Convert pycosio exception to equivalent OSError",
"except",
"ObjectException",
":",
"exc_type",
",",
"exc_value",
",",
"_",
"=",
"exc_info",
"(",
")",
"raise",
"_OS_EXCEPTIONS",
".",
"get",
"(",
... | Handles pycosio exceptions and raise standard OS exceptions. | [
"Handles",
"pycosio",
"exceptions",
"and",
"raise",
"standard",
"OS",
"exceptions",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/exceptions.py#L36-L56 |
Accelize/pycosio | pycosio/_core/functions_os.py | listdir | def listdir(path='.'):
"""
Return a list containing the names of the entries in the directory given by
path.
Equivalent to "os.listdir".
Args:
path (path-like object): Path or URL.
Returns:
list of str: Entries names.
"""
return [name.rstrip('/') for name, _ in
... | python | def listdir(path='.'):
"""
Return a list containing the names of the entries in the directory given by
path.
Equivalent to "os.listdir".
Args:
path (path-like object): Path or URL.
Returns:
list of str: Entries names.
"""
return [name.rstrip('/') for name, _ in
... | [
"def",
"listdir",
"(",
"path",
"=",
"'.'",
")",
":",
"return",
"[",
"name",
".",
"rstrip",
"(",
"'/'",
")",
"for",
"name",
",",
"_",
"in",
"get_instance",
"(",
"path",
")",
".",
"list_objects",
"(",
"path",
",",
"first_level",
"=",
"True",
")",
"]"... | Return a list containing the names of the entries in the directory given by
path.
Equivalent to "os.listdir".
Args:
path (path-like object): Path or URL.
Returns:
list of str: Entries names. | [
"Return",
"a",
"list",
"containing",
"the",
"names",
"of",
"the",
"entries",
"in",
"the",
"directory",
"given",
"by",
"path",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L20-L34 |
Accelize/pycosio | pycosio/_core/functions_os.py | makedirs | def makedirs(name, mode=0o777, exist_ok=False):
"""
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment
(not just the rightmost) will be created if it does not exist.
Equivalent to "os.makedirs".
Args:
name (path-l... | python | def makedirs(name, mode=0o777, exist_ok=False):
"""
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment
(not just the rightmost) will be created if it does not exist.
Equivalent to "os.makedirs".
Args:
name (path-l... | [
"def",
"makedirs",
"(",
"name",
",",
"mode",
"=",
"0o777",
",",
"exist_ok",
"=",
"False",
")",
":",
"system",
"=",
"get_instance",
"(",
"name",
")",
"# Checks if directory not already exists",
"if",
"not",
"exist_ok",
"and",
"system",
".",
"isdir",
"(",
"sys... | Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment
(not just the rightmost) will be created if it does not exist.
Equivalent to "os.makedirs".
Args:
name (path-like object): Path or URL.
mode (int): The mode param... | [
"Super",
"-",
"mkdir",
";",
"create",
"a",
"leaf",
"directory",
"and",
"all",
"intermediate",
"ones",
".",
"Works",
"like",
"mkdir",
"except",
"that",
"any",
"intermediate",
"path",
"segment",
"(",
"not",
"just",
"the",
"rightmost",
")",
"will",
"be",
"cre... | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L38-L65 |
Accelize/pycosio | pycosio/_core/functions_os.py | mkdir | def mkdir(path, mode=0o777, dir_fd=None):
"""
Create a directory named path with numeric mode mode.
Equivalent to "os.mkdir".
Args:
path (path-like object): Path or URL.
mode (int): The mode parameter is passed to os.mkdir();
see the os.mkdir() description for how it is int... | python | def mkdir(path, mode=0o777, dir_fd=None):
"""
Create a directory named path with numeric mode mode.
Equivalent to "os.mkdir".
Args:
path (path-like object): Path or URL.
mode (int): The mode parameter is passed to os.mkdir();
see the os.mkdir() description for how it is int... | [
"def",
"mkdir",
"(",
"path",
",",
"mode",
"=",
"0o777",
",",
"dir_fd",
"=",
"None",
")",
":",
"system",
"=",
"get_instance",
"(",
"path",
")",
"relative",
"=",
"system",
".",
"relpath",
"(",
"path",
")",
"# Checks if parent directory exists",
"parent_dir",
... | Create a directory named path with numeric mode mode.
Equivalent to "os.mkdir".
Args:
path (path-like object): Path or URL.
mode (int): The mode parameter is passed to os.mkdir();
see the os.mkdir() description for how it is interpreted.
Not supported on cloud storage o... | [
"Create",
"a",
"directory",
"named",
"path",
"with",
"numeric",
"mode",
"mode",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L69-L104 |
Accelize/pycosio | pycosio/_core/functions_os.py | remove | def remove(path, dir_fd=None):
"""
Remove a file.
Equivalent to "os.remove" and "os.unlink".
Args:
path (path-like object): Path or URL.
dir_fd: directory descriptors;
see the os.remove() description for how it is interpreted.
Not supported on cloud storage obje... | python | def remove(path, dir_fd=None):
"""
Remove a file.
Equivalent to "os.remove" and "os.unlink".
Args:
path (path-like object): Path or URL.
dir_fd: directory descriptors;
see the os.remove() description for how it is interpreted.
Not supported on cloud storage obje... | [
"def",
"remove",
"(",
"path",
",",
"dir_fd",
"=",
"None",
")",
":",
"system",
"=",
"get_instance",
"(",
"path",
")",
"# Only support files",
"if",
"system",
".",
"is_locator",
"(",
"path",
")",
"or",
"path",
"[",
"-",
"1",
"]",
"==",
"'/'",
":",
"rai... | Remove a file.
Equivalent to "os.remove" and "os.unlink".
Args:
path (path-like object): Path or URL.
dir_fd: directory descriptors;
see the os.remove() description for how it is interpreted.
Not supported on cloud storage objects. | [
"Remove",
"a",
"file",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L108-L127 |
Accelize/pycosio | pycosio/_core/functions_os.py | rmdir | def rmdir(path, dir_fd=None):
"""
Remove a directory.
Equivalent to "os.rmdir".
Args:
path (path-like object): Path or URL.
dir_fd: directory descriptors;
see the os.rmdir() description for how it is interpreted.
Not supported on cloud storage objects.
"""
... | python | def rmdir(path, dir_fd=None):
"""
Remove a directory.
Equivalent to "os.rmdir".
Args:
path (path-like object): Path or URL.
dir_fd: directory descriptors;
see the os.rmdir() description for how it is interpreted.
Not supported on cloud storage objects.
"""
... | [
"def",
"rmdir",
"(",
"path",
",",
"dir_fd",
"=",
"None",
")",
":",
"system",
"=",
"get_instance",
"(",
"path",
")",
"system",
".",
"remove",
"(",
"system",
".",
"ensure_dir_path",
"(",
"path",
")",
")"
] | Remove a directory.
Equivalent to "os.rmdir".
Args:
path (path-like object): Path or URL.
dir_fd: directory descriptors;
see the os.rmdir() description for how it is interpreted.
Not supported on cloud storage objects. | [
"Remove",
"a",
"directory",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L135-L148 |
Accelize/pycosio | pycosio/_core/functions_os.py | scandir | def scandir(path='.'):
"""
Return an iterator of os.DirEntry objects corresponding to the entries in
the directory given by path. The entries are yielded in arbitrary order,
and the special entries '.' and '..' are not included.
Equivalent to "os.scandir".
Args:
path (path-like object)... | python | def scandir(path='.'):
"""
Return an iterator of os.DirEntry objects corresponding to the entries in
the directory given by path. The entries are yielded in arbitrary order,
and the special entries '.' and '..' are not included.
Equivalent to "os.scandir".
Args:
path (path-like object)... | [
"def",
"scandir",
"(",
"path",
"=",
"'.'",
")",
":",
"# Handles path-like objects",
"scandir_path",
"=",
"fsdecode",
"(",
"path",
")",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"if",
"not",
"is_storage",
"(",
"scandir_path",
")",
":",
"return",
"os_s... | Return an iterator of os.DirEntry objects corresponding to the entries in
the directory given by path. The entries are yielded in arbitrary order,
and the special entries '.' and '..' are not included.
Equivalent to "os.scandir".
Args:
path (path-like object): Path or URL.
If path... | [
"Return",
"an",
"iterator",
"of",
"os",
".",
"DirEntry",
"objects",
"corresponding",
"to",
"the",
"entries",
"in",
"the",
"directory",
"given",
"by",
"path",
".",
"The",
"entries",
"are",
"yielded",
"in",
"arbitrary",
"order",
"and",
"the",
"special",
"entri... | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L374-L400 |
Accelize/pycosio | pycosio/_core/functions_os.py | _scandir_generator | def _scandir_generator(is_bytes, scandir_path, system):
"""
scandir generator
Args:
is_bytes (bool): True if DirEntry must handle path as bytes.
scandir_path (str): Path.
system (pycosio._core.io_system.SystemBase subclass):
Storage system.
Yields:
DirEntry:... | python | def _scandir_generator(is_bytes, scandir_path, system):
"""
scandir generator
Args:
is_bytes (bool): True if DirEntry must handle path as bytes.
scandir_path (str): Path.
system (pycosio._core.io_system.SystemBase subclass):
Storage system.
Yields:
DirEntry:... | [
"def",
"_scandir_generator",
"(",
"is_bytes",
",",
"scandir_path",
",",
"system",
")",
":",
"with",
"handle_os_exceptions",
"(",
")",
":",
"for",
"name",
",",
"header",
"in",
"system",
".",
"list_objects",
"(",
"scandir_path",
",",
"first_level",
"=",
"True",
... | scandir generator
Args:
is_bytes (bool): True if DirEntry must handle path as bytes.
scandir_path (str): Path.
system (pycosio._core.io_system.SystemBase subclass):
Storage system.
Yields:
DirEntry: Directory entries | [
"scandir",
"generator"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L403-L420 |
Accelize/pycosio | pycosio/_core/functions_os.py | DirEntry.name | def name(self):
"""
The entry’s base filename, relative to the scandir() path argument.
Returns:
str: name.
"""
name = self._name.rstrip('/')
if self._bytes_path:
name = fsencode(name)
return name | python | def name(self):
"""
The entry’s base filename, relative to the scandir() path argument.
Returns:
str: name.
"""
name = self._name.rstrip('/')
if self._bytes_path:
name = fsencode(name)
return name | [
"def",
"name",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"_name",
".",
"rstrip",
"(",
"'/'",
")",
"if",
"self",
".",
"_bytes_path",
":",
"name",
"=",
"fsencode",
"(",
"name",
")",
"return",
"name"
] | The entry’s base filename, relative to the scandir() path argument.
Returns:
str: name. | [
"The",
"entry’s",
"base",
"filename",
"relative",
"to",
"the",
"scandir",
"()",
"path",
"argument",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L249-L259 |
Accelize/pycosio | pycosio/_core/functions_os.py | DirEntry.path | def path(self):
"""
The entry’s full path name:
equivalent to os.path.join(scandir_path, entry.name)
where scandir_path is the scandir() path argument.
The path is only absolute if the scandir() path argument was absolute.
Returns:
str: name.
"""
... | python | def path(self):
"""
The entry’s full path name:
equivalent to os.path.join(scandir_path, entry.name)
where scandir_path is the scandir() path argument.
The path is only absolute if the scandir() path argument was absolute.
Returns:
str: name.
"""
... | [
"def",
"path",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"_path",
".",
"rstrip",
"(",
"'/'",
")",
"if",
"self",
".",
"_bytes_path",
":",
"path",
"=",
"fsencode",
"(",
"path",
")",
"return",
"path"
] | The entry’s full path name:
equivalent to os.path.join(scandir_path, entry.name)
where scandir_path is the scandir() path argument.
The path is only absolute if the scandir() path argument was absolute.
Returns:
str: name. | [
"The",
"entry’s",
"full",
"path",
"name",
":",
"equivalent",
"to",
"os",
".",
"path",
".",
"join",
"(",
"scandir_path",
"entry",
".",
"name",
")",
"where",
"scandir_path",
"is",
"the",
"scandir",
"()",
"path",
"argument",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L263-L277 |
Accelize/pycosio | pycosio/_core/functions_os.py | DirEntry.is_dir | def is_dir(self, follow_symlinks=True):
"""
Return True if this entry is a directory or a symbolic link pointing to
a directory; return False if the entry is or points to any other kind
of file, or if it doesn’t exist anymore.
The result is cached on the os.DirEntry object.
... | python | def is_dir(self, follow_symlinks=True):
"""
Return True if this entry is a directory or a symbolic link pointing to
a directory; return False if the entry is or points to any other kind
of file, or if it doesn’t exist anymore.
The result is cached on the os.DirEntry object.
... | [
"def",
"is_dir",
"(",
"self",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"try",
":",
"return",
"(",
"self",
".",
"_system",
".",
"isdir",
"(",
"path",
"=",
"self",
".",
"_path",
",",
"client_kwargs",
"=",
"self",
".",
"_client_kwargs",
",",
"virtua... | Return True if this entry is a directory or a symbolic link pointing to
a directory; return False if the entry is or points to any other kind
of file, or if it doesn’t exist anymore.
The result is cached on the os.DirEntry object.
Args:
follow_symlinks (bool): Follow symlin... | [
"Return",
"True",
"if",
"this",
"entry",
"is",
"a",
"directory",
"or",
"a",
"symbolic",
"link",
"pointing",
"to",
"a",
"directory",
";",
"return",
"False",
"if",
"the",
"entry",
"is",
"or",
"points",
"to",
"any",
"other",
"kind",
"of",
"file",
"or",
"i... | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L292-L319 |
Accelize/pycosio | pycosio/_core/functions_os.py | DirEntry.is_file | def is_file(self, follow_symlinks=True):
"""
Return True if this entry is a file or a symbolic link pointing to a
file; return False if the entry is or points to a directory or other
non-file entry, or if it doesn’t exist anymore.
The result is cached on the os.DirEntry object.
... | python | def is_file(self, follow_symlinks=True):
"""
Return True if this entry is a file or a symbolic link pointing to a
file; return False if the entry is or points to a directory or other
non-file entry, or if it doesn’t exist anymore.
The result is cached on the os.DirEntry object.
... | [
"def",
"is_file",
"(",
"self",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"return",
"self",
".",
"_system",
".",
"isfile",
"(",
"path",
"=",
"self",
".",
"_path",
",",
"client_kwargs",
"=",
"self",
".",
"_client_kwargs",
")"
] | Return True if this entry is a file or a symbolic link pointing to a
file; return False if the entry is or points to a directory or other
non-file entry, or if it doesn’t exist anymore.
The result is cached on the os.DirEntry object.
Args:
follow_symlinks (bool): Follow sym... | [
"Return",
"True",
"if",
"this",
"entry",
"is",
"a",
"file",
"or",
"a",
"symbolic",
"link",
"pointing",
"to",
"a",
"file",
";",
"return",
"False",
"if",
"the",
"entry",
"is",
"or",
"points",
"to",
"a",
"directory",
"or",
"other",
"non",
"-",
"file",
"... | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L322-L338 |
Accelize/pycosio | pycosio/_core/functions_os.py | DirEntry.stat | def stat(self, follow_symlinks=True):
"""
Return a stat_result object for this entry.
The result is cached on the os.DirEntry object.
Args:
follow_symlinks (bool): Follow symlinks.
Not supported on cloud storage objects.
Returns:
os.stat... | python | def stat(self, follow_symlinks=True):
"""
Return a stat_result object for this entry.
The result is cached on the os.DirEntry object.
Args:
follow_symlinks (bool): Follow symlinks.
Not supported on cloud storage objects.
Returns:
os.stat... | [
"def",
"stat",
"(",
"self",
",",
"follow_symlinks",
"=",
"True",
")",
":",
"return",
"self",
".",
"_system",
".",
"stat",
"(",
"path",
"=",
"self",
".",
"_path",
",",
"client_kwargs",
"=",
"self",
".",
"_client_kwargs",
",",
"header",
"=",
"self",
".",... | Return a stat_result object for this entry.
The result is cached on the os.DirEntry object.
Args:
follow_symlinks (bool): Follow symlinks.
Not supported on cloud storage objects.
Returns:
os.stat_result: Stat result object | [
"Return",
"a",
"stat_result",
"object",
"for",
"this",
"entry",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/functions_os.py#L353-L368 |
Accelize/pycosio | pycosio/_core/io_base_buffered.py | ObjectBufferedIOBase.close | def close(self):
"""
Flush the write buffers of the stream if applicable and
close the object.
"""
if self._writable and not self._closed:
self._closed = True
with self._seek_lock:
self._flush_raw_or_buffered()
if self._seek:
... | python | def close(self):
"""
Flush the write buffers of the stream if applicable and
close the object.
"""
if self._writable and not self._closed:
self._closed = True
with self._seek_lock:
self._flush_raw_or_buffered()
if self._seek:
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_writable",
"and",
"not",
"self",
".",
"_closed",
":",
"self",
".",
"_closed",
"=",
"True",
"with",
"self",
".",
"_seek_lock",
":",
"self",
".",
"_flush_raw_or_buffered",
"(",
")",
"if",
"self"... | Flush the write buffers of the stream if applicable and
close the object. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"if",
"applicable",
"and",
"close",
"the",
"object",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L120-L131 |
Accelize/pycosio | pycosio/_core/io_base_buffered.py | ObjectBufferedIOBase.flush | def flush(self):
"""
Flush the write buffers of the stream if applicable.
"""
if self._writable:
with self._seek_lock:
self._flush_raw_or_buffered()
# Clear the buffer
self._write_buffer = bytearray(self._buffer_size)
... | python | def flush(self):
"""
Flush the write buffers of the stream if applicable.
"""
if self._writable:
with self._seek_lock:
self._flush_raw_or_buffered()
# Clear the buffer
self._write_buffer = bytearray(self._buffer_size)
... | [
"def",
"flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"_writable",
":",
"with",
"self",
".",
"_seek_lock",
":",
"self",
".",
"_flush_raw_or_buffered",
"(",
")",
"# Clear the buffer",
"self",
".",
"_write_buffer",
"=",
"bytearray",
"(",
"self",
".",
"_b... | Flush the write buffers of the stream if applicable. | [
"Flush",
"the",
"write",
"buffers",
"of",
"the",
"stream",
"if",
"applicable",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L144-L154 |
Accelize/pycosio | pycosio/_core/io_base_buffered.py | ObjectBufferedIOBase._flush_raw_or_buffered | def _flush_raw_or_buffered(self):
"""
Flush using raw of buffered methods.
"""
# Flush only if bytes written
# This avoid no required process/thread
# creation and network call.
# This step is performed by raw stream.
if self._buffer_seek and self._seek:
... | python | def _flush_raw_or_buffered(self):
"""
Flush using raw of buffered methods.
"""
# Flush only if bytes written
# This avoid no required process/thread
# creation and network call.
# This step is performed by raw stream.
if self._buffer_seek and self._seek:
... | [
"def",
"_flush_raw_or_buffered",
"(",
"self",
")",
":",
"# Flush only if bytes written",
"# This avoid no required process/thread",
"# creation and network call.",
"# This step is performed by raw stream.",
"if",
"self",
".",
"_buffer_seek",
"and",
"self",
".",
"_seek",
":",
"s... | Flush using raw of buffered methods. | [
"Flush",
"using",
"raw",
"of",
"buffered",
"methods",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L156-L174 |
Accelize/pycosio | pycosio/_core/io_base_buffered.py | ObjectBufferedIOBase.peek | def peek(self, size=-1):
"""
Return bytes from the stream without advancing the position.
Args:
size (int): Number of bytes to read. -1 to read the full
stream.
Returns:
bytes: bytes read
"""
if not self._readable:
rai... | python | def peek(self, size=-1):
"""
Return bytes from the stream without advancing the position.
Args:
size (int): Number of bytes to read. -1 to read the full
stream.
Returns:
bytes: bytes read
"""
if not self._readable:
rai... | [
"def",
"peek",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"not",
"self",
".",
"_readable",
":",
"raise",
"UnsupportedOperation",
"(",
"'read'",
")",
"with",
"self",
".",
"_seek_lock",
":",
"self",
".",
"_raw",
".",
"seek",
"(",
"self",
... | Return bytes from the stream without advancing the position.
Args:
size (int): Number of bytes to read. -1 to read the full
stream.
Returns:
bytes: bytes read | [
"Return",
"bytes",
"from",
"the",
"stream",
"without",
"advancing",
"the",
"position",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L194-L210 |
Accelize/pycosio | pycosio/_core/io_base_buffered.py | ObjectBufferedIOBase._preload_range | def _preload_range(self):
"""Preload data for reading"""
queue = self._read_queue
size = self._buffer_size
start = self._seek
end = int(start + size * self._max_buffers)
workers_submit = self._workers.submit
indexes = tuple(range(start, end, size))
# Drop... | python | def _preload_range(self):
"""Preload data for reading"""
queue = self._read_queue
size = self._buffer_size
start = self._seek
end = int(start + size * self._max_buffers)
workers_submit = self._workers.submit
indexes = tuple(range(start, end, size))
# Drop... | [
"def",
"_preload_range",
"(",
"self",
")",
":",
"queue",
"=",
"self",
".",
"_read_queue",
"size",
"=",
"self",
".",
"_buffer_size",
"start",
"=",
"self",
".",
"_seek",
"end",
"=",
"int",
"(",
"start",
"+",
"size",
"*",
"self",
".",
"_max_buffers",
")",... | Preload data for reading | [
"Preload",
"data",
"for",
"reading"
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L212-L230 |
Accelize/pycosio | pycosio/_core/io_base_buffered.py | ObjectBufferedIOBase.read | def read(self, size=-1):
"""
Read and return up to size bytes,
with at most one call to the underlying raw stream’s.
Use at most one call to the underlying raw stream’s read method.
Args:
size (int): Number of bytes to read. -1 to read the
stream unt... | python | def read(self, size=-1):
"""
Read and return up to size bytes,
with at most one call to the underlying raw stream’s.
Use at most one call to the underlying raw stream’s read method.
Args:
size (int): Number of bytes to read. -1 to read the
stream unt... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"not",
"self",
".",
"_readable",
":",
"raise",
"UnsupportedOperation",
"(",
"'read'",
")",
"# Checks if EOF",
"if",
"self",
".",
"_seek",
"==",
"self",
".",
"_size",
":",
"return",... | Read and return up to size bytes,
with at most one call to the underlying raw stream’s.
Use at most one call to the underlying raw stream’s read method.
Args:
size (int): Number of bytes to read. -1 to read the
stream until end.
Returns:
bytes: ... | [
"Read",
"and",
"return",
"up",
"to",
"size",
"bytes",
"with",
"at",
"most",
"one",
"call",
"to",
"the",
"underlying",
"raw",
"stream’s",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L242-L298 |
Accelize/pycosio | pycosio/_core/io_base_buffered.py | ObjectBufferedIOBase.readinto | def readinto(self, b):
"""
Read bytes into a pre-allocated, writable bytes-like object b,
and return the number of bytes read.
Args:
b (bytes-like object): buffer.
Returns:
int: number of bytes read
"""
if not self._readable:
... | python | def readinto(self, b):
"""
Read bytes into a pre-allocated, writable bytes-like object b,
and return the number of bytes read.
Args:
b (bytes-like object): buffer.
Returns:
int: number of bytes read
"""
if not self._readable:
... | [
"def",
"readinto",
"(",
"self",
",",
"b",
")",
":",
"if",
"not",
"self",
".",
"_readable",
":",
"raise",
"UnsupportedOperation",
"(",
"'read'",
")",
"with",
"self",
".",
"_seek_lock",
":",
"# Gets seek",
"seek",
"=",
"self",
".",
"_seek",
"# Initializes qu... | Read bytes into a pre-allocated, writable bytes-like object b,
and return the number of bytes read.
Args:
b (bytes-like object): buffer.
Returns:
int: number of bytes read | [
"Read",
"bytes",
"into",
"a",
"pre",
"-",
"allocated",
"writable",
"bytes",
"-",
"like",
"object",
"b",
"and",
"return",
"the",
"number",
"of",
"bytes",
"read",
"."
] | train | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/_core/io_base_buffered.py#L316-L422 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.