repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/productmilestones_api.py | ProductmilestonesApi.get_distributed_builds | def get_distributed_builds(self, id, **kwargs):
"""
Gets the set of builds which produced artifacts distributed/shipped in a Product Milestone
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
... | python | def get_distributed_builds(self, id, **kwargs):
"""
Gets the set of builds which produced artifacts distributed/shipped in a Product Milestone
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
... | [
"def",
"get_distributed_builds",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"get_distributed_builds_w... | Gets the set of builds which produced artifacts distributed/shipped in a Product Milestone
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callba... | [
"Gets",
"the",
"set",
"of",
"builds",
"which",
"produced",
"artifacts",
"distributed",
"/",
"shipped",
"in",
"a",
"Product",
"Milestone",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous"... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/productmilestones_api.py#L830-L858 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/productmilestones_api.py | ProductmilestonesApi.get_performed_builds | def get_performed_builds(self, id, **kwargs):
"""
Gets the set of builds performed during in a Product Milestone cycle
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when re... | python | def get_performed_builds(self, id, **kwargs):
"""
Gets the set of builds performed during in a Product Milestone cycle
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when re... | [
"def",
"get_performed_builds",
"(",
"self",
",",
"id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
".",
"get_performed_builds_with_... | Gets the set of builds performed during in a Product Milestone cycle
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):... | [
"Gets",
"the",
"set",
"of",
"builds",
"performed",
"during",
"in",
"a",
"Product",
"Milestone",
"cycle",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/productmilestones_api.py#L1058-L1086 |
project-ncl/pnc-cli | pnc_cli/swagger_client/apis/productmilestones_api.py | ProductmilestonesApi.remove_distributed_artifact | def remove_distributed_artifact(self, id, artifact_id, **kwargs):
"""
Removes an artifact from the specified product milestone
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked... | python | def remove_distributed_artifact(self, id, artifact_id, **kwargs):
"""
Removes an artifact from the specified product milestone
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked... | [
"def",
"remove_distributed_artifact",
"(",
"self",
",",
"id",
",",
"artifact_id",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'callback'",
")",
":",
"return",
"self",
"."... | Removes an artifact from the specified product milestone
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>>... | [
"Removes",
"an",
"artifact",
"from",
"the",
"specified",
"product",
"milestone",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"define",
"a",
"callback",
... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/apis/productmilestones_api.py#L1286-L1311 |
cosven/feeluown-core | fuocore/xiami/models.py | XUserModel.playlists | def playlists(self):
"""获取用户创建的歌单
如果不是用户本人,则不能获取用户默认精选集
"""
if self._playlists is None:
playlists_data = self._api.user_playlists(self.identifier)
playlists = []
for playlist_data in playlists_data:
playlist = _deserialize(playlist_dat... | python | def playlists(self):
"""获取用户创建的歌单
如果不是用户本人,则不能获取用户默认精选集
"""
if self._playlists is None:
playlists_data = self._api.user_playlists(self.identifier)
playlists = []
for playlist_data in playlists_data:
playlist = _deserialize(playlist_dat... | [
"def",
"playlists",
"(",
"self",
")",
":",
"if",
"self",
".",
"_playlists",
"is",
"None",
":",
"playlists_data",
"=",
"self",
".",
"_api",
".",
"user_playlists",
"(",
"self",
".",
"identifier",
")",
"playlists",
"=",
"[",
"]",
"for",
"playlist_data",
"in... | 获取用户创建的歌单
如果不是用户本人,则不能获取用户默认精选集 | [
"获取用户创建的歌单"
] | train | https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/xiami/models.py#L157-L169 |
cosven/feeluown-core | fuocore/xiami/models.py | XUserModel.fav_songs | def fav_songs(self):
"""
FIXME: 支持获取所有的收藏歌曲
"""
if self._fav_songs is None:
songs_data = self._api.user_favorite_songs(self.identifier)
self._fav_songs = []
if not songs_data:
return
for song_data in songs_data:
... | python | def fav_songs(self):
"""
FIXME: 支持获取所有的收藏歌曲
"""
if self._fav_songs is None:
songs_data = self._api.user_favorite_songs(self.identifier)
self._fav_songs = []
if not songs_data:
return
for song_data in songs_data:
... | [
"def",
"fav_songs",
"(",
"self",
")",
":",
"if",
"self",
".",
"_fav_songs",
"is",
"None",
":",
"songs_data",
"=",
"self",
".",
"_api",
".",
"user_favorite_songs",
"(",
"self",
".",
"identifier",
")",
"self",
".",
"_fav_songs",
"=",
"[",
"]",
"if",
"not... | FIXME: 支持获取所有的收藏歌曲 | [
"FIXME",
":",
"支持获取所有的收藏歌曲"
] | train | https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/xiami/models.py#L191-L203 |
kurtraschke/pyRFC3339 | pyrfc3339/parser.py | parse | def parse(timestamp, utc=False, produce_naive=False):
'''
Parse an :RFC:`3339`-formatted timestamp and return a
`datetime.datetime`.
If the timestamp is presented in UTC, then the `tzinfo` parameter of the
returned `datetime` will be set to `pytz.utc`.
>>> parse('2009-01-01T10:01:02Z')
dat... | python | def parse(timestamp, utc=False, produce_naive=False):
'''
Parse an :RFC:`3339`-formatted timestamp and return a
`datetime.datetime`.
If the timestamp is presented in UTC, then the `tzinfo` parameter of the
returned `datetime` will be set to `pytz.utc`.
>>> parse('2009-01-01T10:01:02Z')
dat... | [
"def",
"parse",
"(",
"timestamp",
",",
"utc",
"=",
"False",
",",
"produce_naive",
"=",
"False",
")",
":",
"parse_re",
"=",
"re",
".",
"compile",
"(",
"r'''^(?:(?:(?P<date_fullyear>[0-9]{4})\\-(?P<date_month>[0-9]{2})\\-(?P<date_mday>[0-9]{2}))T(?:(?:(?P<time_hour>[0-9]{2})\\:... | Parse an :RFC:`3339`-formatted timestamp and return a
`datetime.datetime`.
If the timestamp is presented in UTC, then the `tzinfo` parameter of the
returned `datetime` will be set to `pytz.utc`.
>>> parse('2009-01-01T10:01:02Z')
datetime.datetime(2009, 1, 1, 10, 1, 2, tzinfo=<UTC>)
Otherwise,... | [
"Parse",
"an",
":",
"RFC",
":",
"3339",
"-",
"formatted",
"timestamp",
"and",
"return",
"a",
"datetime",
".",
"datetime",
"."
] | train | https://github.com/kurtraschke/pyRFC3339/blob/e30cc1555adce0ecc7bd65509a2249d47e5a41b4/pyrfc3339/parser.py#L9-L87 |
cosven/feeluown-core | fuocore/local/provider.py | add_song | def add_song(fpath, g_songs, g_artists, g_albums):
"""
parse music file metadata with Easymp3 and return a song
model.
"""
try:
if fpath.endswith('mp3') or fpath.endswith('ogg') or fpath.endswith('wma'):
metadata = EasyMP3(fpath)
elif fpath.endswith('m4a'):
me... | python | def add_song(fpath, g_songs, g_artists, g_albums):
"""
parse music file metadata with Easymp3 and return a song
model.
"""
try:
if fpath.endswith('mp3') or fpath.endswith('ogg') or fpath.endswith('wma'):
metadata = EasyMP3(fpath)
elif fpath.endswith('m4a'):
me... | [
"def",
"add_song",
"(",
"fpath",
",",
"g_songs",
",",
"g_artists",
",",
"g_albums",
")",
":",
"try",
":",
"if",
"fpath",
".",
"endswith",
"(",
"'mp3'",
")",
"or",
"fpath",
".",
"endswith",
"(",
"'ogg'",
")",
"or",
"fpath",
".",
"endswith",
"(",
"'wma... | parse music file metadata with Easymp3 and return a song
model. | [
"parse",
"music",
"file",
"metadata",
"with",
"Easymp3",
"and",
"return",
"a",
"song",
"model",
"."
] | train | https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/local/provider.py#L67-L170 |
cosven/feeluown-core | fuocore/local/provider.py | Library.scan | def scan(self, paths=None, depth=2):
"""scan media files in all paths
"""
song_exts = ['mp3', 'ogg', 'wma', 'm4a']
exts = song_exts
paths = paths or [Library.DEFAULT_MUSIC_FOLDER]
depth = depth if depth <= 3 else 3
media_files = []
for directory in paths:
... | python | def scan(self, paths=None, depth=2):
"""scan media files in all paths
"""
song_exts = ['mp3', 'ogg', 'wma', 'm4a']
exts = song_exts
paths = paths or [Library.DEFAULT_MUSIC_FOLDER]
depth = depth if depth <= 3 else 3
media_files = []
for directory in paths:
... | [
"def",
"scan",
"(",
"self",
",",
"paths",
"=",
"None",
",",
"depth",
"=",
"2",
")",
":",
"song_exts",
"=",
"[",
"'mp3'",
",",
"'ogg'",
",",
"'wma'",
",",
"'m4a'",
"]",
"exts",
"=",
"song_exts",
"paths",
"=",
"paths",
"or",
"[",
"Library",
".",
"D... | scan media files in all paths | [
"scan",
"media",
"files",
"in",
"all",
"paths"
] | train | https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/local/provider.py#L194-L209 |
SmartTeleMax/iktomi | iktomi/web/core.py | cases.cases | def cases(self, env, data):
'''Calls each nested handler until one of them returns nonzero result.
If any handler returns `None`, it is interpreted as
"request does not match, the handler has nothing to do with it and
`web.cases` should try to call the next handler".'''
for ha... | python | def cases(self, env, data):
'''Calls each nested handler until one of them returns nonzero result.
If any handler returns `None`, it is interpreted as
"request does not match, the handler has nothing to do with it and
`web.cases` should try to call the next handler".'''
for ha... | [
"def",
"cases",
"(",
"self",
",",
"env",
",",
"data",
")",
":",
"for",
"handler",
"in",
"self",
".",
"handlers",
":",
"env",
".",
"_push",
"(",
")",
"data",
".",
"_push",
"(",
")",
"try",
":",
"result",
"=",
"handler",
"(",
"env",
",",
"data",
... | Calls each nested handler until one of them returns nonzero result.
If any handler returns `None`, it is interpreted as
"request does not match, the handler has nothing to do with it and
`web.cases` should try to call the next handler". | [
"Calls",
"each",
"nested",
"handler",
"until",
"one",
"of",
"them",
"returns",
"nonzero",
"result",
"."
] | train | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/web/core.py#L123-L138 |
mithro/python-datetime-tz | datetime_tz/update_win32tz_map.py | create_win32tz_map | def create_win32tz_map(windows_zones_xml):
"""Creates a map between Windows and Olson timezone names.
Args:
windows_zones_xml: The CLDR XML mapping.
Yields:
(win32_name, olson_name, comment)
"""
coming_comment = None
win32_name = None
territory = None
parser = genshi.input.XMLParser(StringIO(w... | python | def create_win32tz_map(windows_zones_xml):
"""Creates a map between Windows and Olson timezone names.
Args:
windows_zones_xml: The CLDR XML mapping.
Yields:
(win32_name, olson_name, comment)
"""
coming_comment = None
win32_name = None
territory = None
parser = genshi.input.XMLParser(StringIO(w... | [
"def",
"create_win32tz_map",
"(",
"windows_zones_xml",
")",
":",
"coming_comment",
"=",
"None",
"win32_name",
"=",
"None",
"territory",
"=",
"None",
"parser",
"=",
"genshi",
".",
"input",
".",
"XMLParser",
"(",
"StringIO",
"(",
"windows_zones_xml",
")",
")",
"... | Creates a map between Windows and Olson timezone names.
Args:
windows_zones_xml: The CLDR XML mapping.
Yields:
(win32_name, olson_name, comment) | [
"Creates",
"a",
"map",
"between",
"Windows",
"and",
"Olson",
"timezone",
"names",
"."
] | train | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/update_win32tz_map.py#L57-L92 |
mithro/python-datetime-tz | datetime_tz/update_win32tz_map.py | update_stored_win32tz_map | def update_stored_win32tz_map():
"""Downloads the cldr win32 timezone map and stores it in win32tz_map.py."""
windows_zones_xml = download_cldr_win32tz_map_xml()
source_hash = hashlib.md5(windows_zones_xml).hexdigest()
if hasattr(windows_zones_xml, "decode"):
windows_zones_xml = windows_zones_xml.decode("u... | python | def update_stored_win32tz_map():
"""Downloads the cldr win32 timezone map and stores it in win32tz_map.py."""
windows_zones_xml = download_cldr_win32tz_map_xml()
source_hash = hashlib.md5(windows_zones_xml).hexdigest()
if hasattr(windows_zones_xml, "decode"):
windows_zones_xml = windows_zones_xml.decode("u... | [
"def",
"update_stored_win32tz_map",
"(",
")",
":",
"windows_zones_xml",
"=",
"download_cldr_win32tz_map_xml",
"(",
")",
"source_hash",
"=",
"hashlib",
".",
"md5",
"(",
"windows_zones_xml",
")",
".",
"hexdigest",
"(",
")",
"if",
"hasattr",
"(",
"windows_zones_xml",
... | Downloads the cldr win32 timezone map and stores it in win32tz_map.py. | [
"Downloads",
"the",
"cldr",
"win32",
"timezone",
"map",
"and",
"stores",
"it",
"in",
"win32tz_map",
".",
"py",
"."
] | train | https://github.com/mithro/python-datetime-tz/blob/3c682d003f8b28e39f0c096773e471aeb68e6bbb/datetime_tz/update_win32tz_map.py#L95-L134 |
andreafioraldi/angrdbg | angrdbg/page_7.py | DbgPage.load_mo | def load_mo(self, state, page_idx):
"""
Loads a memory object from memory.
:param page_idx: the index into the page
:returns: a tuple of the object
"""
mo = self._storage[page_idx - self._page_addr]
#print filter(lambda x: x != None, self._storage)
if mo i... | python | def load_mo(self, state, page_idx):
"""
Loads a memory object from memory.
:param page_idx: the index into the page
:returns: a tuple of the object
"""
mo = self._storage[page_idx - self._page_addr]
#print filter(lambda x: x != None, self._storage)
if mo i... | [
"def",
"load_mo",
"(",
"self",
",",
"state",
",",
"page_idx",
")",
":",
"mo",
"=",
"self",
".",
"_storage",
"[",
"page_idx",
"-",
"self",
".",
"_page_addr",
"]",
"#print filter(lambda x: x != None, self._storage)",
"if",
"mo",
"is",
"None",
"and",
"hasattr",
... | Loads a memory object from memory.
:param page_idx: the index into the page
:returns: a tuple of the object | [
"Loads",
"a",
"memory",
"object",
"from",
"memory",
".",
":",
"param",
"page_idx",
":",
"the",
"index",
"into",
"the",
"page",
":",
"returns",
":",
"a",
"tuple",
"of",
"the",
"object"
] | train | https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/page_7.py#L78-L90 |
andreafioraldi/angrdbg | angrdbg/page_7.py | DbgPage.load_slice | def load_slice(self, state, start, end):
"""
Return the memory objects overlapping with the provided slice.
:param start: the start address
:param end: the end address (non-inclusive)
:returns: tuples of (starting_addr, memory_object)
"""
items = []
if sta... | python | def load_slice(self, state, start, end):
"""
Return the memory objects overlapping with the provided slice.
:param start: the start address
:param end: the end address (non-inclusive)
:returns: tuples of (starting_addr, memory_object)
"""
items = []
if sta... | [
"def",
"load_slice",
"(",
"self",
",",
"state",
",",
"start",
",",
"end",
")",
":",
"items",
"=",
"[",
"]",
"if",
"start",
">",
"self",
".",
"_page_addr",
"+",
"self",
".",
"_page_size",
"or",
"end",
"<",
"self",
".",
"_page_addr",
":",
"l",
".",
... | Return the memory objects overlapping with the provided slice.
:param start: the start address
:param end: the end address (non-inclusive)
:returns: tuples of (starting_addr, memory_object) | [
"Return",
"the",
"memory",
"objects",
"overlapping",
"with",
"the",
"provided",
"slice",
".",
":",
"param",
"start",
":",
"the",
"start",
"address",
":",
"param",
"end",
":",
"the",
"end",
"address",
"(",
"non",
"-",
"inclusive",
")",
":",
"returns",
":"... | train | https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/page_7.py#L92-L115 |
andreafioraldi/angrdbg | angrdbg/page_7.py | SimDbgMemory.load_objects | def load_objects(self, addr, num_bytes, ret_on_segv=False):
"""
Load memory objects from paged memory.
:param addr: Address to start loading.
:param num_bytes: Number of bytes to load.
:param bool ret_on_segv: True if you want load_bytes to return directly when a SIGSEV is trigg... | python | def load_objects(self, addr, num_bytes, ret_on_segv=False):
"""
Load memory objects from paged memory.
:param addr: Address to start loading.
:param num_bytes: Number of bytes to load.
:param bool ret_on_segv: True if you want load_bytes to return directly when a SIGSEV is trigg... | [
"def",
"load_objects",
"(",
"self",
",",
"addr",
",",
"num_bytes",
",",
"ret_on_segv",
"=",
"False",
")",
":",
"result",
"=",
"[",
"]",
"end",
"=",
"addr",
"+",
"num_bytes",
"for",
"page_addr",
"in",
"self",
".",
"_containing_pages",
"(",
"addr",
",",
... | Load memory objects from paged memory.
:param addr: Address to start loading.
:param num_bytes: Number of bytes to load.
:param bool ret_on_segv: True if you want load_bytes to return directly when a SIGSEV is triggered, otherwise
a SimSegfaultError will be rais... | [
"Load",
"memory",
"objects",
"from",
"paged",
"memory",
"."
] | train | https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/page_7.py#L247-L284 |
andreafioraldi/angrdbg | angrdbg/page_7.py | SimDbgMemory.memory_objects_for_name | def memory_objects_for_name(self, n):
"""
Returns a set of :class:`SimMemoryObjects` that contain expressions that contain a variable with the name of
`n`.
This is useful for replacing those values in one fell swoop with :func:`replace_memory_object()`, even if
they have been pa... | python | def memory_objects_for_name(self, n):
"""
Returns a set of :class:`SimMemoryObjects` that contain expressions that contain a variable with the name of
`n`.
This is useful for replacing those values in one fell swoop with :func:`replace_memory_object()`, even if
they have been pa... | [
"def",
"memory_objects_for_name",
"(",
"self",
",",
"n",
")",
":",
"return",
"set",
"(",
"[",
"self",
"[",
"i",
"]",
"for",
"i",
"in",
"self",
".",
"addrs_for_name",
"(",
"n",
")",
"]",
")"
] | Returns a set of :class:`SimMemoryObjects` that contain expressions that contain a variable with the name of
`n`.
This is useful for replacing those values in one fell swoop with :func:`replace_memory_object()`, even if
they have been partially overwritten. | [
"Returns",
"a",
"set",
"of",
":",
"class",
":",
"SimMemoryObjects",
"that",
"contain",
"expressions",
"that",
"contain",
"a",
"variable",
"with",
"the",
"name",
"of",
"n",
"."
] | train | https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/page_7.py#L858-L866 |
andreafioraldi/angrdbg | angrdbg/page_7.py | SimDbgMemory.memory_objects_for_hash | def memory_objects_for_hash(self, n):
"""
Returns a set of :class:`SimMemoryObjects` that contain expressions that contain a variable with the hash
`h`.
"""
return set([self[i] for i in self.addrs_for_hash(n)]) | python | def memory_objects_for_hash(self, n):
"""
Returns a set of :class:`SimMemoryObjects` that contain expressions that contain a variable with the hash
`h`.
"""
return set([self[i] for i in self.addrs_for_hash(n)]) | [
"def",
"memory_objects_for_hash",
"(",
"self",
",",
"n",
")",
":",
"return",
"set",
"(",
"[",
"self",
"[",
"i",
"]",
"for",
"i",
"in",
"self",
".",
"addrs_for_hash",
"(",
"n",
")",
"]",
")"
] | Returns a set of :class:`SimMemoryObjects` that contain expressions that contain a variable with the hash
`h`. | [
"Returns",
"a",
"set",
"of",
":",
"class",
":",
"SimMemoryObjects",
"that",
"contain",
"expressions",
"that",
"contain",
"a",
"variable",
"with",
"the",
"hash",
"h",
"."
] | train | https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/page_7.py#L868-L873 |
andreafioraldi/angrdbg | angrdbg/page_7.py | SimDbgMemory.permissions | def permissions(self, addr, permissions=None):
"""
Returns the permissions for a page at address `addr`.
If optional argument permissions is given, set page permissions to that prior to returning permissions.
"""
if self.state.solver.symbolic(addr):
raise SimMemoryE... | python | def permissions(self, addr, permissions=None):
"""
Returns the permissions for a page at address `addr`.
If optional argument permissions is given, set page permissions to that prior to returning permissions.
"""
if self.state.solver.symbolic(addr):
raise SimMemoryE... | [
"def",
"permissions",
"(",
"self",
",",
"addr",
",",
"permissions",
"=",
"None",
")",
":",
"if",
"self",
".",
"state",
".",
"solver",
".",
"symbolic",
"(",
"addr",
")",
":",
"raise",
"SimMemoryError",
"(",
"\"page permissions cannot currently be looked up for sy... | Returns the permissions for a page at address `addr`.
If optional argument permissions is given, set page permissions to that prior to returning permissions. | [
"Returns",
"the",
"permissions",
"for",
"a",
"page",
"at",
"address",
"addr",
"."
] | train | https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/page_7.py#L875-L908 |
CivicSpleen/ambry | ambry/bundle/process.py | call_interval | def call_interval(freq, **kwargs):
"""Decorator for the CallInterval wrapper"""
def wrapper(f):
return CallInterval(f, freq, **kwargs)
return wrapper | python | def call_interval(freq, **kwargs):
"""Decorator for the CallInterval wrapper"""
def wrapper(f):
return CallInterval(f, freq, **kwargs)
return wrapper | [
"def",
"call_interval",
"(",
"freq",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"return",
"CallInterval",
"(",
"f",
",",
"freq",
",",
"*",
"*",
"kwargs",
")",
"return",
"wrapper"
] | Decorator for the CallInterval wrapper | [
"Decorator",
"for",
"the",
"CallInterval",
"wrapper"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L431-L436 |
CivicSpleen/ambry | ambry/bundle/process.py | ProgressSection.add | def add(self, *args, **kwargs):
"""Add a new record to the section"""
if self.start and self.start.state == 'done' and kwargs.get('log_action') != 'done':
raise ProgressLoggingError("Can't add -- process section is done")
self.augment_args(args, kwargs)
kwargs['log_action'... | python | def add(self, *args, **kwargs):
"""Add a new record to the section"""
if self.start and self.start.state == 'done' and kwargs.get('log_action') != 'done':
raise ProgressLoggingError("Can't add -- process section is done")
self.augment_args(args, kwargs)
kwargs['log_action'... | [
"def",
"add",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"start",
"and",
"self",
".",
"start",
".",
"state",
"==",
"'done'",
"and",
"kwargs",
".",
"get",
"(",
"'log_action'",
")",
"!=",
"'done'",
":",
"ra... | Add a new record to the section | [
"Add",
"a",
"new",
"record",
"to",
"the",
"section"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L111-L133 |
CivicSpleen/ambry | ambry/bundle/process.py | ProgressSection.update | def update(self, *args, **kwargs):
"""Update the last section record"""
self.augment_args(args, kwargs)
kwargs['log_action'] = kwargs.get('log_action', 'update')
if not self.rec:
return self.add(**kwargs)
else:
for k, v in kwargs.items():
... | python | def update(self, *args, **kwargs):
"""Update the last section record"""
self.augment_args(args, kwargs)
kwargs['log_action'] = kwargs.get('log_action', 'update')
if not self.rec:
return self.add(**kwargs)
else:
for k, v in kwargs.items():
... | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"augment_args",
"(",
"args",
",",
"kwargs",
")",
"kwargs",
"[",
"'log_action'",
"]",
"=",
"kwargs",
".",
"get",
"(",
"'log_action'",
",",
"'update'",
")",... | Update the last section record | [
"Update",
"the",
"last",
"section",
"record"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L135-L157 |
CivicSpleen/ambry | ambry/bundle/process.py | ProgressSection.add_update | def add_update(self, *args, **kwargs):
"""A records is added, then on subsequent calls, updated"""
if not self._ai_rec_id:
self._ai_rec_id = self.add(*args, **kwargs)
else:
au_save = self._ai_rec_id
self.update(*args, **kwargs)
self._ai_rec_id = a... | python | def add_update(self, *args, **kwargs):
"""A records is added, then on subsequent calls, updated"""
if not self._ai_rec_id:
self._ai_rec_id = self.add(*args, **kwargs)
else:
au_save = self._ai_rec_id
self.update(*args, **kwargs)
self._ai_rec_id = a... | [
"def",
"add_update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_ai_rec_id",
":",
"self",
".",
"_ai_rec_id",
"=",
"self",
".",
"add",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"else",
":",
... | A records is added, then on subsequent calls, updated | [
"A",
"records",
"is",
"added",
"then",
"on",
"subsequent",
"calls",
"updated"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L159-L169 |
CivicSpleen/ambry | ambry/bundle/process.py | ProgressSection.update_done | def update_done(self, *args, **kwargs):
"""Clear out the previous update"""
kwargs['state'] = 'done'
self.update(*args, **kwargs)
self.rec = None | python | def update_done(self, *args, **kwargs):
"""Clear out the previous update"""
kwargs['state'] = 'done'
self.update(*args, **kwargs)
self.rec = None | [
"def",
"update_done",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'state'",
"]",
"=",
"'done'",
"self",
".",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"rec",
"=",
"None"
] | Clear out the previous update | [
"Clear",
"out",
"the",
"previous",
"update"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L171-L175 |
CivicSpleen/ambry | ambry/bundle/process.py | ProgressSection.done | def done(self, *args, **kwargs):
"""Mark the whole ProgressSection as done"""
kwargs['state'] = 'done'
pr_id = self.add(*args, log_action='done', **kwargs)
self._session.query(Process).filter(Process.group == self._group).update({Process.state: 'done'})
self.start.state = 'done'... | python | def done(self, *args, **kwargs):
"""Mark the whole ProgressSection as done"""
kwargs['state'] = 'done'
pr_id = self.add(*args, log_action='done', **kwargs)
self._session.query(Process).filter(Process.group == self._group).update({Process.state: 'done'})
self.start.state = 'done'... | [
"def",
"done",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'state'",
"]",
"=",
"'done'",
"pr_id",
"=",
"self",
".",
"add",
"(",
"*",
"args",
",",
"log_action",
"=",
"'done'",
",",
"*",
"*",
"kwargs",
")",
"... | Mark the whole ProgressSection as done | [
"Mark",
"the",
"whole",
"ProgressSection",
"as",
"done"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L177-L186 |
CivicSpleen/ambry | ambry/bundle/process.py | ProcessLogger.start | def start(self, phase, stage, **kwargs):
"""Start a new routine, stage or phase"""
return ProgressSection(self, self._session, phase, stage, self._logger, **kwargs) | python | def start(self, phase, stage, **kwargs):
"""Start a new routine, stage or phase"""
return ProgressSection(self, self._session, phase, stage, self._logger, **kwargs) | [
"def",
"start",
"(",
"self",
",",
"phase",
",",
"stage",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"ProgressSection",
"(",
"self",
",",
"self",
".",
"_session",
",",
"phase",
",",
"stage",
",",
"self",
".",
"_logger",
",",
"*",
"*",
"kwargs",
")... | Start a new routine, stage or phase | [
"Start",
"a",
"new",
"routine",
"stage",
"or",
"phase"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L258-L260 |
CivicSpleen/ambry | ambry/bundle/process.py | ProcessLogger.records | def records(self):
"""Return all start records for this the dataset, grouped by the start record"""
return (self._session.query(Process)
.filter(Process.d_vid == self._d_vid)).all() | python | def records(self):
"""Return all start records for this the dataset, grouped by the start record"""
return (self._session.query(Process)
.filter(Process.d_vid == self._d_vid)).all() | [
"def",
"records",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_session",
".",
"query",
"(",
"Process",
")",
".",
"filter",
"(",
"Process",
".",
"d_vid",
"==",
"self",
".",
"_d_vid",
")",
")",
".",
"all",
"(",
")"
] | Return all start records for this the dataset, grouped by the start record | [
"Return",
"all",
"start",
"records",
"for",
"this",
"the",
"dataset",
"grouped",
"by",
"the",
"start",
"record"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L263-L267 |
CivicSpleen/ambry | ambry/bundle/process.py | ProcessLogger.starts | def starts(self):
"""Return all start records for this the dataset, grouped by the start record"""
return (self._session.query(Process)
.filter(Process.d_vid == self._d_vid)
.filter(Process.log_action == 'start')
).all() | python | def starts(self):
"""Return all start records for this the dataset, grouped by the start record"""
return (self._session.query(Process)
.filter(Process.d_vid == self._d_vid)
.filter(Process.log_action == 'start')
).all() | [
"def",
"starts",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_session",
".",
"query",
"(",
"Process",
")",
".",
"filter",
"(",
"Process",
".",
"d_vid",
"==",
"self",
".",
"_d_vid",
")",
".",
"filter",
"(",
"Process",
".",
"log_action",
"==",
... | Return all start records for this the dataset, grouped by the start record | [
"Return",
"all",
"start",
"records",
"for",
"this",
"the",
"dataset",
"grouped",
"by",
"the",
"start",
"record"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L270-L276 |
CivicSpleen/ambry | ambry/bundle/process.py | ProcessLogger.query | def query(self):
"""Return all start records for this the dataset, grouped by the start record"""
return self._session.query(Process).filter(Process.d_vid == self._d_vid) | python | def query(self):
"""Return all start records for this the dataset, grouped by the start record"""
return self._session.query(Process).filter(Process.d_vid == self._d_vid) | [
"def",
"query",
"(",
"self",
")",
":",
"return",
"self",
".",
"_session",
".",
"query",
"(",
"Process",
")",
".",
"filter",
"(",
"Process",
".",
"d_vid",
"==",
"self",
".",
"_d_vid",
")"
] | Return all start records for this the dataset, grouped by the start record | [
"Return",
"all",
"start",
"records",
"for",
"this",
"the",
"dataset",
"grouped",
"by",
"the",
"start",
"record"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L279-L282 |
CivicSpleen/ambry | ambry/bundle/process.py | ProcessLogger.exceptions | def exceptions(self):
"""Return all start records for this the dataset, grouped by the start record"""
return (self._session.query(Process)
.filter(Process.d_vid == self._d_vid)
.filter(Process.exception_class != None)
.order_by(Process.modified)).all() | python | def exceptions(self):
"""Return all start records for this the dataset, grouped by the start record"""
return (self._session.query(Process)
.filter(Process.d_vid == self._d_vid)
.filter(Process.exception_class != None)
.order_by(Process.modified)).all() | [
"def",
"exceptions",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_session",
".",
"query",
"(",
"Process",
")",
".",
"filter",
"(",
"Process",
".",
"d_vid",
"==",
"self",
".",
"_d_vid",
")",
".",
"filter",
"(",
"Process",
".",
"exception_class",... | Return all start records for this the dataset, grouped by the start record | [
"Return",
"all",
"start",
"records",
"for",
"this",
"the",
"dataset",
"grouped",
"by",
"the",
"start",
"record"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L285-L291 |
CivicSpleen/ambry | ambry/bundle/process.py | ProcessLogger.clean | def clean(self):
"""Delete all of the records"""
# Deleting seems to be really weird and unrelable.
self._session \
.query(Process) \
.filter(Process.d_vid == self._d_vid) \
.delete(synchronize_session='fetch')
for r in self.records:
self... | python | def clean(self):
"""Delete all of the records"""
# Deleting seems to be really weird and unrelable.
self._session \
.query(Process) \
.filter(Process.d_vid == self._d_vid) \
.delete(synchronize_session='fetch')
for r in self.records:
self... | [
"def",
"clean",
"(",
"self",
")",
":",
"# Deleting seems to be really weird and unrelable.",
"self",
".",
"_session",
".",
"query",
"(",
"Process",
")",
".",
"filter",
"(",
"Process",
".",
"d_vid",
"==",
"self",
".",
"_d_vid",
")",
".",
"delete",
"(",
"synch... | Delete all of the records | [
"Delete",
"all",
"of",
"the",
"records"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L293-L305 |
CivicSpleen/ambry | ambry/bundle/process.py | ProcessLogger.build | def build(self):
"""Access build configuration values as attributes. See self.process
for a usage example"""
from ambry.orm.config import BuildConfigGroupAccessor
# It is a lightweight object, so no need to cache
return BuildConfigGroupAccessor(self.dataset, 'buildstate', se... | python | def build(self):
"""Access build configuration values as attributes. See self.process
for a usage example"""
from ambry.orm.config import BuildConfigGroupAccessor
# It is a lightweight object, so no need to cache
return BuildConfigGroupAccessor(self.dataset, 'buildstate', se... | [
"def",
"build",
"(",
"self",
")",
":",
"from",
"ambry",
".",
"orm",
".",
"config",
"import",
"BuildConfigGroupAccessor",
"# It is a lightweight object, so no need to cache",
"return",
"BuildConfigGroupAccessor",
"(",
"self",
".",
"dataset",
",",
"'buildstate'",
",",
"... | Access build configuration values as attributes. See self.process
for a usage example | [
"Access",
"build",
"configuration",
"values",
"as",
"attributes",
".",
"See",
"self",
".",
"process",
"for",
"a",
"usage",
"example"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/bundle/process.py#L319-L325 |
sailthru/relay | relay/relay_logging.py | configure_logging | def configure_logging(add_handler, log=log):
"""
Configure log records. If adding a handler, make the formatter print all
passed in key:value data.
ie log.extra('msg', extra=dict(a=1))
generates 'msg a=1'
`add_handler` (True, False, None, or Handler instance)
if True, add a l... | python | def configure_logging(add_handler, log=log):
"""
Configure log records. If adding a handler, make the formatter print all
passed in key:value data.
ie log.extra('msg', extra=dict(a=1))
generates 'msg a=1'
`add_handler` (True, False, None, or Handler instance)
if True, add a l... | [
"def",
"configure_logging",
"(",
"add_handler",
",",
"log",
"=",
"log",
")",
":",
"_ignore_log_keys",
"=",
"set",
"(",
"logging",
".",
"makeLogRecord",
"(",
"{",
"}",
")",
".",
"__dict__",
")",
"def",
"_json_format",
"(",
"record",
")",
":",
"extras",
"=... | Configure log records. If adding a handler, make the formatter print all
passed in key:value data.
ie log.extra('msg', extra=dict(a=1))
generates 'msg a=1'
`add_handler` (True, False, None, or Handler instance)
if True, add a logging.StreamHandler() instance
if False, do not ... | [
"Configure",
"log",
"records",
".",
"If",
"adding",
"a",
"handler",
"make",
"the",
"formatter",
"print",
"all",
"passed",
"in",
"key",
":",
"value",
"data",
".",
"ie",
"log",
".",
"extra",
"(",
"msg",
"extra",
"=",
"dict",
"(",
"a",
"=",
"1",
"))",
... | train | https://github.com/sailthru/relay/blob/995209346c6663675d96d0cbff3bb67b9758c8e2/relay/relay_logging.py#L7-L47 |
project-ncl/pnc-cli | pnc_cli/swagger_client/models/build_environment_rest.py | BuildEnvironmentRest.system_image_type | def system_image_type(self, system_image_type):
"""
Sets the system_image_type of this BuildEnvironmentRest.
:param system_image_type: The system_image_type of this BuildEnvironmentRest.
:type: str
"""
allowed_values = ["DOCKER_IMAGE", "VIRTUAL_MACHINE_RAW", "VIRTUAL_MAC... | python | def system_image_type(self, system_image_type):
"""
Sets the system_image_type of this BuildEnvironmentRest.
:param system_image_type: The system_image_type of this BuildEnvironmentRest.
:type: str
"""
allowed_values = ["DOCKER_IMAGE", "VIRTUAL_MACHINE_RAW", "VIRTUAL_MAC... | [
"def",
"system_image_type",
"(",
"self",
",",
"system_image_type",
")",
":",
"allowed_values",
"=",
"[",
"\"DOCKER_IMAGE\"",
",",
"\"VIRTUAL_MACHINE_RAW\"",
",",
"\"VIRTUAL_MACHINE_QCOW2\"",
",",
"\"LOCAL_WORKSPACE\"",
"]",
"if",
"system_image_type",
"not",
"in",
"allow... | Sets the system_image_type of this BuildEnvironmentRest.
:param system_image_type: The system_image_type of this BuildEnvironmentRest.
:type: str | [
"Sets",
"the",
"system_image_type",
"of",
"this",
"BuildEnvironmentRest",
"."
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/swagger_client/models/build_environment_rest.py#L228-L242 |
jedie/django-cms-tools | django_cms_tools/fixture_helper/page_utils.py | get_public_cms_app_namespaces | def get_public_cms_app_namespaces():
"""
:return: a tuple() with all cms app namespaces
"""
qs = Page.objects.public()
qs = qs.exclude(application_namespace=None)
qs = qs.order_by('application_namespace')
try:
application_namespaces = list(
qs.distinct('application_names... | python | def get_public_cms_app_namespaces():
"""
:return: a tuple() with all cms app namespaces
"""
qs = Page.objects.public()
qs = qs.exclude(application_namespace=None)
qs = qs.order_by('application_namespace')
try:
application_namespaces = list(
qs.distinct('application_names... | [
"def",
"get_public_cms_app_namespaces",
"(",
")",
":",
"qs",
"=",
"Page",
".",
"objects",
".",
"public",
"(",
")",
"qs",
"=",
"qs",
".",
"exclude",
"(",
"application_namespace",
"=",
"None",
")",
"qs",
"=",
"qs",
".",
"order_by",
"(",
"'application_namespa... | :return: a tuple() with all cms app namespaces | [
":",
"return",
":",
"a",
"tuple",
"()",
"with",
"all",
"cms",
"app",
"namespaces"
] | train | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/page_utils.py#L10-L30 |
jedie/django-cms-tools | django_cms_tools/fixture_helper/page_utils.py | get_public_cms_page_urls | def get_public_cms_page_urls(*, language_code):
"""
:param language_code: e.g.: "en" or "de"
:return: Tuple with all public urls in the given language
"""
pages = Page.objects.public()
urls = [page.get_absolute_url(language=language_code) for page in pages]
urls.sort()
return tuple(urls) | python | def get_public_cms_page_urls(*, language_code):
"""
:param language_code: e.g.: "en" or "de"
:return: Tuple with all public urls in the given language
"""
pages = Page.objects.public()
urls = [page.get_absolute_url(language=language_code) for page in pages]
urls.sort()
return tuple(urls) | [
"def",
"get_public_cms_page_urls",
"(",
"*",
",",
"language_code",
")",
":",
"pages",
"=",
"Page",
".",
"objects",
".",
"public",
"(",
")",
"urls",
"=",
"[",
"page",
".",
"get_absolute_url",
"(",
"language",
"=",
"language_code",
")",
"for",
"page",
"in",
... | :param language_code: e.g.: "en" or "de"
:return: Tuple with all public urls in the given language | [
":",
"param",
"language_code",
":",
"e",
".",
"g",
".",
":",
"en",
"or",
"de",
":",
"return",
":",
"Tuple",
"with",
"all",
"public",
"urls",
"in",
"the",
"given",
"language"
] | train | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/fixture_helper/page_utils.py#L33-L41 |
CivicSpleen/ambry | ambry/metadata/schema.py | ExtDoc.group_by_source | def group_by_source(self):
"""Return a dict of all of the docs, with the source associated
with the doc as a key"""
from collections import defaultdict
docs = defaultdict(list)
for k, v in self.items():
if 'source' in v:
docs[v.source].append(dict(v.i... | python | def group_by_source(self):
"""Return a dict of all of the docs, with the source associated
with the doc as a key"""
from collections import defaultdict
docs = defaultdict(list)
for k, v in self.items():
if 'source' in v:
docs[v.source].append(dict(v.i... | [
"def",
"group_by_source",
"(",
"self",
")",
":",
"from",
"collections",
"import",
"defaultdict",
"docs",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"'source'",
"in",
"v",
":",
"docs",
... | Return a dict of all of the docs, with the source associated
with the doc as a key | [
"Return",
"a",
"dict",
"of",
"all",
"of",
"the",
"docs",
"with",
"the",
"source",
"associated",
"with",
"the",
"doc",
"as",
"a",
"key"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/metadata/schema.py#L88-L98 |
twisted/epsilon | epsilon/hotfixes/filepath_copyTo.py | FilePath.preauthChild | def preauthChild(self, path):
"""
Use me if `path' might have slashes in it, but you know they're safe.
(NOT slashes at the beginning. It still needs to be a _child_).
"""
newpath = abspath(joinpath(self.path, normpath(path)))
if not newpath.startswith(self.path):
... | python | def preauthChild(self, path):
"""
Use me if `path' might have slashes in it, but you know they're safe.
(NOT slashes at the beginning. It still needs to be a _child_).
"""
newpath = abspath(joinpath(self.path, normpath(path)))
if not newpath.startswith(self.path):
... | [
"def",
"preauthChild",
"(",
"self",
",",
"path",
")",
":",
"newpath",
"=",
"abspath",
"(",
"joinpath",
"(",
"self",
".",
"path",
",",
"normpath",
"(",
"path",
")",
")",
")",
"if",
"not",
"newpath",
".",
"startswith",
"(",
"self",
".",
"path",
")",
... | Use me if `path' might have slashes in it, but you know they're safe.
(NOT slashes at the beginning. It still needs to be a _child_). | [
"Use",
"me",
"if",
"path",
"might",
"have",
"slashes",
"in",
"it",
"but",
"you",
"know",
"they",
"re",
"safe",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/filepath_copyTo.py#L96-L105 |
twisted/epsilon | epsilon/hotfixes/filepath_copyTo.py | FilePath.childSearchPreauth | def childSearchPreauth(self, *paths):
"""Return my first existing child with a name in 'paths'.
paths is expected to be a list of *pre-secured* path fragments; in most
cases this will be specified by a system administrator and not an
arbitrary user.
If no appropriately-named ch... | python | def childSearchPreauth(self, *paths):
"""Return my first existing child with a name in 'paths'.
paths is expected to be a list of *pre-secured* path fragments; in most
cases this will be specified by a system administrator and not an
arbitrary user.
If no appropriately-named ch... | [
"def",
"childSearchPreauth",
"(",
"self",
",",
"*",
"paths",
")",
":",
"p",
"=",
"self",
".",
"path",
"for",
"child",
"in",
"paths",
":",
"jp",
"=",
"joinpath",
"(",
"p",
",",
"child",
")",
"if",
"exists",
"(",
"jp",
")",
":",
"return",
"self",
"... | Return my first existing child with a name in 'paths'.
paths is expected to be a list of *pre-secured* path fragments; in most
cases this will be specified by a system administrator and not an
arbitrary user.
If no appropriately-named children exist, this will return None. | [
"Return",
"my",
"first",
"existing",
"child",
"with",
"a",
"name",
"in",
"paths",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/filepath_copyTo.py#L107-L120 |
twisted/epsilon | epsilon/hotfixes/filepath_copyTo.py | FilePath.siblingExtensionSearch | def siblingExtensionSearch(self, *exts):
"""Attempt to return a path with my name, given multiple possible
extensions.
Each extension in exts will be tested and the first path which exists
will be returned. If no path exists, None will be returned. If '' is
in exts, then if th... | python | def siblingExtensionSearch(self, *exts):
"""Attempt to return a path with my name, given multiple possible
extensions.
Each extension in exts will be tested and the first path which exists
will be returned. If no path exists, None will be returned. If '' is
in exts, then if th... | [
"def",
"siblingExtensionSearch",
"(",
"self",
",",
"*",
"exts",
")",
":",
"p",
"=",
"self",
".",
"path",
"for",
"ext",
"in",
"exts",
":",
"if",
"not",
"ext",
"and",
"self",
".",
"exists",
"(",
")",
":",
"return",
"self",
"if",
"ext",
"==",
"'*'",
... | Attempt to return a path with my name, given multiple possible
extensions.
Each extension in exts will be tested and the first path which exists
will be returned. If no path exists, None will be returned. If '' is
in exts, then if the file referred to by this path exists, 'self' will
... | [
"Attempt",
"to",
"return",
"a",
"path",
"with",
"my",
"name",
"given",
"multiple",
"possible",
"extensions",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/filepath_copyTo.py#L122-L145 |
twisted/epsilon | epsilon/hotfixes/filepath_copyTo.py | FilePath.globChildren | def globChildren(self, pattern):
"""
Assuming I am representing a directory, return a list of
FilePaths representing my children that match the given
pattern.
"""
import glob
path = self.path[-1] == '/' and self.path + pattern or slash.join([self.path, pattern])
... | python | def globChildren(self, pattern):
"""
Assuming I am representing a directory, return a list of
FilePaths representing my children that match the given
pattern.
"""
import glob
path = self.path[-1] == '/' and self.path + pattern or slash.join([self.path, pattern])
... | [
"def",
"globChildren",
"(",
"self",
",",
"pattern",
")",
":",
"import",
"glob",
"path",
"=",
"self",
".",
"path",
"[",
"-",
"1",
"]",
"==",
"'/'",
"and",
"self",
".",
"path",
"+",
"pattern",
"or",
"slash",
".",
"join",
"(",
"[",
"self",
".",
"pat... | Assuming I am representing a directory, return a list of
FilePaths representing my children that match the given
pattern. | [
"Assuming",
"I",
"am",
"representing",
"a",
"directory",
"return",
"a",
"list",
"of",
"FilePaths",
"representing",
"my",
"children",
"that",
"match",
"the",
"given",
"pattern",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/filepath_copyTo.py#L261-L269 |
twisted/epsilon | epsilon/hotfixes/filepath_copyTo.py | FilePath.create | def create(self):
"""Exclusively create a file, only if this file previously did not exist.
"""
fdint = os.open(self.path, (os.O_EXCL |
os.O_CREAT |
os.O_RDWR))
# XXX TODO: 'name' attribute of returned files is not ... | python | def create(self):
"""Exclusively create a file, only if this file previously did not exist.
"""
fdint = os.open(self.path, (os.O_EXCL |
os.O_CREAT |
os.O_RDWR))
# XXX TODO: 'name' attribute of returned files is not ... | [
"def",
"create",
"(",
"self",
")",
":",
"fdint",
"=",
"os",
".",
"open",
"(",
"self",
".",
"path",
",",
"(",
"os",
".",
"O_EXCL",
"|",
"os",
".",
"O_CREAT",
"|",
"os",
".",
"O_RDWR",
")",
")",
"# XXX TODO: 'name' attribute of returned files is not mutable ... | Exclusively create a file, only if this file previously did not exist. | [
"Exclusively",
"create",
"a",
"file",
"only",
"if",
"this",
"file",
"previously",
"did",
"not",
"exist",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/filepath_copyTo.py#L301-L312 |
twisted/epsilon | epsilon/hotfixes/filepath_copyTo.py | FilePath.temporarySibling | def temporarySibling(self):
"""
Create a path naming a temporary sibling of this path in a secure fashion.
"""
sib = self.parent().child(_secureEnoughString() + self.basename())
sib.requireCreate()
return sib | python | def temporarySibling(self):
"""
Create a path naming a temporary sibling of this path in a secure fashion.
"""
sib = self.parent().child(_secureEnoughString() + self.basename())
sib.requireCreate()
return sib | [
"def",
"temporarySibling",
"(",
"self",
")",
":",
"sib",
"=",
"self",
".",
"parent",
"(",
")",
".",
"child",
"(",
"_secureEnoughString",
"(",
")",
"+",
"self",
".",
"basename",
"(",
")",
")",
"sib",
".",
"requireCreate",
"(",
")",
"return",
"sib"
] | Create a path naming a temporary sibling of this path in a secure fashion. | [
"Create",
"a",
"path",
"naming",
"a",
"temporary",
"sibling",
"of",
"this",
"path",
"in",
"a",
"secure",
"fashion",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/filepath_copyTo.py#L314-L320 |
twisted/epsilon | epsilon/scripts/benchmark.py | parseDiskStatLine | def parseDiskStatLine(L):
"""
Parse a single line from C{/proc/diskstats} into a two-tuple of the name of
the device to which it corresponds (ie 'hda') and an instance of the
appropriate record type (either L{partitionstat} or L{diskstat}).
"""
parts = L.split()
device = parts[2]
if len(... | python | def parseDiskStatLine(L):
"""
Parse a single line from C{/proc/diskstats} into a two-tuple of the name of
the device to which it corresponds (ie 'hda') and an instance of the
appropriate record type (either L{partitionstat} or L{diskstat}).
"""
parts = L.split()
device = parts[2]
if len(... | [
"def",
"parseDiskStatLine",
"(",
"L",
")",
":",
"parts",
"=",
"L",
".",
"split",
"(",
")",
"device",
"=",
"parts",
"[",
"2",
"]",
"if",
"len",
"(",
"parts",
")",
"==",
"7",
":",
"factory",
"=",
"partitionstat",
"else",
":",
"factory",
"=",
"disksta... | Parse a single line from C{/proc/diskstats} into a two-tuple of the name of
the device to which it corresponds (ie 'hda') and an instance of the
appropriate record type (either L{partitionstat} or L{diskstat}). | [
"Parse",
"a",
"single",
"line",
"from",
"C",
"{",
"/",
"proc",
"/",
"diskstats",
"}",
"into",
"a",
"two",
"-",
"tuple",
"of",
"the",
"name",
"of",
"the",
"device",
"to",
"which",
"it",
"corresponds",
"(",
"ie",
"hda",
")",
"and",
"an",
"instance",
... | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/scripts/benchmark.py#L42-L54 |
twisted/epsilon | epsilon/scripts/benchmark.py | discoverCurrentWorkingDevice | def discoverCurrentWorkingDevice(procMounts='/proc/self/mounts'):
"""
Return a short string naming the device which backs the current working
directory, ie C{/dev/hda1}.
"""
possibilities = []
cwd = os.getcwd()
with file(procMounts, 'rb') as f:
for L in f:
parts = L.split... | python | def discoverCurrentWorkingDevice(procMounts='/proc/self/mounts'):
"""
Return a short string naming the device which backs the current working
directory, ie C{/dev/hda1}.
"""
possibilities = []
cwd = os.getcwd()
with file(procMounts, 'rb') as f:
for L in f:
parts = L.split... | [
"def",
"discoverCurrentWorkingDevice",
"(",
"procMounts",
"=",
"'/proc/self/mounts'",
")",
":",
"possibilities",
"=",
"[",
"]",
"cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"with",
"file",
"(",
"procMounts",
",",
"'rb'",
")",
"as",
"f",
":",
"for",
"L",
"i... | Return a short string naming the device which backs the current working
directory, ie C{/dev/hda1}. | [
"Return",
"a",
"short",
"string",
"naming",
"the",
"device",
"which",
"backs",
"the",
"current",
"working",
"directory",
"ie",
"C",
"{",
"/",
"dev",
"/",
"hda1",
"}",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/scripts/benchmark.py#L415-L431 |
twisted/epsilon | epsilon/scripts/benchmark.py | makeBenchmarkRunner | def makeBenchmarkRunner(path, args):
"""
Make a function that will run two Python processes serially: first one
which calls the setup function from the given file, then one which calls
the execute function from the given file.
"""
def runner():
return BenchmarkProcess.spawn(
... | python | def makeBenchmarkRunner(path, args):
"""
Make a function that will run two Python processes serially: first one
which calls the setup function from the given file, then one which calls
the execute function from the given file.
"""
def runner():
return BenchmarkProcess.spawn(
... | [
"def",
"makeBenchmarkRunner",
"(",
"path",
",",
"args",
")",
":",
"def",
"runner",
"(",
")",
":",
"return",
"BenchmarkProcess",
".",
"spawn",
"(",
"executable",
"=",
"sys",
".",
"executable",
",",
"args",
"=",
"[",
"'-Wignore'",
"]",
"+",
"args",
",",
... | Make a function that will run two Python processes serially: first one
which calls the setup function from the given file, then one which calls
the execute function from the given file. | [
"Make",
"a",
"function",
"that",
"will",
"run",
"two",
"Python",
"processes",
"serially",
":",
"first",
"one",
"which",
"calls",
"the",
"setup",
"function",
"from",
"the",
"given",
"file",
"then",
"one",
"which",
"calls",
"the",
"execute",
"function",
"from"... | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/scripts/benchmark.py#L514-L526 |
twisted/epsilon | epsilon/scripts/benchmark.py | start | def start():
"""
Start recording stats. Call this from a benchmark script when your setup
is done. Call this at most once.
@raise RuntimeError: Raised if the parent process responds with anything
other than an acknowledgement of this message.
"""
os.write(BenchmarkProcess.BACKCHANNEL_OUT,... | python | def start():
"""
Start recording stats. Call this from a benchmark script when your setup
is done. Call this at most once.
@raise RuntimeError: Raised if the parent process responds with anything
other than an acknowledgement of this message.
"""
os.write(BenchmarkProcess.BACKCHANNEL_OUT,... | [
"def",
"start",
"(",
")",
":",
"os",
".",
"write",
"(",
"BenchmarkProcess",
".",
"BACKCHANNEL_OUT",
",",
"BenchmarkProcess",
".",
"START",
")",
"response",
"=",
"util",
".",
"untilConcludes",
"(",
"os",
".",
"read",
",",
"BenchmarkProcess",
".",
"BACKCHANNEL... | Start recording stats. Call this from a benchmark script when your setup
is done. Call this at most once.
@raise RuntimeError: Raised if the parent process responds with anything
other than an acknowledgement of this message. | [
"Start",
"recording",
"stats",
".",
"Call",
"this",
"from",
"a",
"benchmark",
"script",
"when",
"your",
"setup",
"is",
"done",
".",
"Call",
"this",
"at",
"most",
"once",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/scripts/benchmark.py#L530-L542 |
twisted/epsilon | epsilon/scripts/benchmark.py | stop | def stop():
"""
Stop recording stats. Call this from a benchmark script when the code you
want benchmarked has finished. Call this exactly the same number of times
you call L{start} and only after calling it.
@raise RuntimeError: Raised if the parent process responds with anything
other than ... | python | def stop():
"""
Stop recording stats. Call this from a benchmark script when the code you
want benchmarked has finished. Call this exactly the same number of times
you call L{start} and only after calling it.
@raise RuntimeError: Raised if the parent process responds with anything
other than ... | [
"def",
"stop",
"(",
")",
":",
"os",
".",
"write",
"(",
"BenchmarkProcess",
".",
"BACKCHANNEL_OUT",
",",
"BenchmarkProcess",
".",
"STOP",
")",
"response",
"=",
"util",
".",
"untilConcludes",
"(",
"os",
".",
"read",
",",
"BenchmarkProcess",
".",
"BACKCHANNEL_I... | Stop recording stats. Call this from a benchmark script when the code you
want benchmarked has finished. Call this exactly the same number of times
you call L{start} and only after calling it.
@raise RuntimeError: Raised if the parent process responds with anything
other than an acknowledgement of th... | [
"Stop",
"recording",
"stats",
".",
"Call",
"this",
"from",
"a",
"benchmark",
"script",
"when",
"the",
"code",
"you",
"want",
"benchmarked",
"has",
"finished",
".",
"Call",
"this",
"exactly",
"the",
"same",
"number",
"of",
"times",
"you",
"call",
"L",
"{",
... | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/scripts/benchmark.py#L546-L559 |
twisted/epsilon | epsilon/scripts/benchmark.py | main | def main():
"""
Run me with the filename of a benchmark script as an argument. I will time
it and append the results to a file named output in the current working
directory.
"""
name = sys.argv[1]
path = filepath.FilePath('.stat').temporarySibling()
path.makedirs()
func = makeBenchm... | python | def main():
"""
Run me with the filename of a benchmark script as an argument. I will time
it and append the results to a file named output in the current working
directory.
"""
name = sys.argv[1]
path = filepath.FilePath('.stat').temporarySibling()
path.makedirs()
func = makeBenchm... | [
"def",
"main",
"(",
")",
":",
"name",
"=",
"sys",
".",
"argv",
"[",
"1",
"]",
"path",
"=",
"filepath",
".",
"FilePath",
"(",
"'.stat'",
")",
".",
"temporarySibling",
"(",
")",
"path",
".",
"makedirs",
"(",
")",
"func",
"=",
"makeBenchmarkRunner",
"("... | Run me with the filename of a benchmark script as an argument. I will time
it and append the results to a file named output in the current working
directory. | [
"Run",
"me",
"with",
"the",
"filename",
"of",
"a",
"benchmark",
"script",
"as",
"an",
"argument",
".",
"I",
"will",
"time",
"it",
"and",
"append",
"the",
"results",
"to",
"a",
"file",
"named",
"output",
"in",
"the",
"current",
"working",
"directory",
"."... | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/scripts/benchmark.py#L563-L576 |
twisted/epsilon | epsilon/scripts/benchmark.py | BasicProcess.spawn | def spawn(cls, executable, args, path, env, spawnProcess=None):
"""
Run an executable with some arguments in the given working directory with
the given environment variables.
Returns a Deferred which fires with a two-tuple of (exit status, output
list) if the process terminates ... | python | def spawn(cls, executable, args, path, env, spawnProcess=None):
"""
Run an executable with some arguments in the given working directory with
the given environment variables.
Returns a Deferred which fires with a two-tuple of (exit status, output
list) if the process terminates ... | [
"def",
"spawn",
"(",
"cls",
",",
"executable",
",",
"args",
",",
"path",
",",
"env",
",",
"spawnProcess",
"=",
"None",
")",
":",
"d",
"=",
"defer",
".",
"Deferred",
"(",
")",
"proto",
"=",
"cls",
"(",
"d",
",",
"filepath",
".",
"FilePath",
"(",
"... | Run an executable with some arguments in the given working directory with
the given environment variables.
Returns a Deferred which fires with a two-tuple of (exit status, output
list) if the process terminates without timing out or being killed by a
signal. Otherwise, the Deferred err... | [
"Run",
"an",
"executable",
"with",
"some",
"arguments",
"in",
"the",
"given",
"working",
"directory",
"with",
"the",
"given",
"environment",
"variables",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/scripts/benchmark.py#L166-L192 |
scholrly/orcid-python | orcid/rest.py | get | def get(orcid_id):
"""
Get an author based on an ORCID identifier.
"""
resp = requests.get(ORCID_PUBLIC_BASE_URL + unicode(orcid_id),
headers=BASE_HEADERS)
json_body = resp.json()
return Author(json_body) | python | def get(orcid_id):
"""
Get an author based on an ORCID identifier.
"""
resp = requests.get(ORCID_PUBLIC_BASE_URL + unicode(orcid_id),
headers=BASE_HEADERS)
json_body = resp.json()
return Author(json_body) | [
"def",
"get",
"(",
"orcid_id",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"ORCID_PUBLIC_BASE_URL",
"+",
"unicode",
"(",
"orcid_id",
")",
",",
"headers",
"=",
"BASE_HEADERS",
")",
"json_body",
"=",
"resp",
".",
"json",
"(",
")",
"return",
"Author... | Get an author based on an ORCID identifier. | [
"Get",
"an",
"author",
"based",
"on",
"an",
"ORCID",
"identifier",
"."
] | train | https://github.com/scholrly/orcid-python/blob/71311ca708689740e99d447716d6f22f1291f6f8/orcid/rest.py#L119-L126 |
twisted/epsilon | epsilon/structlike.py | _contextualize | def _contextualize(contextFactory, contextReceiver):
"""
Invoke a callable with an argument derived from the current execution
context (L{twisted.python.context}), or automatically created if none is
yet present in the current context.
This function, with a better name and documentation, should pro... | python | def _contextualize(contextFactory, contextReceiver):
"""
Invoke a callable with an argument derived from the current execution
context (L{twisted.python.context}), or automatically created if none is
yet present in the current context.
This function, with a better name and documentation, should pro... | [
"def",
"_contextualize",
"(",
"contextFactory",
",",
"contextReceiver",
")",
":",
"value",
"=",
"context",
".",
"get",
"(",
"contextFactory",
",",
"_NOT_SPECIFIED",
")",
"if",
"value",
"is",
"not",
"_NOT_SPECIFIED",
":",
"return",
"contextReceiver",
"(",
"value"... | Invoke a callable with an argument derived from the current execution
context (L{twisted.python.context}), or automatically created if none is
yet present in the current context.
This function, with a better name and documentation, should probably be
somewhere in L{twisted.python.context}. Calling con... | [
"Invoke",
"a",
"callable",
"with",
"an",
"argument",
"derived",
"from",
"the",
"current",
"execution",
"context",
"(",
"L",
"{",
"twisted",
".",
"python",
".",
"context",
"}",
")",
"or",
"automatically",
"created",
"if",
"none",
"is",
"yet",
"present",
"in... | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/structlike.py#L36-L62 |
twisted/epsilon | epsilon/structlike.py | record | def record(*a, **kw):
"""
Are you tired of typing class declarations that look like this::
class StuffInfo:
def __init__(self, a=None, b=None, c=None, d=None, e=None,
f=None, g=None, h=None, i=None, j=None):
self.a = a
self.b = b
... | python | def record(*a, **kw):
"""
Are you tired of typing class declarations that look like this::
class StuffInfo:
def __init__(self, a=None, b=None, c=None, d=None, e=None,
f=None, g=None, h=None, i=None, j=None):
self.a = a
self.b = b
... | [
"def",
"record",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"if",
"len",
"(",
"a",
")",
"==",
"1",
":",
"attributeNames",
"=",
"a",
"[",
"0",
"]",
".",
"split",
"(",
")",
"elif",
"len",
"(",
"a",
")",
"==",
"0",
":",
"if",
"not",
"kw",... | Are you tired of typing class declarations that look like this::
class StuffInfo:
def __init__(self, a=None, b=None, c=None, d=None, e=None,
f=None, g=None, h=None, i=None, j=None):
self.a = a
self.b = b
self.c = c
... | [
"Are",
"you",
"tired",
"of",
"typing",
"class",
"declarations",
"that",
"look",
"like",
"this",
"::"
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/structlike.py#L117-L183 |
twisted/epsilon | epsilon/structlike.py | _RecursiveReprer.recursiveRepr | def recursiveRepr(self, stuff, thunk=repr):
"""
Recursive repr().
"""
ID = id(stuff)
if ID in self.active:
return '%s(...)' % (stuff.__class__.__name__,)
else:
try:
self.active[ID] = stuff
return thunk(stuff)
... | python | def recursiveRepr(self, stuff, thunk=repr):
"""
Recursive repr().
"""
ID = id(stuff)
if ID in self.active:
return '%s(...)' % (stuff.__class__.__name__,)
else:
try:
self.active[ID] = stuff
return thunk(stuff)
... | [
"def",
"recursiveRepr",
"(",
"self",
",",
"stuff",
",",
"thunk",
"=",
"repr",
")",
":",
"ID",
"=",
"id",
"(",
"stuff",
")",
"if",
"ID",
"in",
"self",
".",
"active",
":",
"return",
"'%s(...)'",
"%",
"(",
"stuff",
".",
"__class__",
".",
"__name__",
"... | Recursive repr(). | [
"Recursive",
"repr",
"()",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/structlike.py#L21-L33 |
cosven/feeluown-core | fuocore/lyric.py | parse | def parse(content):
"""
Reference: https://github.com/osdlyrics/osdlyrics/blob/master/python/lrc.py
>>> parse("[00:00.00] 作曲 : 周杰伦\\n[00:01.00] 作词 : 周杰伦\\n")
{0.0: ' 作曲 : 周杰伦', 1000.0: ' 作词 : 周杰伦'}
"""
ms_sentence_map = dict()
sentence_pattern = re.compile(r'\[(\d+(:\d+){0,2}(\.\d+)?)\]')
... | python | def parse(content):
"""
Reference: https://github.com/osdlyrics/osdlyrics/blob/master/python/lrc.py
>>> parse("[00:00.00] 作曲 : 周杰伦\\n[00:01.00] 作词 : 周杰伦\\n")
{0.0: ' 作曲 : 周杰伦', 1000.0: ' 作词 : 周杰伦'}
"""
ms_sentence_map = dict()
sentence_pattern = re.compile(r'\[(\d+(:\d+){0,2}(\.\d+)?)\]')
... | [
"def",
"parse",
"(",
"content",
")",
":",
"ms_sentence_map",
"=",
"dict",
"(",
")",
"sentence_pattern",
"=",
"re",
".",
"compile",
"(",
"r'\\[(\\d+(:\\d+){0,2}(\\.\\d+)?)\\]'",
")",
"lines",
"=",
"content",
".",
"splitlines",
"(",
")",
"for",
"line",
"in",
"... | Reference: https://github.com/osdlyrics/osdlyrics/blob/master/python/lrc.py
>>> parse("[00:00.00] 作曲 : 周杰伦\\n[00:01.00] 作词 : 周杰伦\\n")
{0.0: ' 作曲 : 周杰伦', 1000.0: ' 作词 : 周杰伦'} | [
"Reference",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"osdlyrics",
"/",
"osdlyrics",
"/",
"blob",
"/",
"master",
"/",
"python",
"/",
"lrc",
".",
"py"
] | train | https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/lyric.py#L6-L29 |
project-ncl/pnc-cli | pnc_cli/products.py | create_product | def create_product(name, abbreviation, **kwargs):
"""
Create a new Product
"""
data = create_product_raw(name, abbreviation, **kwargs)
if data:
return utils.format_json(data) | python | def create_product(name, abbreviation, **kwargs):
"""
Create a new Product
"""
data = create_product_raw(name, abbreviation, **kwargs)
if data:
return utils.format_json(data) | [
"def",
"create_product",
"(",
"name",
",",
"abbreviation",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"create_product_raw",
"(",
"name",
",",
"abbreviation",
",",
"*",
"*",
"kwargs",
")",
"if",
"data",
":",
"return",
"utils",
".",
"format_json",
"("... | Create a new Product | [
"Create",
"a",
"new",
"Product"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/products.py#L28-L34 |
project-ncl/pnc-cli | pnc_cli/products.py | update_product | def update_product(product_id, **kwargs):
"""
Update a Product with new information
"""
content = update_product_raw(product_id, **kwargs)
if content:
return utils.format_json(content) | python | def update_product(product_id, **kwargs):
"""
Update a Product with new information
"""
content = update_product_raw(product_id, **kwargs)
if content:
return utils.format_json(content) | [
"def",
"update_product",
"(",
"product_id",
",",
"*",
"*",
"kwargs",
")",
":",
"content",
"=",
"update_product_raw",
"(",
"product_id",
",",
"*",
"*",
"kwargs",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Update a Product with new information | [
"Update",
"a",
"Product",
"with",
"new",
"information"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/products.py#L51-L57 |
project-ncl/pnc-cli | pnc_cli/products.py | get_product | def get_product(id=None, name=None):
"""
Get a specific Product by name or ID
"""
content = get_product_raw(id, name)
if content:
return utils.format_json(content) | python | def get_product(id=None, name=None):
"""
Get a specific Product by name or ID
"""
content = get_product_raw(id, name)
if content:
return utils.format_json(content) | [
"def",
"get_product",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"content",
"=",
"get_product_raw",
"(",
"id",
",",
"name",
")",
"if",
"content",
":",
"return",
"utils",
".",
"format_json",
"(",
"content",
")"
] | Get a specific Product by name or ID | [
"Get",
"a",
"specific",
"Product",
"by",
"name",
"or",
"ID"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/products.py#L74-L80 |
project-ncl/pnc-cli | pnc_cli/products.py | list_versions_for_product | def list_versions_for_product(id=None, name=None, page_size=200, page_index=0, sort='', q=''):
"""
List all ProductVersions for a given Product
"""
content = list_versions_for_product_raw(id, name, page_size, page_index, sort, q)
if content:
return utils.format_json_list(content) | python | def list_versions_for_product(id=None, name=None, page_size=200, page_index=0, sort='', q=''):
"""
List all ProductVersions for a given Product
"""
content = list_versions_for_product_raw(id, name, page_size, page_index, sort, q)
if content:
return utils.format_json_list(content) | [
"def",
"list_versions_for_product",
"(",
"id",
"=",
"None",
",",
"name",
"=",
"None",
",",
"page_size",
"=",
"200",
",",
"page_index",
"=",
"0",
",",
"sort",
"=",
"''",
",",
"q",
"=",
"''",
")",
":",
"content",
"=",
"list_versions_for_product_raw",
"(",
... | List all ProductVersions for a given Product | [
"List",
"all",
"ProductVersions",
"for",
"a",
"given",
"Product"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/products.py#L97-L103 |
project-ncl/pnc-cli | pnc_cli/products.py | list_products | def list_products(page_size=200, page_index=0, sort="", q=""):
"""
List all Products
"""
content = list_products_raw(page_size, page_index, sort, q)
if content:
return utils.format_json_list(content) | python | def list_products(page_size=200, page_index=0, sort="", q=""):
"""
List all Products
"""
content = list_products_raw(page_size, page_index, sort, q)
if content:
return utils.format_json_list(content) | [
"def",
"list_products",
"(",
"page_size",
"=",
"200",
",",
"page_index",
"=",
"0",
",",
"sort",
"=",
"\"\"",
",",
"q",
"=",
"\"\"",
")",
":",
"content",
"=",
"list_products_raw",
"(",
"page_size",
",",
"page_index",
",",
"sort",
",",
"q",
")",
"if",
... | List all Products | [
"List",
"all",
"Products"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/products.py#L116-L122 |
CivicSpleen/ambry | ambry/util/geocoders.py | DstkGeocoder.geocode | def geocode(self):
"""A Generator that reads from the address generators and returns
geocode results.
The generator yields ( address, geocode_results, object)
"""
submit_set = []
data_map = {}
for address, o in self.gen:
submit_set.append(address)
... | python | def geocode(self):
"""A Generator that reads from the address generators and returns
geocode results.
The generator yields ( address, geocode_results, object)
"""
submit_set = []
data_map = {}
for address, o in self.gen:
submit_set.append(address)
... | [
"def",
"geocode",
"(",
"self",
")",
":",
"submit_set",
"=",
"[",
"]",
"data_map",
"=",
"{",
"}",
"for",
"address",
",",
"o",
"in",
"self",
".",
"gen",
":",
"submit_set",
".",
"append",
"(",
"address",
")",
"data_map",
"[",
"address",
"]",
"=",
"o",... | A Generator that reads from the address generators and returns
geocode results.
The generator yields ( address, geocode_results, object) | [
"A",
"Generator",
"that",
"reads",
"from",
"the",
"address",
"generators",
"and",
"returns",
"geocode",
"results",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/util/geocoders.py#L35-L64 |
CivicSpleen/ambry | ambry/orm/database.py | migrate | def migrate(connection, dsn):
""" Collects all migrations and applies missed.
Args:
connection (sqlalchemy connection):
"""
all_migrations = _get_all_migrations()
logger.debug('Collected migrations: {}'.format(all_migrations))
for version, modname in all_migrations:
if _is_mis... | python | def migrate(connection, dsn):
""" Collects all migrations and applies missed.
Args:
connection (sqlalchemy connection):
"""
all_migrations = _get_all_migrations()
logger.debug('Collected migrations: {}'.format(all_migrations))
for version, modname in all_migrations:
if _is_mis... | [
"def",
"migrate",
"(",
"connection",
",",
"dsn",
")",
":",
"all_migrations",
"=",
"_get_all_migrations",
"(",
")",
"logger",
".",
"debug",
"(",
"'Collected migrations: {}'",
".",
"format",
"(",
"all_migrations",
")",
")",
"for",
"version",
",",
"modname",
"in"... | Collects all migrations and applies missed.
Args:
connection (sqlalchemy connection): | [
"Collects",
"all",
"migrations",
"and",
"applies",
"missed",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L835-L860 |
CivicSpleen/ambry | ambry/orm/database.py | create_migration_template | def create_migration_template(name):
""" Creates migration file. Returns created file name.
Args:
name (str): name of the migration.
Returns:
str: name of the migration file.
"""
assert name, 'Name of the migration can not be empty.'
from . import migrations
# Find next num... | python | def create_migration_template(name):
""" Creates migration file. Returns created file name.
Args:
name (str): name of the migration.
Returns:
str: name of the migration file.
"""
assert name, 'Name of the migration can not be empty.'
from . import migrations
# Find next num... | [
"def",
"create_migration_template",
"(",
"name",
")",
":",
"assert",
"name",
",",
"'Name of the migration can not be empty.'",
"from",
".",
"import",
"migrations",
"# Find next number",
"#",
"package",
"=",
"migrations",
"prefix",
"=",
"package",
".",
"__name__",
"+",... | Creates migration file. Returns created file name.
Args:
name (str): name of the migration.
Returns:
str: name of the migration file. | [
"Creates",
"migration",
"file",
".",
"Returns",
"created",
"file",
"name",
".",
"Args",
":",
"name",
"(",
"str",
")",
":",
"name",
"of",
"the",
"migration",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L863-L894 |
CivicSpleen/ambry | ambry/orm/database.py | get_stored_version | def get_stored_version(connection):
""" Returns database version.
Args:
connection (sqlalchemy connection):
Raises: Assuming user_version pragma (sqlite case) and user_version table (postgresql case)
exist because they created with the database creation.
Returns:
int: version ... | python | def get_stored_version(connection):
""" Returns database version.
Args:
connection (sqlalchemy connection):
Raises: Assuming user_version pragma (sqlite case) and user_version table (postgresql case)
exist because they created with the database creation.
Returns:
int: version ... | [
"def",
"get_stored_version",
"(",
"connection",
")",
":",
"if",
"connection",
".",
"engine",
".",
"name",
"==",
"'sqlite'",
":",
"version",
"=",
"connection",
".",
"execute",
"(",
"'PRAGMA user_version'",
")",
".",
"fetchone",
"(",
")",
"[",
"0",
"]",
"if"... | Returns database version.
Args:
connection (sqlalchemy connection):
Raises: Assuming user_version pragma (sqlite case) and user_version table (postgresql case)
exist because they created with the database creation.
Returns:
int: version of the database. | [
"Returns",
"database",
"version",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L897-L931 |
CivicSpleen/ambry | ambry/orm/database.py | _validate_version | def _validate_version(connection, dsn):
""" Performs on-the-fly schema updates based on the models version.
Raises:
DatabaseError: if user uses old sqlite database.
"""
try:
version = get_stored_version(connection)
except VersionIsNotStored:
logger.debug('Version not stored... | python | def _validate_version(connection, dsn):
""" Performs on-the-fly schema updates based on the models version.
Raises:
DatabaseError: if user uses old sqlite database.
"""
try:
version = get_stored_version(connection)
except VersionIsNotStored:
logger.debug('Version not stored... | [
"def",
"_validate_version",
"(",
"connection",
",",
"dsn",
")",
":",
"try",
":",
"version",
"=",
"get_stored_version",
"(",
"connection",
")",
"except",
"VersionIsNotStored",
":",
"logger",
".",
"debug",
"(",
"'Version not stored in the db: assuming new database creatio... | Performs on-the-fly schema updates based on the models version.
Raises:
DatabaseError: if user uses old sqlite database. | [
"Performs",
"on",
"-",
"the",
"-",
"fly",
"schema",
"updates",
"based",
"on",
"the",
"models",
"version",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L934-L953 |
CivicSpleen/ambry | ambry/orm/database.py | _migration_required | def _migration_required(connection):
""" Returns True if ambry models do not match to db tables. Otherwise returns False. """
stored_version = get_stored_version(connection)
actual_version = SCHEMA_VERSION
assert isinstance(stored_version, int)
assert isinstance(actual_version, int)
assert store... | python | def _migration_required(connection):
""" Returns True if ambry models do not match to db tables. Otherwise returns False. """
stored_version = get_stored_version(connection)
actual_version = SCHEMA_VERSION
assert isinstance(stored_version, int)
assert isinstance(actual_version, int)
assert store... | [
"def",
"_migration_required",
"(",
"connection",
")",
":",
"stored_version",
"=",
"get_stored_version",
"(",
"connection",
")",
"actual_version",
"=",
"SCHEMA_VERSION",
"assert",
"isinstance",
"(",
"stored_version",
",",
"int",
")",
"assert",
"isinstance",
"(",
"act... | Returns True if ambry models do not match to db tables. Otherwise returns False. | [
"Returns",
"True",
"if",
"ambry",
"models",
"do",
"not",
"match",
"to",
"db",
"tables",
".",
"Otherwise",
"returns",
"False",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L956-L964 |
CivicSpleen/ambry | ambry/orm/database.py | _update_version | def _update_version(connection, version):
""" Updates version in the db to the given version.
Args:
connection (sqlalchemy connection): sqlalchemy session where to update version.
version (int): version of the migration.
"""
if connection.engine.name == 'sqlite':
connection.exe... | python | def _update_version(connection, version):
""" Updates version in the db to the given version.
Args:
connection (sqlalchemy connection): sqlalchemy session where to update version.
version (int): version of the migration.
"""
if connection.engine.name == 'sqlite':
connection.exe... | [
"def",
"_update_version",
"(",
"connection",
",",
"version",
")",
":",
"if",
"connection",
".",
"engine",
".",
"name",
"==",
"'sqlite'",
":",
"connection",
".",
"execute",
"(",
"'PRAGMA user_version = {}'",
".",
"format",
"(",
"version",
")",
")",
"elif",
"c... | Updates version in the db to the given version.
Args:
connection (sqlalchemy connection): sqlalchemy session where to update version.
version (int): version of the migration. | [
"Updates",
"version",
"in",
"the",
"db",
"to",
"the",
"given",
"version",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L967-L997 |
CivicSpleen/ambry | ambry/orm/database.py | _get_all_migrations | def _get_all_migrations():
""" Returns sorted list of all migrations.
Returns:
list of (int, str) tuples: first elem of the tuple is migration number, second if module name.
"""
from . import migrations
package = migrations
prefix = package.__name__ + '.'
all_migrations = []
f... | python | def _get_all_migrations():
""" Returns sorted list of all migrations.
Returns:
list of (int, str) tuples: first elem of the tuple is migration number, second if module name.
"""
from . import migrations
package = migrations
prefix = package.__name__ + '.'
all_migrations = []
f... | [
"def",
"_get_all_migrations",
"(",
")",
":",
"from",
".",
"import",
"migrations",
"package",
"=",
"migrations",
"prefix",
"=",
"package",
".",
"__name__",
"+",
"'.'",
"all_migrations",
"=",
"[",
"]",
"for",
"importer",
",",
"modname",
",",
"ispkg",
"in",
"... | Returns sorted list of all migrations.
Returns:
list of (int, str) tuples: first elem of the tuple is migration number, second if module name. | [
"Returns",
"sorted",
"list",
"of",
"all",
"migrations",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L1013-L1030 |
CivicSpleen/ambry | ambry/orm/database.py | Database.create | def create(self):
"""Create the database from the base SQL."""
if not self.exists():
self._create_path()
self.create_tables()
return True
return False | python | def create(self):
"""Create the database from the base SQL."""
if not self.exists():
self._create_path()
self.create_tables()
return True
return False | [
"def",
"create",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"exists",
"(",
")",
":",
"self",
".",
"_create_path",
"(",
")",
"self",
".",
"create_tables",
"(",
")",
"return",
"True",
"return",
"False"
] | Create the database from the base SQL. | [
"Create",
"the",
"database",
"from",
"the",
"base",
"SQL",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L107-L115 |
CivicSpleen/ambry | ambry/orm/database.py | Database._create_path | def _create_path(self):
"""Create the path to hold the database, if one wwas specified."""
if self.driver == 'sqlite' and 'memory' not in self.dsn and self.dsn != 'sqlite://':
dir_ = os.path.dirname(self.path)
if dir_ and not os.path.exists(dir_):
try:
... | python | def _create_path(self):
"""Create the path to hold the database, if one wwas specified."""
if self.driver == 'sqlite' and 'memory' not in self.dsn and self.dsn != 'sqlite://':
dir_ = os.path.dirname(self.path)
if dir_ and not os.path.exists(dir_):
try:
... | [
"def",
"_create_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"driver",
"==",
"'sqlite'",
"and",
"'memory'",
"not",
"in",
"self",
".",
"dsn",
"and",
"self",
".",
"dsn",
"!=",
"'sqlite://'",
":",
"dir_",
"=",
"os",
".",
"path",
".",
"dirname",
"(",... | Create the path to hold the database, if one wwas specified. | [
"Create",
"the",
"path",
"to",
"hold",
"the",
"database",
"if",
"one",
"wwas",
"specified",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L117-L133 |
CivicSpleen/ambry | ambry/orm/database.py | Database.exists | def exists(self):
"""Return True if the database exists, or for Sqlite, which will create the file on the
first reference, the file has been initialized with the root config """
if self.driver == 'sqlite' and not os.path.exists(self.path):
return False
# init engine
... | python | def exists(self):
"""Return True if the database exists, or for Sqlite, which will create the file on the
first reference, the file has been initialized with the root config """
if self.driver == 'sqlite' and not os.path.exists(self.path):
return False
# init engine
... | [
"def",
"exists",
"(",
"self",
")",
":",
"if",
"self",
".",
"driver",
"==",
"'sqlite'",
"and",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"return",
"False",
"# init engine",
"self",
".",
"engine",
"try",
":",
"# Since... | Return True if the database exists, or for Sqlite, which will create the file on the
first reference, the file has been initialized with the root config | [
"Return",
"True",
"if",
"the",
"database",
"exists",
"or",
"for",
"Sqlite",
"which",
"will",
"create",
"the",
"file",
"on",
"the",
"first",
"reference",
"the",
"file",
"has",
"been",
"initialized",
"with",
"the",
"root",
"config"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L139-L162 |
CivicSpleen/ambry | ambry/orm/database.py | Database.engine | def engine(self):
"""return the SqlAlchemy engine for this database."""
if not self._engine:
if 'postgres' in self.driver:
if 'connect_args' not in self.engine_kwargs:
self.engine_kwargs['connect_args'] = {
'application_name': '{... | python | def engine(self):
"""return the SqlAlchemy engine for this database."""
if not self._engine:
if 'postgres' in self.driver:
if 'connect_args' not in self.engine_kwargs:
self.engine_kwargs['connect_args'] = {
'application_name': '{... | [
"def",
"engine",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_engine",
":",
"if",
"'postgres'",
"in",
"self",
".",
"driver",
":",
"if",
"'connect_args'",
"not",
"in",
"self",
".",
"engine_kwargs",
":",
"self",
".",
"engine_kwargs",
"[",
"'connect_a... | return the SqlAlchemy engine for this database. | [
"return",
"the",
"SqlAlchemy",
"engine",
"for",
"this",
"database",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L165-L225 |
CivicSpleen/ambry | ambry/orm/database.py | Database.connection | def connection(self):
"""Return an SqlAlchemy connection."""
if not self._connection:
logger.debug('Opening connection to: {}'.format(self.dsn))
self._connection = self.engine.connect()
logger.debug('Opened connection to: {}'.format(self.dsn))
# logger.debug(... | python | def connection(self):
"""Return an SqlAlchemy connection."""
if not self._connection:
logger.debug('Opening connection to: {}'.format(self.dsn))
self._connection = self.engine.connect()
logger.debug('Opened connection to: {}'.format(self.dsn))
# logger.debug(... | [
"def",
"connection",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_connection",
":",
"logger",
".",
"debug",
"(",
"'Opening connection to: {}'",
".",
"format",
"(",
"self",
".",
"dsn",
")",
")",
"self",
".",
"_connection",
"=",
"self",
".",
"engine"... | Return an SqlAlchemy connection. | [
"Return",
"an",
"SqlAlchemy",
"connection",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L228-L236 |
CivicSpleen/ambry | ambry/orm/database.py | Database.session | def session(self):
"""Return a SqlAlchemy session."""
from sqlalchemy.orm import sessionmaker
from sqlalchemy.event import listen
if not self.Session:
self.Session = sessionmaker(bind=self.engine)
if not self._session:
self._session = self.Session()
... | python | def session(self):
"""Return a SqlAlchemy session."""
from sqlalchemy.orm import sessionmaker
from sqlalchemy.event import listen
if not self.Session:
self.Session = sessionmaker(bind=self.engine)
if not self._session:
self._session = self.Session()
... | [
"def",
"session",
"(",
"self",
")",
":",
"from",
"sqlalchemy",
".",
"orm",
"import",
"sessionmaker",
"from",
"sqlalchemy",
".",
"event",
"import",
"listen",
"if",
"not",
"self",
".",
"Session",
":",
"self",
".",
"Session",
"=",
"sessionmaker",
"(",
"bind",... | Return a SqlAlchemy session. | [
"Return",
"a",
"SqlAlchemy",
"session",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L239-L259 |
CivicSpleen/ambry | ambry/orm/database.py | Database.metadata | def metadata(self):
"""Return an SqlAlchemy MetaData object, bound to the engine."""
from sqlalchemy import MetaData
metadata = MetaData(bind=self.engine, schema=self._schema)
metadata.reflect(self.engine)
return metadata | python | def metadata(self):
"""Return an SqlAlchemy MetaData object, bound to the engine."""
from sqlalchemy import MetaData
metadata = MetaData(bind=self.engine, schema=self._schema)
metadata.reflect(self.engine)
return metadata | [
"def",
"metadata",
"(",
"self",
")",
":",
"from",
"sqlalchemy",
"import",
"MetaData",
"metadata",
"=",
"MetaData",
"(",
"bind",
"=",
"self",
".",
"engine",
",",
"schema",
"=",
"self",
".",
"_schema",
")",
"metadata",
".",
"reflect",
"(",
"self",
".",
"... | Return an SqlAlchemy MetaData object, bound to the engine. | [
"Return",
"an",
"SqlAlchemy",
"MetaData",
"object",
"bound",
"to",
"the",
"engine",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L362-L371 |
CivicSpleen/ambry | ambry/orm/database.py | Database._add_config_root | def _add_config_root(self):
""" Adds the root dataset, which holds configuration values for the database. """
try:
self.session.query(Dataset).filter_by(id=ROOT_CONFIG_NAME).one()
self.close_session()
except NoResultFound:
o = Dataset(
id=ROOT... | python | def _add_config_root(self):
""" Adds the root dataset, which holds configuration values for the database. """
try:
self.session.query(Dataset).filter_by(id=ROOT_CONFIG_NAME).one()
self.close_session()
except NoResultFound:
o = Dataset(
id=ROOT... | [
"def",
"_add_config_root",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"session",
".",
"query",
"(",
"Dataset",
")",
".",
"filter_by",
"(",
"id",
"=",
"ROOT_CONFIG_NAME",
")",
".",
"one",
"(",
")",
"self",
".",
"close_session",
"(",
")",
"except",
... | Adds the root dataset, which holds configuration values for the database. | [
"Adds",
"the",
"root",
"dataset",
"which",
"holds",
"configuration",
"values",
"for",
"the",
"database",
"."
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L422-L442 |
CivicSpleen/ambry | ambry/orm/database.py | Database.new_dataset | def new_dataset(self, *args, **kwargs):
""" Creates a new dataset
:param args: Positional args passed to the Dataset constructor.
:param kwargs: Keyword args passed to the Dataset constructor.
:return: :class:`ambry.orm.Dataset`
:raises: :class:`ambry.orm.ConflictError` if the ... | python | def new_dataset(self, *args, **kwargs):
""" Creates a new dataset
:param args: Positional args passed to the Dataset constructor.
:param kwargs: Keyword args passed to the Dataset constructor.
:return: :class:`ambry.orm.Dataset`
:raises: :class:`ambry.orm.ConflictError` if the ... | [
"def",
"new_dataset",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"ds",
"=",
"Dataset",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"try",
":",
"self",
".",
"session",
".",
"add",
"(",
"ds",
")",
"self",
".",
"session"... | Creates a new dataset
:param args: Positional args passed to the Dataset constructor.
:param kwargs: Keyword args passed to the Dataset constructor.
:return: :class:`ambry.orm.Dataset`
:raises: :class:`ambry.orm.ConflictError` if the a Dataset records already exists with the given vid | [
"Creates",
"a",
"new",
"dataset"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L448-L467 |
CivicSpleen/ambry | ambry/orm/database.py | Database.root_dataset | def root_dataset(self):
"""Return the root dataset, which hold configuration values for the library"""
ds = self.dataset(ROOT_CONFIG_NAME_V)
ds._database = self
return ds | python | def root_dataset(self):
"""Return the root dataset, which hold configuration values for the library"""
ds = self.dataset(ROOT_CONFIG_NAME_V)
ds._database = self
return ds | [
"def",
"root_dataset",
"(",
"self",
")",
":",
"ds",
"=",
"self",
".",
"dataset",
"(",
"ROOT_CONFIG_NAME_V",
")",
"ds",
".",
"_database",
"=",
"self",
"return",
"ds"
] | Return the root dataset, which hold configuration values for the library | [
"Return",
"the",
"root",
"dataset",
"which",
"hold",
"configuration",
"values",
"for",
"the",
"library"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L470-L474 |
CivicSpleen/ambry | ambry/orm/database.py | Database.package_dataset | def package_dataset(self):
"""For sqlite bundle packages, return the first ( and only ) dataset"""
return self.session.query(Dataset).filter(Dataset.vid != ROOT_CONFIG_NAME_V).one() | python | def package_dataset(self):
"""For sqlite bundle packages, return the first ( and only ) dataset"""
return self.session.query(Dataset).filter(Dataset.vid != ROOT_CONFIG_NAME_V).one() | [
"def",
"package_dataset",
"(",
"self",
")",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"Dataset",
")",
".",
"filter",
"(",
"Dataset",
".",
"vid",
"!=",
"ROOT_CONFIG_NAME_V",
")",
".",
"one",
"(",
")"
] | For sqlite bundle packages, return the first ( and only ) dataset | [
"For",
"sqlite",
"bundle",
"packages",
"return",
"the",
"first",
"(",
"and",
"only",
")",
"dataset"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L477-L480 |
CivicSpleen/ambry | ambry/orm/database.py | Database.dataset | def dataset(self, ref, load_all=False, exception=True):
"""Return a dataset, given a vid or id
:param ref: Vid or id for a dataset. If an id is provided, will it will return the one with the
largest revision number
:param load_all: Use a query that eagerly loads everything.
:re... | python | def dataset(self, ref, load_all=False, exception=True):
"""Return a dataset, given a vid or id
:param ref: Vid or id for a dataset. If an id is provided, will it will return the one with the
largest revision number
:param load_all: Use a query that eagerly loads everything.
:re... | [
"def",
"dataset",
"(",
"self",
",",
"ref",
",",
"load_all",
"=",
"False",
",",
"exception",
"=",
"True",
")",
":",
"ref",
"=",
"str",
"(",
"ref",
")",
"try",
":",
"ds",
"=",
"self",
".",
"session",
".",
"query",
"(",
"Dataset",
")",
".",
"filter"... | Return a dataset, given a vid or id
:param ref: Vid or id for a dataset. If an id is provided, will it will return the one with the
largest revision number
:param load_all: Use a query that eagerly loads everything.
:return: :class:`ambry.orm.Dataset` | [
"Return",
"a",
"dataset",
"given",
"a",
"vid",
"or",
"id"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L482-L531 |
CivicSpleen/ambry | ambry/orm/database.py | Database.datasets | def datasets(self):
"""
Return all datasets
:return:
"""
return self.session.query(Dataset).filter(Dataset.vid != ROOT_CONFIG_NAME_V).all() | python | def datasets(self):
"""
Return all datasets
:return:
"""
return self.session.query(Dataset).filter(Dataset.vid != ROOT_CONFIG_NAME_V).all() | [
"def",
"datasets",
"(",
"self",
")",
":",
"return",
"self",
".",
"session",
".",
"query",
"(",
"Dataset",
")",
".",
"filter",
"(",
"Dataset",
".",
"vid",
"!=",
"ROOT_CONFIG_NAME_V",
")",
".",
"all",
"(",
")"
] | Return all datasets
:return: | [
"Return",
"all",
"datasets"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L547-L554 |
CivicSpleen/ambry | ambry/orm/database.py | Database.delete_tables_partitions | def delete_tables_partitions(self, ds):
"""Fast delete of all of a datasets codes, columns, partitions and tables"""
from ambry.orm import Code, Column, Table, Partition, ColumnStat, Process
ssq = self.session.query
ssq(Process).filter(Process.d_vid == ds.vid).delete()
ssq(Code... | python | def delete_tables_partitions(self, ds):
"""Fast delete of all of a datasets codes, columns, partitions and tables"""
from ambry.orm import Code, Column, Table, Partition, ColumnStat, Process
ssq = self.session.query
ssq(Process).filter(Process.d_vid == ds.vid).delete()
ssq(Code... | [
"def",
"delete_tables_partitions",
"(",
"self",
",",
"ds",
")",
":",
"from",
"ambry",
".",
"orm",
"import",
"Code",
",",
"Column",
",",
"Table",
",",
"Partition",
",",
"ColumnStat",
",",
"Process",
"ssq",
"=",
"self",
".",
"session",
".",
"query",
"ssq",... | Fast delete of all of a datasets codes, columns, partitions and tables | [
"Fast",
"delete",
"of",
"all",
"of",
"a",
"datasets",
"codes",
"columns",
"partitions",
"and",
"tables"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L563-L578 |
CivicSpleen/ambry | ambry/orm/database.py | Database.delete_partitions | def delete_partitions(self, ds):
"""Fast delete of all of a datasets codes, columns, partitions and tables"""
from ambry.orm import Partition
ssq = self.session.query
ssq(Process).filter(Process.d_vid == ds.vid).delete()
ssq(Code).filter(Code.d_vid == ds.vid).delete()
s... | python | def delete_partitions(self, ds):
"""Fast delete of all of a datasets codes, columns, partitions and tables"""
from ambry.orm import Partition
ssq = self.session.query
ssq(Process).filter(Process.d_vid == ds.vid).delete()
ssq(Code).filter(Code.d_vid == ds.vid).delete()
s... | [
"def",
"delete_partitions",
"(",
"self",
",",
"ds",
")",
":",
"from",
"ambry",
".",
"orm",
"import",
"Partition",
"ssq",
"=",
"self",
".",
"session",
".",
"query",
"ssq",
"(",
"Process",
")",
".",
"filter",
"(",
"Process",
".",
"d_vid",
"==",
"ds",
"... | Fast delete of all of a datasets codes, columns, partitions and tables | [
"Fast",
"delete",
"of",
"all",
"of",
"a",
"datasets",
"codes",
"columns",
"partitions",
"and",
"tables"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L580-L589 |
CivicSpleen/ambry | ambry/orm/database.py | Database.copy_dataset | def copy_dataset(self, ds, incver=False, cb=None, **kwargs):
"""
Copy a dataset into the database.
:param ds: The source dataset to copy
:param cb: A progress callback, taking two parameters: cb(message, num_records)
:return:
"""
from ambry.orm import Table, Colum... | python | def copy_dataset(self, ds, incver=False, cb=None, **kwargs):
"""
Copy a dataset into the database.
:param ds: The source dataset to copy
:param cb: A progress callback, taking two parameters: cb(message, num_records)
:return:
"""
from ambry.orm import Table, Colum... | [
"def",
"copy_dataset",
"(",
"self",
",",
"ds",
",",
"incver",
"=",
"False",
",",
"cb",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"ambry",
".",
"orm",
"import",
"Table",
",",
"Column",
",",
"Partition",
",",
"File",
",",
"ColumnStat",
... | Copy a dataset into the database.
:param ds: The source dataset to copy
:param cb: A progress callback, taking two parameters: cb(message, num_records)
:return: | [
"Copy",
"a",
"dataset",
"into",
"the",
"database",
".",
":",
"param",
"ds",
":",
"The",
"source",
"dataset",
"to",
"copy",
":",
"param",
"cb",
":",
"A",
"progress",
"callback",
"taking",
"two",
"parameters",
":",
"cb",
"(",
"message",
"num_records",
")",... | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L591-L603 |
CivicSpleen/ambry | ambry/orm/database.py | Database.copy_dataset_files | def copy_dataset_files(self, ds, incver=False, cb=None, **kwargs):
"""
Copy only files and configs into the database.
:param ds: The source dataset to copy
:param cb: A progress callback, taking two parameters: cb(message, num_records)
:return:
"""
from ambry.orm ... | python | def copy_dataset_files(self, ds, incver=False, cb=None, **kwargs):
"""
Copy only files and configs into the database.
:param ds: The source dataset to copy
:param cb: A progress callback, taking two parameters: cb(message, num_records)
:return:
"""
from ambry.orm ... | [
"def",
"copy_dataset_files",
"(",
"self",
",",
"ds",
",",
"incver",
"=",
"False",
",",
"cb",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"ambry",
".",
"orm",
"import",
"File",
"tables",
"=",
"[",
"File",
"]",
"return",
"self",
".",
"_co... | Copy only files and configs into the database.
:param ds: The source dataset to copy
:param cb: A progress callback, taking two parameters: cb(message, num_records)
:return: | [
"Copy",
"only",
"files",
"and",
"configs",
"into",
"the",
"database",
".",
":",
"param",
"ds",
":",
"The",
"source",
"dataset",
"to",
"copy",
":",
"param",
"cb",
":",
"A",
"progress",
"callback",
"taking",
"two",
"parameters",
":",
"cb",
"(",
"message",
... | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L605-L616 |
CivicSpleen/ambry | ambry/orm/database.py | Database.next_sequence_id | def next_sequence_id(self, parent_table_class, parent_vid, child_table_class):
"""Get the next sequence id for child objects for a parent object that has a child sequence
field"""
from sqlalchemy import text
# Name of sequence id column in the child
c_seq_col = child_table_clas... | python | def next_sequence_id(self, parent_table_class, parent_vid, child_table_class):
"""Get the next sequence id for child objects for a parent object that has a child sequence
field"""
from sqlalchemy import text
# Name of sequence id column in the child
c_seq_col = child_table_clas... | [
"def",
"next_sequence_id",
"(",
"self",
",",
"parent_table_class",
",",
"parent_vid",
",",
"child_table_class",
")",
":",
"from",
"sqlalchemy",
"import",
"text",
"# Name of sequence id column in the child",
"c_seq_col",
"=",
"child_table_class",
".",
"sequence_id",
".",
... | Get the next sequence id for child objects for a parent object that has a child sequence
field | [
"Get",
"the",
"next",
"sequence",
"id",
"for",
"child",
"objects",
"for",
"a",
"parent",
"object",
"that",
"has",
"a",
"child",
"sequence",
"field"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L716-L757 |
CivicSpleen/ambry | ambry/orm/database.py | BaseMigration.create_table | def create_table(table, connection, schema=None):
"""Create a single table, primarily used din migrations"""
orig_schemas = {}
# These schema shenanigans are almost certainly wrong.
# But they are expedient. For Postgres, it puts the library
# tables in the Library schema. We n... | python | def create_table(table, connection, schema=None):
"""Create a single table, primarily used din migrations"""
orig_schemas = {}
# These schema shenanigans are almost certainly wrong.
# But they are expedient. For Postgres, it puts the library
# tables in the Library schema. We n... | [
"def",
"create_table",
"(",
"table",
",",
"connection",
",",
"schema",
"=",
"None",
")",
":",
"orig_schemas",
"=",
"{",
"}",
"# These schema shenanigans are almost certainly wrong.",
"# But they are expedient. For Postgres, it puts the library",
"# tables in the Library schema. W... | Create a single table, primarily used din migrations | [
"Create",
"a",
"single",
"table",
"primarily",
"used",
"din",
"migrations"
] | train | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/database.py#L796-L819 |
twisted/epsilon | epsilon/hotfixes/deferredgenerator_tfailure.py | _deferGenerator | def _deferGenerator(g, deferred=None):
"""
See L{waitForDeferred}.
"""
result = None
while 1:
if deferred is None:
deferred = defer.Deferred()
try:
result = g.next()
except StopIteration:
deferred.callback(result)
return deferre... | python | def _deferGenerator(g, deferred=None):
"""
See L{waitForDeferred}.
"""
result = None
while 1:
if deferred is None:
deferred = defer.Deferred()
try:
result = g.next()
except StopIteration:
deferred.callback(result)
return deferre... | [
"def",
"_deferGenerator",
"(",
"g",
",",
"deferred",
"=",
"None",
")",
":",
"result",
"=",
"None",
"while",
"1",
":",
"if",
"deferred",
"is",
"None",
":",
"deferred",
"=",
"defer",
".",
"Deferred",
"(",
")",
"try",
":",
"result",
"=",
"g",
".",
"ne... | See L{waitForDeferred}. | [
"See",
"L",
"{",
"waitForDeferred",
"}",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/deferredgenerator_tfailure.py#L11-L51 |
SmartTeleMax/iktomi | iktomi/unstable/utils/functools.py | return_locals | def return_locals(func):
'''Modifies decorated function to return its locals'''
@functools.wraps(func)
def wrap(*args, **kwargs):
frames = []
def tracer(frame, event, arg): # pragma: no cover
# coverage does not work in this function because the tracer
# is deactiva... | python | def return_locals(func):
'''Modifies decorated function to return its locals'''
@functools.wraps(func)
def wrap(*args, **kwargs):
frames = []
def tracer(frame, event, arg): # pragma: no cover
# coverage does not work in this function because the tracer
# is deactiva... | [
"def",
"return_locals",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrap",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"frames",
"=",
"[",
"]",
"def",
"tracer",
"(",
"frame",
",",
"event",
",",
"arg",... | Modifies decorated function to return its locals | [
"Modifies",
"decorated",
"function",
"to",
"return",
"its",
"locals"
] | train | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/unstable/utils/functools.py#L6-L38 |
SmartTeleMax/iktomi | iktomi/db/sqla/__init__.py | multidb_binds | def multidb_binds(databases, package=None, engine_params=None):
'''Creates dictionary to be passed as `binds` parameter to
`sqlalchemy.orm.sessionmaker()` from dictionary mapping models module name
to connection URI that should be used for these models. Models module must
have `metadata` attribute. `pac... | python | def multidb_binds(databases, package=None, engine_params=None):
'''Creates dictionary to be passed as `binds` parameter to
`sqlalchemy.orm.sessionmaker()` from dictionary mapping models module name
to connection URI that should be used for these models. Models module must
have `metadata` attribute. `pac... | [
"def",
"multidb_binds",
"(",
"databases",
",",
"package",
"=",
"None",
",",
"engine_params",
"=",
"None",
")",
":",
"engine_params",
"=",
"engine_params",
"or",
"{",
"}",
"if",
"not",
"(",
"package",
"is",
"None",
"or",
"isinstance",
"(",
"package",
",",
... | Creates dictionary to be passed as `binds` parameter to
`sqlalchemy.orm.sessionmaker()` from dictionary mapping models module name
to connection URI that should be used for these models. Models module must
have `metadata` attribute. `package` when set must be a package or package
name for all models mod... | [
"Creates",
"dictionary",
"to",
"be",
"passed",
"as",
"binds",
"parameter",
"to",
"sqlalchemy",
".",
"orm",
".",
"sessionmaker",
"()",
"from",
"dictionary",
"mapping",
"models",
"module",
"name",
"to",
"connection",
"URI",
"that",
"should",
"be",
"used",
"for",... | train | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/db/sqla/__init__.py#L8-L32 |
twisted/epsilon | epsilon/descriptor.py | requiredAttribute | def requiredAttribute(requiredAttributeName):
"""
Utility for defining attributes on base classes/mixins which require their
values to be supplied by their derived classes. C{None} is a common, but
almost never suitable default value for these kinds of attributes, as it
may cause operations in the ... | python | def requiredAttribute(requiredAttributeName):
"""
Utility for defining attributes on base classes/mixins which require their
values to be supplied by their derived classes. C{None} is a common, but
almost never suitable default value for these kinds of attributes, as it
may cause operations in the ... | [
"def",
"requiredAttribute",
"(",
"requiredAttributeName",
")",
":",
"class",
"RequiredAttribute",
"(",
"attribute",
")",
":",
"def",
"get",
"(",
"self",
")",
":",
"if",
"requiredAttributeName",
"not",
"in",
"self",
".",
"__dict__",
":",
"raise",
"AttributeError"... | Utility for defining attributes on base classes/mixins which require their
values to be supplied by their derived classes. C{None} is a common, but
almost never suitable default value for these kinds of attributes, as it
may cause operations in the derived class to fail silently in peculiar
ways. If a... | [
"Utility",
"for",
"defining",
"attributes",
"on",
"base",
"classes",
"/",
"mixins",
"which",
"require",
"their",
"values",
"to",
"be",
"supplied",
"by",
"their",
"derived",
"classes",
".",
"C",
"{",
"None",
"}",
"is",
"a",
"common",
"but",
"almost",
"never... | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/descriptor.py#L96-L143 |
project-ncl/pnc-cli | pnc_cli/builds.py | list_builds | def list_builds(page_size=200, page_index=0, sort="", q=""):
"""
List all builds
:param page_size: number of builds returned per query
:param sort: RSQL sorting query
:param q: RSQL query
:return:
"""
response = utils.checked_api_call(pnc_api.builds_running, 'get_all', page_size=page_siz... | python | def list_builds(page_size=200, page_index=0, sort="", q=""):
"""
List all builds
:param page_size: number of builds returned per query
:param sort: RSQL sorting query
:param q: RSQL query
:return:
"""
response = utils.checked_api_call(pnc_api.builds_running, 'get_all', page_size=page_siz... | [
"def",
"list_builds",
"(",
"page_size",
"=",
"200",
",",
"page_index",
"=",
"0",
",",
"sort",
"=",
"\"\"",
",",
"q",
"=",
"\"\"",
")",
":",
"response",
"=",
"utils",
".",
"checked_api_call",
"(",
"pnc_api",
".",
"builds_running",
",",
"'get_all'",
",",
... | List all builds
:param page_size: number of builds returned per query
:param sort: RSQL sorting query
:param q: RSQL query
:return: | [
"List",
"all",
"builds",
":",
"param",
"page_size",
":",
"number",
"of",
"builds",
"returned",
"per",
"query",
":",
"param",
"sort",
":",
"RSQL",
"sorting",
"query",
":",
"param",
"q",
":",
"RSQL",
"query",
":",
"return",
":"
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/builds.py#L16-L26 |
project-ncl/pnc-cli | pnc_cli/generate_repo.py | generate_repo_list | def generate_repo_list(product_name=None, product_version=None, product_milestone=None):
"""
Generates list of artifacts for offline repository.
"""
if not validate_input_parameters(product_name, product_version, product_milestone):
sys.exit(1)
product_version = pnc_api.product_versions.get_... | python | def generate_repo_list(product_name=None, product_version=None, product_milestone=None):
"""
Generates list of artifacts for offline repository.
"""
if not validate_input_parameters(product_name, product_version, product_milestone):
sys.exit(1)
product_version = pnc_api.product_versions.get_... | [
"def",
"generate_repo_list",
"(",
"product_name",
"=",
"None",
",",
"product_version",
"=",
"None",
",",
"product_milestone",
"=",
"None",
")",
":",
"if",
"not",
"validate_input_parameters",
"(",
"product_name",
",",
"product_version",
",",
"product_milestone",
")",... | Generates list of artifacts for offline repository. | [
"Generates",
"list",
"of",
"artifacts",
"for",
"offline",
"repository",
"."
] | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/generate_repo.py#L12-L35 |
project-ncl/pnc-cli | pnc_cli/user_config.py | login | def login(username=None, password=None):
"""
Log in to PNC using the supplied username and password. The keycloak token will
be saved for all subsequent pnc-cli operations until login is called again
:return:
"""
global user
user = UserConfig()
if username:
user.username = userna... | python | def login(username=None, password=None):
"""
Log in to PNC using the supplied username and password. The keycloak token will
be saved for all subsequent pnc-cli operations until login is called again
:return:
"""
global user
user = UserConfig()
if username:
user.username = userna... | [
"def",
"login",
"(",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"global",
"user",
"user",
"=",
"UserConfig",
"(",
")",
"if",
"username",
":",
"user",
".",
"username",
"=",
"username",
"else",
":",
"user",
".",
"username",
"=",
"... | Log in to PNC using the supplied username and password. The keycloak token will
be saved for all subsequent pnc-cli operations until login is called again
:return: | [
"Log",
"in",
"to",
"PNC",
"using",
"the",
"supplied",
"username",
"and",
"password",
".",
"The",
"keycloak",
"token",
"will",
"be",
"saved",
"for",
"all",
"subsequent",
"pnc",
"-",
"cli",
"operations",
"until",
"login",
"is",
"called",
"again",
":",
"retur... | train | https://github.com/project-ncl/pnc-cli/blob/3dc149bf84928f60a8044ac50b58bbaddd451902/pnc_cli/user_config.py#L265-L288 |
twisted/epsilon | epsilon/hotfixes/delayedcall_seconds.py | DelayedCall.cancel | def cancel(self):
"""Unschedule this call
@raise AlreadyCancelled: Raised if this call has already been
unscheduled.
@raise AlreadyCalled: Raised if this call has already been made.
"""
if self.cancelled:
raise error.AlreadyCancelled
elif self.called... | python | def cancel(self):
"""Unschedule this call
@raise AlreadyCancelled: Raised if this call has already been
unscheduled.
@raise AlreadyCalled: Raised if this call has already been made.
"""
if self.cancelled:
raise error.AlreadyCancelled
elif self.called... | [
"def",
"cancel",
"(",
"self",
")",
":",
"if",
"self",
".",
"cancelled",
":",
"raise",
"error",
".",
"AlreadyCancelled",
"elif",
"self",
".",
"called",
":",
"raise",
"error",
".",
"AlreadyCalled",
"else",
":",
"self",
".",
"canceller",
"(",
"self",
")",
... | Unschedule this call
@raise AlreadyCancelled: Raised if this call has already been
unscheduled.
@raise AlreadyCalled: Raised if this call has already been made. | [
"Unschedule",
"this",
"call"
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/delayedcall_seconds.py#L38-L55 |
twisted/epsilon | epsilon/hotfixes/delayedcall_seconds.py | DelayedCall.reset | def reset(self, secondsFromNow):
"""Reschedule this call for a different time
@type secondsFromNow: C{float}
@param secondsFromNow: The number of seconds from the time of the
C{reset} call at which this call will be scheduled.
@raise AlreadyCancelled: Raised if this call has be... | python | def reset(self, secondsFromNow):
"""Reschedule this call for a different time
@type secondsFromNow: C{float}
@param secondsFromNow: The number of seconds from the time of the
C{reset} call at which this call will be scheduled.
@raise AlreadyCancelled: Raised if this call has be... | [
"def",
"reset",
"(",
"self",
",",
"secondsFromNow",
")",
":",
"if",
"self",
".",
"cancelled",
":",
"raise",
"error",
".",
"AlreadyCancelled",
"elif",
"self",
".",
"called",
":",
"raise",
"error",
".",
"AlreadyCalled",
"else",
":",
"if",
"self",
".",
"sec... | Reschedule this call for a different time
@type secondsFromNow: C{float}
@param secondsFromNow: The number of seconds from the time of the
C{reset} call at which this call will be scheduled.
@raise AlreadyCancelled: Raised if this call has been cancelled.
@raise AlreadyCalled: ... | [
"Reschedule",
"this",
"call",
"for",
"a",
"different",
"time"
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/delayedcall_seconds.py#L57-L81 |
twisted/epsilon | epsilon/hotfixes/delayedcall_seconds.py | DelayedCall.delay | def delay(self, secondsLater):
"""Reschedule this call for a later time
@type secondsLater: C{float}
@param secondsLater: The number of seconds after the originally
scheduled time for which to reschedule this call.
@raise AlreadyCancelled: Raised if this call has been cancelled... | python | def delay(self, secondsLater):
"""Reschedule this call for a later time
@type secondsLater: C{float}
@param secondsLater: The number of seconds after the originally
scheduled time for which to reschedule this call.
@raise AlreadyCancelled: Raised if this call has been cancelled... | [
"def",
"delay",
"(",
"self",
",",
"secondsLater",
")",
":",
"if",
"self",
".",
"cancelled",
":",
"raise",
"error",
".",
"AlreadyCancelled",
"elif",
"self",
".",
"called",
":",
"raise",
"error",
".",
"AlreadyCalled",
"else",
":",
"self",
".",
"delayed_time"... | Reschedule this call for a later time
@type secondsLater: C{float}
@param secondsLater: The number of seconds after the originally
scheduled time for which to reschedule this call.
@raise AlreadyCancelled: Raised if this call has been cancelled.
@raise AlreadyCalled: Raised if ... | [
"Reschedule",
"this",
"call",
"for",
"a",
"later",
"time"
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/epsilon/hotfixes/delayedcall_seconds.py#L83-L101 |
twisted/epsilon | doc/listings/amp/auth_server.py | main | def main():
"""
Start the AMP server and the reactor.
"""
startLogging(stdout)
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("testuser", "examplepass")
realm = AdditionRealm()
factory = CredAMPServerFactory(Portal(realm, [checker]))
reactor.listenTCP(7805, facto... | python | def main():
"""
Start the AMP server and the reactor.
"""
startLogging(stdout)
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("testuser", "examplepass")
realm = AdditionRealm()
factory = CredAMPServerFactory(Portal(realm, [checker]))
reactor.listenTCP(7805, facto... | [
"def",
"main",
"(",
")",
":",
"startLogging",
"(",
"stdout",
")",
"checker",
"=",
"InMemoryUsernamePasswordDatabaseDontUse",
"(",
")",
"checker",
".",
"addUser",
"(",
"\"testuser\"",
",",
"\"examplepass\"",
")",
"realm",
"=",
"AdditionRealm",
"(",
")",
"factory"... | Start the AMP server and the reactor. | [
"Start",
"the",
"AMP",
"server",
"and",
"the",
"reactor",
"."
] | train | https://github.com/twisted/epsilon/blob/e85fa985a41983ef06e1d3bb26639181e1f78b24/doc/listings/amp/auth_server.py#L63-L73 |
jedie/django-cms-tools | django_cms_tools/plugin_landing_page/views.py | LandingPageDetailView.set_meta | def set_meta(self, instance):
"""
Set django-meta stuff from LandingPageModel instance.
"""
self.use_title_tag = True
self.title = instance.title | python | def set_meta(self, instance):
"""
Set django-meta stuff from LandingPageModel instance.
"""
self.use_title_tag = True
self.title = instance.title | [
"def",
"set_meta",
"(",
"self",
",",
"instance",
")",
":",
"self",
".",
"use_title_tag",
"=",
"True",
"self",
".",
"title",
"=",
"instance",
".",
"title"
] | Set django-meta stuff from LandingPageModel instance. | [
"Set",
"django",
"-",
"meta",
"stuff",
"from",
"LandingPageModel",
"instance",
"."
] | train | https://github.com/jedie/django-cms-tools/blob/0a70dbbb6f770f5a73c8ecd174d5559a37262792/django_cms_tools/plugin_landing_page/views.py#L36-L41 |
SmartTeleMax/iktomi | iktomi/forms/perms.py | FieldPerm.check | def check(self, field):
'''
Returns permissions determined by object itself
'''
if self.permissions is None:
return field.parent.permissions
return self.permissions | python | def check(self, field):
'''
Returns permissions determined by object itself
'''
if self.permissions is None:
return field.parent.permissions
return self.permissions | [
"def",
"check",
"(",
"self",
",",
"field",
")",
":",
"if",
"self",
".",
"permissions",
"is",
"None",
":",
"return",
"field",
".",
"parent",
".",
"permissions",
"return",
"self",
".",
"permissions"
] | Returns permissions determined by object itself | [
"Returns",
"permissions",
"determined",
"by",
"object",
"itself"
] | train | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/forms/perms.py#L77-L83 |
PythonRails/rails | rails/views/__init__.py | View._load_view | def _load_view(self, template_engine_name, template_dir):
"""
Load view by name and return an instance.
"""
file_name = template_engine_name.lower()
class_name = "{}View".format(template_engine_name.title())
try:
view_module = import_module("rails.views.{}".fo... | python | def _load_view(self, template_engine_name, template_dir):
"""
Load view by name and return an instance.
"""
file_name = template_engine_name.lower()
class_name = "{}View".format(template_engine_name.title())
try:
view_module = import_module("rails.views.{}".fo... | [
"def",
"_load_view",
"(",
"self",
",",
"template_engine_name",
",",
"template_dir",
")",
":",
"file_name",
"=",
"template_engine_name",
".",
"lower",
"(",
")",
"class_name",
"=",
"\"{}View\"",
".",
"format",
"(",
"template_engine_name",
".",
"title",
"(",
")",
... | Load view by name and return an instance. | [
"Load",
"view",
"by",
"name",
"and",
"return",
"an",
"instance",
"."
] | train | https://github.com/PythonRails/rails/blob/1e199b9da4da5b24fef39fc6212d71fc9fbb18a5/rails/views/__init__.py#L18-L29 |
SmartTeleMax/iktomi | iktomi/utils/system.py | terminate | def terminate(pid, sig, timeout):
'''Terminates process with PID `pid` and returns True if process finished
during `timeout`. Current user must have permission to access process
information.'''
os.kill(pid, sig)
start = time.time()
while True:
try:
# This is requireed if it's... | python | def terminate(pid, sig, timeout):
'''Terminates process with PID `pid` and returns True if process finished
during `timeout`. Current user must have permission to access process
information.'''
os.kill(pid, sig)
start = time.time()
while True:
try:
# This is requireed if it's... | [
"def",
"terminate",
"(",
"pid",
",",
"sig",
",",
"timeout",
")",
":",
"os",
".",
"kill",
"(",
"pid",
",",
"sig",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"try",
":",
"# This is requireed if it's our child to avoid zombie. Als... | Terminates process with PID `pid` and returns True if process finished
during `timeout`. Current user must have permission to access process
information. | [
"Terminates",
"process",
"with",
"PID",
"pid",
"and",
"returns",
"True",
"if",
"process",
"finished",
"during",
"timeout",
".",
"Current",
"user",
"must",
"have",
"permission",
"to",
"access",
"process",
"information",
"."
] | train | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/utils/system.py#L18-L39 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.