repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
rsgalloway/grit
grit/repo/local.py
Local._get_parent
def _get_parent(self): """:return: Remote origin as Proxy instance""" _dir = os.path.dirname(self.path) if is_repo(_dir): return Local(_dir) else: return None
python
def _get_parent(self): """:return: Remote origin as Proxy instance""" _dir = os.path.dirname(self.path) if is_repo(_dir): return Local(_dir) else: return None
[ "def", "_get_parent", "(", "self", ")", ":", "_dir", "=", "os", ".", "path", ".", "dirname", "(", "self", ".", "path", ")", "if", "is_repo", "(", "_dir", ")", ":", "return", "Local", "(", "_dir", ")", "else", ":", "return", "None" ]
:return: Remote origin as Proxy instance
[ ":", "return", ":", "Remote", "origin", "as", "Proxy", "instance" ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L121-L127
train
Return Remote origin as Proxy instance
rsgalloway/grit
grit/repo/local.py
Local.setVersion
def setVersion(self, version): """ Checkout a version of the repo. :param version: Version number. """ try: sha = self.versions(version).commit.sha self.git.reset("--hard", sha) except Exception, e: raise RepoError(e)
python
def setVersion(self, version): """ Checkout a version of the repo. :param version: Version number. """ try: sha = self.versions(version).commit.sha self.git.reset("--hard", sha) except Exception, e: raise RepoError(e)
[ "def", "setVersion", "(", "self", ",", "version", ")", ":", "try", ":", "sha", "=", "self", ".", "versions", "(", "version", ")", ".", "commit", ".", "sha", "self", ".", "git", ".", "reset", "(", "\"--hard\"", ",", "sha", ")", "except", "Exception", ...
Checkout a version of the repo. :param version: Version number.
[ "Checkout", "a", "version", "of", "the", "repo", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L159-L169
train
Checkout a version of the repo.
rsgalloway/grit
grit/repo/local.py
Local._commits
def _commits(self, head='HEAD'): """Returns a list of the commits reachable from head. :return: List of commit objects. the first of which will be the commit of head, then following theat will be the parents. :raise: RepoError if any no commits are referenced, including if the ...
python
def _commits(self, head='HEAD'): """Returns a list of the commits reachable from head. :return: List of commit objects. the first of which will be the commit of head, then following theat will be the parents. :raise: RepoError if any no commits are referenced, including if the ...
[ "def", "_commits", "(", "self", ",", "head", "=", "'HEAD'", ")", ":", "pending_commits", "=", "[", "head", "]", "history", "=", "[", "]", "while", "pending_commits", "!=", "[", "]", ":", "head", "=", "pending_commits", ".", "pop", "(", "0", ")", "try...
Returns a list of the commits reachable from head. :return: List of commit objects. the first of which will be the commit of head, then following theat will be the parents. :raise: RepoError if any no commits are referenced, including if the head parameter isn't the sha of a commit.
[ "Returns", "a", "list", "of", "the", "commits", "reachable", "from", "head", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L171-L199
train
Returns a list of the commits reachable from head.
rsgalloway/grit
grit/repo/local.py
Local.versions
def versions(self, version=None): """ List of Versions of this repository. :param version: Version index. :param rev: Commit sha or ref. :return: List of Version objects matching params. """ try: versions = [Version(self, c) for c in self._commits()]...
python
def versions(self, version=None): """ List of Versions of this repository. :param version: Version index. :param rev: Commit sha or ref. :return: List of Version objects matching params. """ try: versions = [Version(self, c) for c in self._commits()]...
[ "def", "versions", "(", "self", ",", "version", "=", "None", ")", ":", "try", ":", "versions", "=", "[", "Version", "(", "self", ",", "c", ")", "for", "c", "in", "self", ".", "_commits", "(", ")", "]", "except", "Exception", ",", "e", ":", "log",...
List of Versions of this repository. :param version: Version index. :param rev: Commit sha or ref. :return: List of Version objects matching params.
[ "List", "of", "Versions", "of", "this", "repository", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L201-L220
train
Return a list of Version objects matching the given params.
rsgalloway/grit
grit/repo/local.py
Local.setDescription
def setDescription(self, desc='No description'): """sets repository description""" try: self._put_named_file('description', desc) except Exception, e: raise RepoError(e)
python
def setDescription(self, desc='No description'): """sets repository description""" try: self._put_named_file('description', desc) except Exception, e: raise RepoError(e)
[ "def", "setDescription", "(", "self", ",", "desc", "=", "'No description'", ")", ":", "try", ":", "self", ".", "_put_named_file", "(", "'description'", ",", "desc", ")", "except", "Exception", ",", "e", ":", "raise", "RepoError", "(", "e", ")" ]
sets repository description
[ "sets", "repository", "description" ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L229-L234
train
sets repository description
rsgalloway/grit
grit/repo/local.py
Local.new
def new(self, path, desc=None, bare=True): """ Create a new bare repo.Local instance. :param path: Path to new repo. :param desc: Repo description. :param bare: Create as bare repo. :returns: New repo.Local instance. """ if os.path.exists(path): ...
python
def new(self, path, desc=None, bare=True): """ Create a new bare repo.Local instance. :param path: Path to new repo. :param desc: Repo description. :param bare: Create as bare repo. :returns: New repo.Local instance. """ if os.path.exists(path): ...
[ "def", "new", "(", "self", ",", "path", ",", "desc", "=", "None", ",", "bare", "=", "True", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "raise", "RepoError", "(", "'Path already exists: %s'", "%", "path", ")", "try", ":...
Create a new bare repo.Local instance. :param path: Path to new repo. :param desc: Repo description. :param bare: Create as bare repo. :returns: New repo.Local instance.
[ "Create", "a", "new", "bare", "repo", ".", "Local", "instance", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L246-L272
train
Create a new bare repo. Local instance.
rsgalloway/grit
grit/repo/local.py
Local.branch
def branch(self, name, desc=None): """ Create a branch of this repo at 'name'. :param name: Name of new branch :param desc: Repo description. :return: New Local instance. """ return Local.new(path=os.path.join(self.path, name), desc=desc, bare=True)
python
def branch(self, name, desc=None): """ Create a branch of this repo at 'name'. :param name: Name of new branch :param desc: Repo description. :return: New Local instance. """ return Local.new(path=os.path.join(self.path, name), desc=desc, bare=True)
[ "def", "branch", "(", "self", ",", "name", ",", "desc", "=", "None", ")", ":", "return", "Local", ".", "new", "(", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "name", ")", ",", "desc", "=", "desc", ",", "bare", ...
Create a branch of this repo at 'name'. :param name: Name of new branch :param desc: Repo description. :return: New Local instance.
[ "Create", "a", "branch", "of", "this", "repo", "at", "name", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L274-L283
train
Create a branch of this repo at name.
rsgalloway/grit
grit/repo/local.py
Local.addItem
def addItem(self, item, message=None): """add a new Item class object""" if message is None: message = 'Adding item %s' % item.path try: v = Version.new(repo=self) v.addItem(item) v.save(message) except VersionError, e: raise Re...
python
def addItem(self, item, message=None): """add a new Item class object""" if message is None: message = 'Adding item %s' % item.path try: v = Version.new(repo=self) v.addItem(item) v.save(message) except VersionError, e: raise Re...
[ "def", "addItem", "(", "self", ",", "item", ",", "message", "=", "None", ")", ":", "if", "message", "is", "None", ":", "message", "=", "'Adding item %s'", "%", "item", ".", "path", "try", ":", "v", "=", "Version", ".", "new", "(", "repo", "=", "sel...
add a new Item class object
[ "add", "a", "new", "Item", "class", "object" ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L290-L299
train
add a new Item class object
rsgalloway/grit
grit/repo/local.py
Local.items
def items(self, path=None, version=None): """ Returns a list of items. :param path: Regex filter on item path. :param version: Repo versions number/index. :return: List of Item class objects. """ if version is None: version = -1 items = {} ...
python
def items(self, path=None, version=None): """ Returns a list of items. :param path: Regex filter on item path. :param version: Repo versions number/index. :return: List of Item class objects. """ if version is None: version = -1 items = {} ...
[ "def", "items", "(", "self", ",", "path", "=", "None", ",", "version", "=", "None", ")", ":", "if", "version", "is", "None", ":", "version", "=", "-", "1", "items", "=", "{", "}", "for", "item", "in", "self", ".", "versions", "(", "version", ")",...
Returns a list of items. :param path: Regex filter on item path. :param version: Repo versions number/index. :return: List of Item class objects.
[ "Returns", "a", "list", "of", "items", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/local.py#L305-L334
train
Returns a list of items.
BernardFW/bernard
src/bernard/platforms/telegram/_utils.py
set_reply_markup
async def set_reply_markup(msg: Dict, request: 'Request', stack: 'Stack') \ -> None: """ Add the "reply markup" to a message from the layers :param msg: Message dictionary :param request: Current request being replied :param stack: Stack to analyze """ from bernard.platforms.telegr...
python
async def set_reply_markup(msg: Dict, request: 'Request', stack: 'Stack') \ -> None: """ Add the "reply markup" to a message from the layers :param msg: Message dictionary :param request: Current request being replied :param stack: Stack to analyze """ from bernard.platforms.telegr...
[ "async", "def", "set_reply_markup", "(", "msg", ":", "Dict", ",", "request", ":", "'Request'", ",", "stack", ":", "'Stack'", ")", "->", "None", ":", "from", "bernard", ".", "platforms", ".", "telegram", ".", "layers", "import", "InlineKeyboard", ",", "Repl...
Add the "reply markup" to a message from the layers :param msg: Message dictionary :param request: Current request being replied :param stack: Stack to analyze
[ "Add", "the", "reply", "markup", "to", "a", "message", "from", "the", "layers" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/telegram/_utils.py#L11-L42
train
Add the reply markup to a message from the layers that are currently being processed.
BernardFW/bernard
src/bernard/i18n/utils.py
split_locale
def split_locale(locale: Text) -> Tuple[Text, Optional[Text]]: """ Decompose the locale into a normalized tuple. The first item is the locale (as lowercase letters) while the second item is either the country as lower case either None if no country was supplied. """ items = re.split(r'[_\-]', ...
python
def split_locale(locale: Text) -> Tuple[Text, Optional[Text]]: """ Decompose the locale into a normalized tuple. The first item is the locale (as lowercase letters) while the second item is either the country as lower case either None if no country was supplied. """ items = re.split(r'[_\-]', ...
[ "def", "split_locale", "(", "locale", ":", "Text", ")", "->", "Tuple", "[", "Text", ",", "Optional", "[", "Text", "]", "]", ":", "items", "=", "re", ".", "split", "(", "r'[_\\-]'", ",", "locale", ".", "lower", "(", ")", ",", "1", ")", "try", ":",...
Decompose the locale into a normalized tuple. The first item is the locale (as lowercase letters) while the second item is either the country as lower case either None if no country was supplied.
[ "Decompose", "the", "locale", "into", "a", "normalized", "tuple", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/utils.py#L14-L27
train
Decomposes the locale into a normalized tuple.
BernardFW/bernard
src/bernard/i18n/utils.py
compare_locales
def compare_locales(a, b): """ Compares two locales to find the level of compatibility :param a: First locale :param b: Second locale :return: 2 full match, 1 lang match, 0 no match """ if a is None or b is None: if a == b: return 2 else: return 0 ...
python
def compare_locales(a, b): """ Compares two locales to find the level of compatibility :param a: First locale :param b: Second locale :return: 2 full match, 1 lang match, 0 no match """ if a is None or b is None: if a == b: return 2 else: return 0 ...
[ "def", "compare_locales", "(", "a", ",", "b", ")", ":", "if", "a", "is", "None", "or", "b", "is", "None", ":", "if", "a", "==", "b", ":", "return", "2", "else", ":", "return", "0", "a", "=", "split_locale", "(", "a", ")", "b", "=", "split_local...
Compares two locales to find the level of compatibility :param a: First locale :param b: Second locale :return: 2 full match, 1 lang match, 0 no match
[ "Compares", "two", "locales", "to", "find", "the", "level", "of", "compatibility" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/utils.py#L30-L53
train
Compares two locales to find the level of compatibility
BernardFW/bernard
src/bernard/i18n/utils.py
LocalesDict.list_locales
def list_locales(self) -> List[Optional[Text]]: """ Returns the list of available locales. The first locale is the default locale to be used. If no locales are known, then `None` will be the first item. """ locales = list(self.dict.keys()) if not locales: ...
python
def list_locales(self) -> List[Optional[Text]]: """ Returns the list of available locales. The first locale is the default locale to be used. If no locales are known, then `None` will be the first item. """ locales = list(self.dict.keys()) if not locales: ...
[ "def", "list_locales", "(", "self", ")", "->", "List", "[", "Optional", "[", "Text", "]", "]", ":", "locales", "=", "list", "(", "self", ".", "dict", ".", "keys", "(", ")", ")", "if", "not", "locales", ":", "locales", ".", "append", "(", "None", ...
Returns the list of available locales. The first locale is the default locale to be used. If no locales are known, then `None` will be the first item.
[ "Returns", "the", "list", "of", "available", "locales", ".", "The", "first", "locale", "is", "the", "default", "locale", "to", "be", "used", ".", "If", "no", "locales", "are", "known", "then", "None", "will", "be", "the", "first", "item", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/utils.py#L61-L73
train
Returns the list of available locales.
BernardFW/bernard
src/bernard/i18n/utils.py
LocalesDict.choose_locale
def choose_locale(self, locale: Text) -> Text: """ Returns the best matching locale in what is available. :param locale: Locale to match :return: Locale to use """ if locale not in self._choice_cache: locales = self.list_locales() best_choice = ...
python
def choose_locale(self, locale: Text) -> Text: """ Returns the best matching locale in what is available. :param locale: Locale to match :return: Locale to use """ if locale not in self._choice_cache: locales = self.list_locales() best_choice = ...
[ "def", "choose_locale", "(", "self", ",", "locale", ":", "Text", ")", "->", "Text", ":", "if", "locale", "not", "in", "self", ".", "_choice_cache", ":", "locales", "=", "self", ".", "list_locales", "(", ")", "best_choice", "=", "locales", "[", "0", "]"...
Returns the best matching locale in what is available. :param locale: Locale to match :return: Locale to use
[ "Returns", "the", "best", "matching", "locale", "in", "what", "is", "available", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/utils.py#L75-L98
train
Returns the best matching locale in what is available.
BernardFW/bernard
src/bernard/i18n/utils.py
LocalesFlatDict.update
def update(self, new_data: Dict[Text, Dict[Text, Text]]): """ Receive an update from a loader. :param new_data: New translation data from the loader """ for locale, data in new_data.items(): if locale not in self.dict: self.dict[locale] = {} ...
python
def update(self, new_data: Dict[Text, Dict[Text, Text]]): """ Receive an update from a loader. :param new_data: New translation data from the loader """ for locale, data in new_data.items(): if locale not in self.dict: self.dict[locale] = {} ...
[ "def", "update", "(", "self", ",", "new_data", ":", "Dict", "[", "Text", ",", "Dict", "[", "Text", ",", "Text", "]", "]", ")", ":", "for", "locale", ",", "data", "in", "new_data", ".", "items", "(", ")", ":", "if", "locale", "not", "in", "self", ...
Receive an update from a loader. :param new_data: New translation data from the loader
[ "Receive", "an", "update", "from", "a", "loader", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/i18n/utils.py#L109-L120
train
Receive an update from a loader.
BernardFW/bernard
src/bernard/platforms/facebook/helpers.py
UrlButton._make_url
async def _make_url(self, url: Text, request: 'Request') -> Text: """ Signs the URL if needed """ if self.sign_webview: return await request.sign_url(url) return url
python
async def _make_url(self, url: Text, request: 'Request') -> Text: """ Signs the URL if needed """ if self.sign_webview: return await request.sign_url(url) return url
[ "async", "def", "_make_url", "(", "self", ",", "url", ":", "Text", ",", "request", ":", "'Request'", ")", "->", "Text", ":", "if", "self", ".", "sign_webview", ":", "return", "await", "request", ".", "sign_url", "(", "url", ")", "return", "url" ]
Signs the URL if needed
[ "Signs", "the", "URL", "if", "needed" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/helpers.py#L125-L133
train
Signs the URL if needed
BernardFW/bernard
src/bernard/platforms/facebook/helpers.py
Card.is_sharable
def is_sharable(self): """ Make sure that nothing inside blocks sharing. """ if self.buttons: return (all(b.is_sharable() for b in self.buttons) and self.default_action and self.default_action.is_sharable())
python
def is_sharable(self): """ Make sure that nothing inside blocks sharing. """ if self.buttons: return (all(b.is_sharable() for b in self.buttons) and self.default_action and self.default_action.is_sharable())
[ "def", "is_sharable", "(", "self", ")", ":", "if", "self", ".", "buttons", ":", "return", "(", "all", "(", "b", ".", "is_sharable", "(", ")", "for", "b", "in", "self", ".", "buttons", ")", "and", "self", ".", "default_action", "and", "self", ".", "...
Make sure that nothing inside blocks sharing.
[ "Make", "sure", "that", "nothing", "inside", "blocks", "sharing", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/facebook/helpers.py#L306-L313
train
Check if this object is sharable.
ioos/cc-plugin-ncei
cc_plugin_ncei/ncei_grid.py
NCEIGridBase.check_bounds_variables
def check_bounds_variables(self, dataset): ''' Checks the grid boundary variables. :param netCDF4.Dataset dataset: An open netCDF dataset ''' recommended_ctx = TestCtx(BaseCheck.MEDIUM, 'Recommended variables to describe grid boundaries') bounds_map = { 'lat...
python
def check_bounds_variables(self, dataset): ''' Checks the grid boundary variables. :param netCDF4.Dataset dataset: An open netCDF dataset ''' recommended_ctx = TestCtx(BaseCheck.MEDIUM, 'Recommended variables to describe grid boundaries') bounds_map = { 'lat...
[ "def", "check_bounds_variables", "(", "self", ",", "dataset", ")", ":", "recommended_ctx", "=", "TestCtx", "(", "BaseCheck", ".", "MEDIUM", ",", "'Recommended variables to describe grid boundaries'", ")", "bounds_map", "=", "{", "'lat_bounds'", ":", "{", "'units'", ...
Checks the grid boundary variables. :param netCDF4.Dataset dataset: An open netCDF dataset
[ "Checks", "the", "grid", "boundary", "variables", "." ]
963fefd7fa43afd32657ac4c36aad4ddb4c25acf
https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_grid.py#L42-L93
train
Checks the grid boundaries variables.
walter426/Python_GoogleMapsApi
GoogleMapsApi/geocode.py
Geocoding.geocode
def geocode(self, string, bounds=None, region=None, language=None, sensor=False): '''Geocode an address. Pls refer to the Google Maps Web API for the details of the parameters ''' if isinstance(string, unicode): string = string.encode('utf-8') params ...
python
def geocode(self, string, bounds=None, region=None, language=None, sensor=False): '''Geocode an address. Pls refer to the Google Maps Web API for the details of the parameters ''' if isinstance(string, unicode): string = string.encode('utf-8') params ...
[ "def", "geocode", "(", "self", ",", "string", ",", "bounds", "=", "None", ",", "region", "=", "None", ",", "language", "=", "None", ",", "sensor", "=", "False", ")", ":", "if", "isinstance", "(", "string", ",", "unicode", ")", ":", "string", "=", "...
Geocode an address. Pls refer to the Google Maps Web API for the details of the parameters
[ "Geocode", "an", "address", ".", "Pls", "refer", "to", "the", "Google", "Maps", "Web", "API", "for", "the", "details", "of", "the", "parameters" ]
4832b293a0027446941a5f00ecc66256f92ddbce
https://github.com/walter426/Python_GoogleMapsApi/blob/4832b293a0027446941a5f00ecc66256f92ddbce/GoogleMapsApi/geocode.py#L34-L63
train
Geocode an address.
walter426/Python_GoogleMapsApi
GoogleMapsApi/geocode.py
Geocoding.reverse
def reverse(self, point, language=None, sensor=False): '''Reverse geocode a point. Pls refer to the Google Maps Web API for the details of the parameters ''' params = { 'latlng': point, 'sensor': str(sensor).lower() } if language: ...
python
def reverse(self, point, language=None, sensor=False): '''Reverse geocode a point. Pls refer to the Google Maps Web API for the details of the parameters ''' params = { 'latlng': point, 'sensor': str(sensor).lower() } if language: ...
[ "def", "reverse", "(", "self", ",", "point", ",", "language", "=", "None", ",", "sensor", "=", "False", ")", ":", "params", "=", "{", "'latlng'", ":", "point", ",", "'sensor'", ":", "str", "(", "sensor", ")", ".", "lower", "(", ")", "}", "if", "l...
Reverse geocode a point. Pls refer to the Google Maps Web API for the details of the parameters
[ "Reverse", "geocode", "a", "point", ".", "Pls", "refer", "to", "the", "Google", "Maps", "Web", "API", "for", "the", "details", "of", "the", "parameters" ]
4832b293a0027446941a5f00ecc66256f92ddbce
https://github.com/walter426/Python_GoogleMapsApi/blob/4832b293a0027446941a5f00ecc66256f92ddbce/GoogleMapsApi/geocode.py#L66-L83
train
Reverse geocode a point.
walter426/Python_GoogleMapsApi
GoogleMapsApi/directions.py
Directions.GetDirections
def GetDirections(self, origin, destination, sensor = False, mode = None, waypoints = None, alternatives = None, avoid = None, language = None, units = None, region = None, departure_time = None, arrival_time = None): '''Get Directions Service Pls refer to the Google Maps Web ...
python
def GetDirections(self, origin, destination, sensor = False, mode = None, waypoints = None, alternatives = None, avoid = None, language = None, units = None, region = None, departure_time = None, arrival_time = None): '''Get Directions Service Pls refer to the Google Maps Web ...
[ "def", "GetDirections", "(", "self", ",", "origin", ",", "destination", ",", "sensor", "=", "False", ",", "mode", "=", "None", ",", "waypoints", "=", "None", ",", "alternatives", "=", "None", ",", "avoid", "=", "None", ",", "language", "=", "None", ","...
Get Directions Service Pls refer to the Google Maps Web API for the details of the remained parameters
[ "Get", "Directions", "Service", "Pls", "refer", "to", "the", "Google", "Maps", "Web", "API", "for", "the", "details", "of", "the", "remained", "parameters" ]
4832b293a0027446941a5f00ecc66256f92ddbce
https://github.com/walter426/Python_GoogleMapsApi/blob/4832b293a0027446941a5f00ecc66256f92ddbce/GoogleMapsApi/directions.py#L33-L79
train
Get Directions Service and return the response.
sthysel/knobs
src/knobs.py
Knob.get_knob_defaults_as_table
def get_knob_defaults_as_table(cls): """ Renders knobs in table :return: """ knob_list = [ { 'Knob': name, 'Description': cls.get_registered_knob(name).description, 'Default': cls.get_registered_knob(name).default ...
python
def get_knob_defaults_as_table(cls): """ Renders knobs in table :return: """ knob_list = [ { 'Knob': name, 'Description': cls.get_registered_knob(name).description, 'Default': cls.get_registered_knob(name).default ...
[ "def", "get_knob_defaults_as_table", "(", "cls", ")", ":", "knob_list", "=", "[", "{", "'Knob'", ":", "name", ",", "'Description'", ":", "cls", ".", "get_registered_knob", "(", "name", ")", ".", "description", ",", "'Default'", ":", "cls", ".", "get_register...
Renders knobs in table :return:
[ "Renders", "knobs", "in", "table", ":", "return", ":" ]
1d01f50f643068076e38118a93fed9375ea3ac81
https://github.com/sthysel/knobs/blob/1d01f50f643068076e38118a93fed9375ea3ac81/src/knobs.py#L163-L176
train
Returns a table of knobs with default values for all knobs in the database.
sthysel/knobs
src/knobs.py
Knob.get_knobs_current_as_table
def get_knobs_current_as_table(cls): """ Renders current knob values in table :return: """ knob_list = [ { 'Knob': name, 'Description': cls.get_registered_knob(name).description, 'Value': cls.get_registered_knob(name)()...
python
def get_knobs_current_as_table(cls): """ Renders current knob values in table :return: """ knob_list = [ { 'Knob': name, 'Description': cls.get_registered_knob(name).description, 'Value': cls.get_registered_knob(name)()...
[ "def", "get_knobs_current_as_table", "(", "cls", ")", ":", "knob_list", "=", "[", "{", "'Knob'", ":", "name", ",", "'Description'", ":", "cls", ".", "get_registered_knob", "(", "name", ")", ".", "description", ",", "'Value'", ":", "cls", ".", "get_registered...
Renders current knob values in table :return:
[ "Renders", "current", "knob", "values", "in", "table", ":", "return", ":" ]
1d01f50f643068076e38118a93fed9375ea3ac81
https://github.com/sthysel/knobs/blob/1d01f50f643068076e38118a93fed9375ea3ac81/src/knobs.py#L179-L192
train
Returns a table of current knobs in table format.
sthysel/knobs
src/knobs.py
Knob.get_knob_defaults
def get_knob_defaults(cls): """ Returns a string with defaults >>> Knob.get_knob_defaults() '# \n# HAVE_RUM=True\n\n# Yar\n# JOLLY_ROGER_PIRATES=124\n\n# Foo Bar\n# WUNDER=BAR\n' """ return '\n'.join( [ '# {description}\n# {knob}={default}\n'.format( ...
python
def get_knob_defaults(cls): """ Returns a string with defaults >>> Knob.get_knob_defaults() '# \n# HAVE_RUM=True\n\n# Yar\n# JOLLY_ROGER_PIRATES=124\n\n# Foo Bar\n# WUNDER=BAR\n' """ return '\n'.join( [ '# {description}\n# {knob}={default}\n'.format( ...
[ "def", "get_knob_defaults", "(", "cls", ")", ":", "return", "'\\n'", ".", "join", "(", "[", "'# {description}\\n# {knob}={default}\\n'", ".", "format", "(", "description", "=", "cls", ".", "get_registered_knob", "(", "name", ")", ".", "description", ",", "knob",...
Returns a string with defaults >>> Knob.get_knob_defaults() '# \n# HAVE_RUM=True\n\n# Yar\n# JOLLY_ROGER_PIRATES=124\n\n# Foo Bar\n# WUNDER=BAR\n'
[ "Returns", "a", "string", "with", "defaults", ">>>", "Knob", ".", "get_knob_defaults", "()", "#", "\\", "n#", "HAVE_RUM", "=", "True", "\\", "n", "\\", "n#", "Yar", "\\", "n#", "JOLLY_ROGER_PIRATES", "=", "124", "\\", "n", "\\", "n#", "Foo", "Bar", "\\...
1d01f50f643068076e38118a93fed9375ea3ac81
https://github.com/sthysel/knobs/blob/1d01f50f643068076e38118a93fed9375ea3ac81/src/knobs.py#L202-L216
train
Returns a string with default values for all knob.
sthysel/knobs
src/knobs.py
ListKnob.get
def get(self): """ convert json env variable if set to list """ self._cast = type([]) source_value = os.getenv(self.env_name) # set the environment if it is not set if source_value is None: os.environ[self.env_name] = json.dumps(self.default) ...
python
def get(self): """ convert json env variable if set to list """ self._cast = type([]) source_value = os.getenv(self.env_name) # set the environment if it is not set if source_value is None: os.environ[self.env_name] = json.dumps(self.default) ...
[ "def", "get", "(", "self", ")", ":", "self", ".", "_cast", "=", "type", "(", "[", "]", ")", "source_value", "=", "os", ".", "getenv", "(", "self", ".", "env_name", ")", "# set the environment if it is not set", "if", "source_value", "is", "None", ":", "o...
convert json env variable if set to list
[ "convert", "json", "env", "variable", "if", "set", "to", "list" ]
1d01f50f643068076e38118a93fed9375ea3ac81
https://github.com/sthysel/knobs/blob/1d01f50f643068076e38118a93fed9375ea3ac81/src/knobs.py#L225-L250
train
get the value of the key from the environment variable if set to list AttributeNames
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
parse_ppi_graph
def parse_ppi_graph(path: str, min_edge_weight: float = 0.0) -> Graph: """Build an undirected graph of gene interactions from edgelist file. :param str path: The path to the edgelist file :param float min_edge_weight: Cutoff to keep/remove the edges, default is 0, but could also be 0.63. :return Graph:...
python
def parse_ppi_graph(path: str, min_edge_weight: float = 0.0) -> Graph: """Build an undirected graph of gene interactions from edgelist file. :param str path: The path to the edgelist file :param float min_edge_weight: Cutoff to keep/remove the edges, default is 0, but could also be 0.63. :return Graph:...
[ "def", "parse_ppi_graph", "(", "path", ":", "str", ",", "min_edge_weight", ":", "float", "=", "0.0", ")", "->", "Graph", ":", "logger", ".", "info", "(", "\"In parse_ppi_graph()\"", ")", "graph", "=", "igraph", ".", "read", "(", "os", ".", "path", ".", ...
Build an undirected graph of gene interactions from edgelist file. :param str path: The path to the edgelist file :param float min_edge_weight: Cutoff to keep/remove the edges, default is 0, but could also be 0.63. :return Graph: Protein-protein interaction graph
[ "Build", "an", "undirected", "graph", "of", "gene", "interactions", "from", "edgelist", "file", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L19-L33
train
Parse a PPI file into a undirected graph of proteins and interactions.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
parse_excel
def parse_excel(file_path: str, entrez_id_header, log_fold_change_header, adjusted_p_value_header, entrez_delimiter, base_mean_header=None) -> List[Gene]: """Read an excel file on differential expression values as Gene objects. :pa...
python
def parse_excel(file_path: str, entrez_id_header, log_fold_change_header, adjusted_p_value_header, entrez_delimiter, base_mean_header=None) -> List[Gene]: """Read an excel file on differential expression values as Gene objects. :pa...
[ "def", "parse_excel", "(", "file_path", ":", "str", ",", "entrez_id_header", ",", "log_fold_change_header", ",", "adjusted_p_value_header", ",", "entrez_delimiter", ",", "base_mean_header", "=", "None", ")", "->", "List", "[", "Gene", "]", ":", "logger", ".", "i...
Read an excel file on differential expression values as Gene objects. :param str file_path: The path to the differential expression file to be parsed. :param config.Params params: An object that includes paths, cutoffs and other information. :return list: A list of Gene objects.
[ "Read", "an", "excel", "file", "on", "differential", "expression", "values", "as", "Gene", "objects", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L36-L59
train
Read an excel file on differential expression values as Gene objects.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
parse_csv
def parse_csv(file_path: str, entrez_id_header, log_fold_change_header, adjusted_p_value_header, entrez_delimiter, base_mean_header=None, sep=",") -> List[Gene]: """Read a csv file on differential expression values as Gene objects. ...
python
def parse_csv(file_path: str, entrez_id_header, log_fold_change_header, adjusted_p_value_header, entrez_delimiter, base_mean_header=None, sep=",") -> List[Gene]: """Read a csv file on differential expression values as Gene objects. ...
[ "def", "parse_csv", "(", "file_path", ":", "str", ",", "entrez_id_header", ",", "log_fold_change_header", ",", "adjusted_p_value_header", ",", "entrez_delimiter", ",", "base_mean_header", "=", "None", ",", "sep", "=", "\",\"", ")", "->", "List", "[", "Gene", "]"...
Read a csv file on differential expression values as Gene objects. :param str file_path: The path to the differential expression file to be parsed. :param config.Params params: An object that includes paths, cutoffs and other information. :return list: A list of Gene objects.
[ "Read", "a", "csv", "file", "on", "differential", "expression", "values", "as", "Gene", "objects", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L62-L86
train
Read a csv file on differential expression values as Gene objects.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
handle_dataframe
def handle_dataframe( df: pd.DataFrame, entrez_id_name, log2_fold_change_name, adjusted_p_value_name, entrez_delimiter, base_mean=None, ) -> List[Gene]: """Convert data frame on differential expression values as Gene objects. :param df: Data frame with columns sh...
python
def handle_dataframe( df: pd.DataFrame, entrez_id_name, log2_fold_change_name, adjusted_p_value_name, entrez_delimiter, base_mean=None, ) -> List[Gene]: """Convert data frame on differential expression values as Gene objects. :param df: Data frame with columns sh...
[ "def", "handle_dataframe", "(", "df", ":", "pd", ".", "DataFrame", ",", "entrez_id_name", ",", "log2_fold_change_name", ",", "adjusted_p_value_name", ",", "entrez_delimiter", ",", "base_mean", "=", "None", ",", ")", "->", "List", "[", "Gene", "]", ":", "logger...
Convert data frame on differential expression values as Gene objects. :param df: Data frame with columns showing values on differential expression. :param cfp: An object that includes paths, cutoffs and other information. :return list: A list of Gene objects.
[ "Convert", "data", "frame", "on", "differential", "expression", "values", "as", "Gene", "objects", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L89-L129
train
Convert a pandas DataFrame to a list of Gene objects.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
parse_gene_list
def parse_gene_list(path: str, graph: Graph, anno_type: str = "name") -> list: """Parse a list of genes and return them if they are in the network. :param str path: The path of input file. :param Graph graph: The graph with genes as nodes. :param str anno_type: The type of annotation with two options:n...
python
def parse_gene_list(path: str, graph: Graph, anno_type: str = "name") -> list: """Parse a list of genes and return them if they are in the network. :param str path: The path of input file. :param Graph graph: The graph with genes as nodes. :param str anno_type: The type of annotation with two options:n...
[ "def", "parse_gene_list", "(", "path", ":", "str", ",", "graph", ":", "Graph", ",", "anno_type", ":", "str", "=", "\"name\"", ")", "->", "list", ":", "# read the file", "genes", "=", "pd", ".", "read_csv", "(", "path", ",", "header", "=", "None", ")", ...
Parse a list of genes and return them if they are in the network. :param str path: The path of input file. :param Graph graph: The graph with genes as nodes. :param str anno_type: The type of annotation with two options:name-Entrez ID, symbol-HGNC symbol. :return list: A list of genes, all of which are...
[ "Parse", "a", "list", "of", "genes", "and", "return", "them", "if", "they", "are", "in", "the", "network", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L132-L155
train
Parse a list of genes and return them if they are in the network.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
parse_disease_ids
def parse_disease_ids(path: str): """Parse the disease identifier file. :param str path: Path to the disease identifier file. :return: List of disease identifiers. """ if os.path.isdir(path) or not os.path.exists(path): logger.info("Couldn't find the disease identifiers file. Returning empt...
python
def parse_disease_ids(path: str): """Parse the disease identifier file. :param str path: Path to the disease identifier file. :return: List of disease identifiers. """ if os.path.isdir(path) or not os.path.exists(path): logger.info("Couldn't find the disease identifiers file. Returning empt...
[ "def", "parse_disease_ids", "(", "path", ":", "str", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", "or", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "logger", ".", "info", "(", "\"Couldn't find the disease ident...
Parse the disease identifier file. :param str path: Path to the disease identifier file. :return: List of disease identifiers.
[ "Parse", "the", "disease", "identifier", "file", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L158-L169
train
Parse the disease identifiers file.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
parse_disease_associations
def parse_disease_associations(path: str, excluded_disease_ids: set): """Parse the disease-drug target associations file. :param str path: Path to the disease-drug target associations file. :param list excluded_disease_ids: Identifiers of the disease for which drug targets are being predicted. :return:...
python
def parse_disease_associations(path: str, excluded_disease_ids: set): """Parse the disease-drug target associations file. :param str path: Path to the disease-drug target associations file. :param list excluded_disease_ids: Identifiers of the disease for which drug targets are being predicted. :return:...
[ "def", "parse_disease_associations", "(", "path", ":", "str", ",", "excluded_disease_ids", ":", "set", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", "or", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "logger", ...
Parse the disease-drug target associations file. :param str path: Path to the disease-drug target associations file. :param list excluded_disease_ids: Identifiers of the disease for which drug targets are being predicted. :return: Dictionary of drug target-disease mappings.
[ "Parse", "the", "disease", "-", "drug", "target", "associations", "file", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L172-L189
train
Parse the disease - drug target associations file.
mattlong/hermes
hermes/server.py
run_server
def run_server(chatrooms, use_default_logging=True): """Sets up and serves specified chatrooms. Main entrypoint to Hermes. :param chatrooms: Dictionary of chatrooms to serve. :param use_default_logging: (optional) Boolean. Set to True if Hermes should setup its default logging configuration. """ if...
python
def run_server(chatrooms, use_default_logging=True): """Sets up and serves specified chatrooms. Main entrypoint to Hermes. :param chatrooms: Dictionary of chatrooms to serve. :param use_default_logging: (optional) Boolean. Set to True if Hermes should setup its default logging configuration. """ if...
[ "def", "run_server", "(", "chatrooms", ",", "use_default_logging", "=", "True", ")", ":", "if", "use_default_logging", ":", "configure_logging", "(", ")", "logger", ".", "info", "(", "'Starting Hermes chatroom server...'", ")", "bots", "=", "[", "]", "for", "nam...
Sets up and serves specified chatrooms. Main entrypoint to Hermes. :param chatrooms: Dictionary of chatrooms to serve. :param use_default_logging: (optional) Boolean. Set to True if Hermes should setup its default logging configuration.
[ "Sets", "up", "and", "serves", "specified", "chatrooms", ".", "Main", "entrypoint", "to", "Hermes", "." ]
63a5afcafe90ca99aeb44edeee9ed6f90baae431
https://github.com/mattlong/hermes/blob/63a5afcafe90ca99aeb44edeee9ed6f90baae431/hermes/server.py#L23-L67
train
Starts a server for the specified chatrooms.
mattlong/hermes
hermes/server.py
_get_sockets
def _get_sockets(bots): """Connects and gathers sockets for all chatrooms""" sockets = {} #sockets[sys.stdin] = 'stdio' for bot in bots: bot.connect() sockets[bot.client.Connection._sock] = bot return sockets
python
def _get_sockets(bots): """Connects and gathers sockets for all chatrooms""" sockets = {} #sockets[sys.stdin] = 'stdio' for bot in bots: bot.connect() sockets[bot.client.Connection._sock] = bot return sockets
[ "def", "_get_sockets", "(", "bots", ")", ":", "sockets", "=", "{", "}", "#sockets[sys.stdin] = 'stdio'", "for", "bot", "in", "bots", ":", "bot", ".", "connect", "(", ")", "sockets", "[", "bot", ".", "client", ".", "Connection", ".", "_sock", "]", "=", ...
Connects and gathers sockets for all chatrooms
[ "Connects", "and", "gathers", "sockets", "for", "all", "chatrooms" ]
63a5afcafe90ca99aeb44edeee9ed6f90baae431
https://github.com/mattlong/hermes/blob/63a5afcafe90ca99aeb44edeee9ed6f90baae431/hermes/server.py#L69-L76
train
Connects and gathers sockets for all bots
mattlong/hermes
hermes/server.py
_listen
def _listen(sockets): """Main server loop. Listens for incoming events and dispatches them to appropriate chatroom""" while True: (i , o, e) = select.select(sockets.keys(),[],[],1) for socket in i: if isinstance(sockets[socket], Chatroom): data_len = sockets[socket].c...
python
def _listen(sockets): """Main server loop. Listens for incoming events and dispatches them to appropriate chatroom""" while True: (i , o, e) = select.select(sockets.keys(),[],[],1) for socket in i: if isinstance(sockets[socket], Chatroom): data_len = sockets[socket].c...
[ "def", "_listen", "(", "sockets", ")", ":", "while", "True", ":", "(", "i", ",", "o", ",", "e", ")", "=", "select", ".", "select", "(", "sockets", ".", "keys", "(", ")", ",", "[", "]", ",", "[", "]", ",", "1", ")", "for", "socket", "in", "i...
Main server loop. Listens for incoming events and dispatches them to appropriate chatroom
[ "Main", "server", "loop", ".", "Listens", "for", "incoming", "events", "and", "dispatches", "them", "to", "appropriate", "chatroom" ]
63a5afcafe90ca99aeb44edeee9ed6f90baae431
https://github.com/mattlong/hermes/blob/63a5afcafe90ca99aeb44edeee9ed6f90baae431/hermes/server.py#L78-L91
train
Listen for incoming events and dispatches them to appropriate chatroom
transifex/transifex-python-library
txlib/http/http_requests.py
HttpRequest.post
def post(self, path, data, filename=None): """Make a POST request. If a `filename` is not specified, then the data must already be JSON-encoded. We specify the Content-Type accordingly. Else, we make a multipart/form-encoded request. In this case, the data variable must be a di...
python
def post(self, path, data, filename=None): """Make a POST request. If a `filename` is not specified, then the data must already be JSON-encoded. We specify the Content-Type accordingly. Else, we make a multipart/form-encoded request. In this case, the data variable must be a di...
[ "def", "post", "(", "self", ",", "path", ",", "data", ",", "filename", "=", "None", ")", ":", "return", "self", ".", "_send", "(", "'POST'", ",", "path", ",", "data", ",", "filename", ")" ]
Make a POST request. If a `filename` is not specified, then the data must already be JSON-encoded. We specify the Content-Type accordingly. Else, we make a multipart/form-encoded request. In this case, the data variable must be a dict-like object. The file must already be suita...
[ "Make", "a", "POST", "request", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/http_requests.py#L28-L47
train
Make a POST request.
transifex/transifex-python-library
txlib/http/http_requests.py
HttpRequest.put
def put(self, path, data, filename=None): """Make a PUT request. If a `filename` is not specified, then the data must already be JSON-encoded. We specify the Content-Type accordingly. Else, we make a multipart/form-encoded request. In this case, the data variable must be a dict...
python
def put(self, path, data, filename=None): """Make a PUT request. If a `filename` is not specified, then the data must already be JSON-encoded. We specify the Content-Type accordingly. Else, we make a multipart/form-encoded request. In this case, the data variable must be a dict...
[ "def", "put", "(", "self", ",", "path", ",", "data", ",", "filename", "=", "None", ")", ":", "return", "self", ".", "_send", "(", "'PUT'", ",", "path", ",", "data", ",", "filename", ")" ]
Make a PUT request. If a `filename` is not specified, then the data must already be JSON-encoded. We specify the Content-Type accordingly. Else, we make a multipart/form-encoded request. In this case, the data variable must be a dict-like object. The file must already be suitab...
[ "Make", "a", "PUT", "request", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/http_requests.py#L49-L68
train
Make a PUT request.
transifex/transifex-python-library
txlib/http/http_requests.py
HttpRequest._make_request
def _make_request(self, method, path, data=None, **kwargs): """Make a request. Use the `requests` module to actually perform the request. Args: `method`: The method to use. `path`: The path to the resource. `data`: Any data to send (for POST and PUT requests...
python
def _make_request(self, method, path, data=None, **kwargs): """Make a request. Use the `requests` module to actually perform the request. Args: `method`: The method to use. `path`: The path to the resource. `data`: Any data to send (for POST and PUT requests...
[ "def", "_make_request", "(", "self", ",", "method", ",", "path", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_logger", ".", "debug", "(", "\"Method for request is %s\"", "%", "method", ")", "url", "=", "self", ".", "_construct_full_url", ...
Make a request. Use the `requests` module to actually perform the request. Args: `method`: The method to use. `path`: The path to the resource. `data`: Any data to send (for POST and PUT requests). `kwargs`: Other parameters for `requests`. Retur...
[ "Make", "a", "request", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/http_requests.py#L82-L121
train
Makes a request to the specified resource.
transifex/transifex-python-library
txlib/http/http_requests.py
HttpRequest._send
def _send(self, method, path, data, filename): """Send data to a remote server, either with a POST or a PUT request. Args: `method`: The method (POST or PUT) to use. `path`: The path to the resource. `data`: The data to send. `filename`: The filename of t...
python
def _send(self, method, path, data, filename): """Send data to a remote server, either with a POST or a PUT request. Args: `method`: The method (POST or PUT) to use. `path`: The path to the resource. `data`: The data to send. `filename`: The filename of t...
[ "def", "_send", "(", "self", ",", "method", ",", "path", ",", "data", ",", "filename", ")", ":", "if", "filename", "is", "None", ":", "return", "self", ".", "_send_json", "(", "method", ",", "path", ",", "data", ")", "else", ":", "return", "self", ...
Send data to a remote server, either with a POST or a PUT request. Args: `method`: The method (POST or PUT) to use. `path`: The path to the resource. `data`: The data to send. `filename`: The filename of the file to send (if any). Returns: The...
[ "Send", "data", "to", "a", "remote", "server", "either", "with", "a", "POST", "or", "a", "PUT", "request", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/http_requests.py#L123-L139
train
Send data to a remote server either with a POST or PUT request.
transifex/transifex-python-library
txlib/http/http_requests.py
HttpRequest._send_json
def _send_json(self, method, path, data): """Make a application/json request. Args: `method`: The method of the request (POST or PUT). `path`: The path to the resource. `data`: The JSON-encoded data. Returns: The content of the response. R...
python
def _send_json(self, method, path, data): """Make a application/json request. Args: `method`: The method of the request (POST or PUT). `path`: The path to the resource. `data`: The JSON-encoded data. Returns: The content of the response. R...
[ "def", "_send_json", "(", "self", ",", "method", ",", "path", ",", "data", ")", ":", "headers", "=", "{", "'Content-type'", ":", "'application/json'", "}", "return", "self", ".", "_make_request", "(", "method", ",", "path", ",", "data", "=", "data", ",",...
Make a application/json request. Args: `method`: The method of the request (POST or PUT). `path`: The path to the resource. `data`: The JSON-encoded data. Returns: The content of the response. Raises: An exception depending on the HTTP...
[ "Make", "a", "application", "/", "json", "request", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/http_requests.py#L141-L154
train
Make a JSON request.
transifex/transifex-python-library
txlib/http/http_requests.py
HttpRequest._send_file
def _send_file(self, method, path, data, filename): """Make a multipart/form-encoded request. Args: `method`: The method of the request (POST or PUT). `path`: The path to the resource. `data`: The JSON-encoded data. `filename`: The filename of the file to...
python
def _send_file(self, method, path, data, filename): """Make a multipart/form-encoded request. Args: `method`: The method of the request (POST or PUT). `path`: The path to the resource. `data`: The JSON-encoded data. `filename`: The filename of the file to...
[ "def", "_send_file", "(", "self", ",", "method", ",", "path", ",", "data", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "f", ":", "return", "self", ".", "_make_request", "(", "method", ",", "path", ",", "data", ...
Make a multipart/form-encoded request. Args: `method`: The method of the request (POST or PUT). `path`: The path to the resource. `data`: The JSON-encoded data. `filename`: The filename of the file to send. Returns: The content of the response...
[ "Make", "a", "multipart", "/", "form", "-", "encoded", "request", "." ]
9fea86b718973de35ccca6d54bd1f445c9632406
https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/http_requests.py#L156-L170
train
Send a file to the resource.
BernardFW/bernard
src/bernard/platforms/management.py
get_platform_settings
def get_platform_settings(): """ Returns the content of `settings.PLATFORMS` with a twist. The platforms settings was created to stay compatible with the old way of declaring the FB configuration, in order not to break production bots. This function will convert the legacy configuration into the ne...
python
def get_platform_settings(): """ Returns the content of `settings.PLATFORMS` with a twist. The platforms settings was created to stay compatible with the old way of declaring the FB configuration, in order not to break production bots. This function will convert the legacy configuration into the ne...
[ "def", "get_platform_settings", "(", ")", ":", "s", "=", "settings", ".", "PLATFORMS", "if", "hasattr", "(", "settings", ",", "'FACEBOOK'", ")", "and", "settings", ".", "FACEBOOK", ":", "s", ".", "append", "(", "{", "'class'", ":", "'bernard.platforms.facebo...
Returns the content of `settings.PLATFORMS` with a twist. The platforms settings was created to stay compatible with the old way of declaring the FB configuration, in order not to break production bots. This function will convert the legacy configuration into the new configuration if required. As a res...
[ "Returns", "the", "content", "of", "settings", ".", "PLATFORMS", "with", "a", "twist", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L39-L58
train
Returns the content of settings. PLATFORMS with a twist.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager.init
async def init(self): """ Creates the FSM and the cache. It can be called several times to reset stuff (like for unit tests...). It also runs all the health checks in order to see if everything is fit for running. """ self.fsm = FSM() checks = [] ...
python
async def init(self): """ Creates the FSM and the cache. It can be called several times to reset stuff (like for unit tests...). It also runs all the health checks in order to see if everything is fit for running. """ self.fsm = FSM() checks = [] ...
[ "async", "def", "init", "(", "self", ")", ":", "self", ".", "fsm", "=", "FSM", "(", ")", "checks", "=", "[", "]", "# noinspection PyTypeChecker", "async", "for", "check", "in", "self", ".", "run_checks", "(", ")", ":", "checks", ".", "append", "(", "...
Creates the FSM and the cache. It can be called several times to reset stuff (like for unit tests...). It also runs all the health checks in order to see if everything is fit for running.
[ "Creates", "the", "FSM", "and", "the", "cache", ".", "It", "can", "be", "called", "several", "times", "to", "reset", "stuff", "(", "like", "for", "unit", "tests", "...", ")", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L85-L107
train
Initializes the FSM and the cache.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager.run_checks
async def run_checks(self): """ Run checks on itself and on the FSM """ async for check in self.fsm.health_check(): yield check async for check in self.self_check(): yield check for check in MiddlewareManager.health_check(): yield ch...
python
async def run_checks(self): """ Run checks on itself and on the FSM """ async for check in self.fsm.health_check(): yield check async for check in self.self_check(): yield check for check in MiddlewareManager.health_check(): yield ch...
[ "async", "def", "run_checks", "(", "self", ")", ":", "async", "for", "check", "in", "self", ".", "fsm", ".", "health_check", "(", ")", ":", "yield", "check", "async", "for", "check", "in", "self", ".", "self_check", "(", ")", ":", "yield", "check", "...
Run checks on itself and on the FSM
[ "Run", "checks", "on", "itself", "and", "on", "the", "FSM" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L109-L121
train
Run checks on itself and the FSM and the MiddlewareManager.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager.self_check
async def self_check(self): """ Checks that the platforms configuration is all right. """ platforms = set() for platform in get_platform_settings(): try: name = platform['class'] cls: Type[Platform] = import_class(name) ex...
python
async def self_check(self): """ Checks that the platforms configuration is all right. """ platforms = set() for platform in get_platform_settings(): try: name = platform['class'] cls: Type[Platform] = import_class(name) ex...
[ "async", "def", "self_check", "(", "self", ")", ":", "platforms", "=", "set", "(", ")", "for", "platform", "in", "get_platform_settings", "(", ")", ":", "try", ":", "name", "=", "platform", "[", "'class'", "]", "cls", ":", "Type", "[", "Platform", "]",...
Checks that the platforms configuration is all right.
[ "Checks", "that", "the", "platforms", "configuration", "is", "all", "right", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L123-L154
train
Checks that the platforms configuration is all right.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager._index_classes
def _index_classes(self) -> Dict[Text, Type[Platform]]: """ Build a name index for all platform classes """ out = {} for p in get_platform_settings(): cls: Type[Platform] = import_class(p['class']) if 'name' in p: out[p['name']] = cls ...
python
def _index_classes(self) -> Dict[Text, Type[Platform]]: """ Build a name index for all platform classes """ out = {} for p in get_platform_settings(): cls: Type[Platform] = import_class(p['class']) if 'name' in p: out[p['name']] = cls ...
[ "def", "_index_classes", "(", "self", ")", "->", "Dict", "[", "Text", ",", "Type", "[", "Platform", "]", "]", ":", "out", "=", "{", "}", "for", "p", "in", "get_platform_settings", "(", ")", ":", "cls", ":", "Type", "[", "Platform", "]", "=", "impor...
Build a name index for all platform classes
[ "Build", "a", "name", "index", "for", "all", "platform", "classes" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L156-L171
train
Build a name index for all platform classes.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager.build_platform
async def build_platform(self, cls: Type[Platform], custom_id): """ Build the Facebook platform. Nothing fancy. """ from bernard.server.http import router p = cls() if custom_id: p._id = custom_id await p.async_init() p.on_message(self.fsm....
python
async def build_platform(self, cls: Type[Platform], custom_id): """ Build the Facebook platform. Nothing fancy. """ from bernard.server.http import router p = cls() if custom_id: p._id = custom_id await p.async_init() p.on_message(self.fsm....
[ "async", "def", "build_platform", "(", "self", ",", "cls", ":", "Type", "[", "Platform", "]", ",", "custom_id", ")", ":", "from", "bernard", ".", "server", ".", "http", "import", "router", "p", "=", "cls", "(", ")", "if", "custom_id", ":", "p", ".", ...
Build the Facebook platform. Nothing fancy.
[ "Build", "the", "Facebook", "platform", ".", "Nothing", "fancy", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L173-L188
train
Build the Facebook platform. Nothing fancy.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager.get_class
def get_class(self, platform) -> Type[Platform]: """ For a given platform name, gets the matching class """ if platform in self._classes: return self._classes[platform] raise PlatformDoesNotExist('Platform "{}" is not in configuration' ...
python
def get_class(self, platform) -> Type[Platform]: """ For a given platform name, gets the matching class """ if platform in self._classes: return self._classes[platform] raise PlatformDoesNotExist('Platform "{}" is not in configuration' ...
[ "def", "get_class", "(", "self", ",", "platform", ")", "->", "Type", "[", "Platform", "]", ":", "if", "platform", "in", "self", ".", "_classes", ":", "return", "self", ".", "_classes", "[", "platform", "]", "raise", "PlatformDoesNotExist", "(", "'Platform ...
For a given platform name, gets the matching class
[ "For", "a", "given", "platform", "name", "gets", "the", "matching", "class" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L190-L199
train
Gets the class for a given platform name.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager.get_platform
async def get_platform(self, name: Text): """ Get a valid instance of the specified platform. Do not cache this object, it might change with configuration changes. """ if not self._is_init: await self.init() if name not in self.platforms: self.pl...
python
async def get_platform(self, name: Text): """ Get a valid instance of the specified platform. Do not cache this object, it might change with configuration changes. """ if not self._is_init: await self.init() if name not in self.platforms: self.pl...
[ "async", "def", "get_platform", "(", "self", ",", "name", ":", "Text", ")", ":", "if", "not", "self", ".", "_is_init", ":", "await", "self", ".", "init", "(", ")", "if", "name", "not", "in", "self", ".", "platforms", ":", "self", ".", "platforms", ...
Get a valid instance of the specified platform. Do not cache this object, it might change with configuration changes.
[ "Get", "a", "valid", "instance", "of", "the", "specified", "platform", ".", "Do", "not", "cache", "this", "object", "it", "might", "change", "with", "configuration", "changes", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L201-L214
train
Get a valid instance of the specified platform.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager.get_all_platforms
async def get_all_platforms(self) -> AsyncIterator[Platform]: """ Returns all platform instances """ for name in self._classes.keys(): yield await self.get_platform(name)
python
async def get_all_platforms(self) -> AsyncIterator[Platform]: """ Returns all platform instances """ for name in self._classes.keys(): yield await self.get_platform(name)
[ "async", "def", "get_all_platforms", "(", "self", ")", "->", "AsyncIterator", "[", "Platform", "]", ":", "for", "name", "in", "self", ".", "_classes", ".", "keys", "(", ")", ":", "yield", "await", "self", ".", "get_platform", "(", "name", ")" ]
Returns all platform instances
[ "Returns", "all", "platform", "instances" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L216-L222
train
Returns an async iterator over all platforms.
BernardFW/bernard
src/bernard/platforms/management.py
PlatformManager.message_from_token
async def message_from_token(self, token: Text, payload: Any) \ -> Tuple[Optional[BaseMessage], Optional[Platform]]: """ Given an authentication token, find the right platform that can recognize this token and create a message for this platform. The payload will be inserted ...
python
async def message_from_token(self, token: Text, payload: Any) \ -> Tuple[Optional[BaseMessage], Optional[Platform]]: """ Given an authentication token, find the right platform that can recognize this token and create a message for this platform. The payload will be inserted ...
[ "async", "def", "message_from_token", "(", "self", ",", "token", ":", "Text", ",", "payload", ":", "Any", ")", "->", "Tuple", "[", "Optional", "[", "BaseMessage", "]", ",", "Optional", "[", "Platform", "]", "]", ":", "async", "for", "platform", "in", "...
Given an authentication token, find the right platform that can recognize this token and create a message for this platform. The payload will be inserted into a Postback layer.
[ "Given", "an", "authentication", "token", "find", "the", "right", "platform", "that", "can", "recognize", "this", "token", "and", "create", "a", "message", "for", "this", "platform", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/platforms/management.py#L224-L239
train
Given an authentication token and payload create a message for that platform.
openvax/varlens
varlens/reads_util.py
add_args
def add_args(parser, positional=False): """ Extends a commandline argument parser with arguments for specifying read sources. """ group = parser.add_argument_group("read loading") group.add_argument("reads" if positional else "--reads", nargs="+", default=[], help="Paths to bam f...
python
def add_args(parser, positional=False): """ Extends a commandline argument parser with arguments for specifying read sources. """ group = parser.add_argument_group("read loading") group.add_argument("reads" if positional else "--reads", nargs="+", default=[], help="Paths to bam f...
[ "def", "add_args", "(", "parser", ",", "positional", "=", "False", ")", ":", "group", "=", "parser", ".", "add_argument_group", "(", "\"read loading\"", ")", "group", ".", "add_argument", "(", "\"reads\"", "if", "positional", "else", "\"--reads\"", ",", "nargs...
Extends a commandline argument parser with arguments for specifying read sources.
[ "Extends", "a", "commandline", "argument", "parser", "with", "arguments", "for", "specifying", "read", "sources", "." ]
715d3ede5893757b2fcba4117515621bca7b1e5d
https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/reads_util.py#L104-L141
train
Adds command line arguments for specifying read sources.
openvax/varlens
varlens/reads_util.py
load_from_args
def load_from_args(args): """ Given parsed commandline arguments, returns a list of ReadSource objects """ if not args.reads: return None if args.read_source_name: read_source_names = util.expand( args.read_source_name, 'read_source_name', 'read s...
python
def load_from_args(args): """ Given parsed commandline arguments, returns a list of ReadSource objects """ if not args.reads: return None if args.read_source_name: read_source_names = util.expand( args.read_source_name, 'read_source_name', 'read s...
[ "def", "load_from_args", "(", "args", ")", ":", "if", "not", "args", ".", "reads", ":", "return", "None", "if", "args", ".", "read_source_name", ":", "read_source_names", "=", "util", ".", "expand", "(", "args", ".", "read_source_name", ",", "'read_source_na...
Given parsed commandline arguments, returns a list of ReadSource objects
[ "Given", "parsed", "commandline", "arguments", "returns", "a", "list", "of", "ReadSource", "objects" ]
715d3ede5893757b2fcba4117515621bca7b1e5d
https://github.com/openvax/varlens/blob/715d3ede5893757b2fcba4117515621bca7b1e5d/varlens/reads_util.py#L143-L169
train
Given parsed commandline arguments returns a list of ReadSource objects
klmitch/turnstile
turnstile/compactor.py
version_greater
def version_greater(minimum, version): """ Compare two version strings. :param minimum: The minimum valid version. :param version: The version to compare to. :returns: True if version is greater than minimum, False otherwise. """ # Chop up the version strings minimum = [...
python
def version_greater(minimum, version): """ Compare two version strings. :param minimum: The minimum valid version. :param version: The version to compare to. :returns: True if version is greater than minimum, False otherwise. """ # Chop up the version strings minimum = [...
[ "def", "version_greater", "(", "minimum", ",", "version", ")", ":", "# Chop up the version strings", "minimum", "=", "[", "int", "(", "i", ")", "for", "i", "in", "minimum", ".", "split", "(", "'.'", ")", "]", "version", "=", "[", "int", "(", "i", ")", ...
Compare two version strings. :param minimum: The minimum valid version. :param version: The version to compare to. :returns: True if version is greater than minimum, False otherwise.
[ "Compare", "two", "version", "strings", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/compactor.py#L33-L61
train
Compare two version strings and return True if the minimum is greater than the version.
klmitch/turnstile
turnstile/compactor.py
get_int
def get_int(config, key, default): """ A helper to retrieve an integer value from a given dictionary containing string values. If the requested value is not present in the dictionary, or if it cannot be converted to an integer, a default value will be returned instead. :param config: The dicti...
python
def get_int(config, key, default): """ A helper to retrieve an integer value from a given dictionary containing string values. If the requested value is not present in the dictionary, or if it cannot be converted to an integer, a default value will be returned instead. :param config: The dicti...
[ "def", "get_int", "(", "config", ",", "key", ",", "default", ")", ":", "try", ":", "return", "int", "(", "config", "[", "key", "]", ")", "except", "(", "KeyError", ",", "ValueError", ")", ":", "return", "default" ]
A helper to retrieve an integer value from a given dictionary containing string values. If the requested value is not present in the dictionary, or if it cannot be converted to an integer, a default value will be returned instead. :param config: The dictionary containing the desired value. :param ...
[ "A", "helper", "to", "retrieve", "an", "integer", "value", "from", "a", "given", "dictionary", "containing", "string", "values", ".", "If", "the", "requested", "value", "is", "not", "present", "in", "the", "dictionary", "or", "if", "it", "cannot", "be", "c...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/compactor.py#L64-L83
train
Helper function to retrieve an integer value from a given dictionary containing string values.
klmitch/turnstile
turnstile/compactor.py
compact_bucket
def compact_bucket(db, buck_key, limit): """ Perform the compaction operation. This reads in the bucket information from the database, builds a compacted bucket record, inserts that record in the appropriate place in the database, then removes outdated updates. :param db: A database handle for...
python
def compact_bucket(db, buck_key, limit): """ Perform the compaction operation. This reads in the bucket information from the database, builds a compacted bucket record, inserts that record in the appropriate place in the database, then removes outdated updates. :param db: A database handle for...
[ "def", "compact_bucket", "(", "db", ",", "buck_key", ",", "limit", ")", ":", "# Suck in the bucket records and generate our bucket", "records", "=", "db", ".", "lrange", "(", "str", "(", "buck_key", ")", ",", "0", ",", "-", "1", ")", "loader", "=", "limits",...
Perform the compaction operation. This reads in the bucket information from the database, builds a compacted bucket record, inserts that record in the appropriate place in the database, then removes outdated updates. :param db: A database handle for the Redis database. :param buck_key: A turnstile...
[ "Perform", "the", "compaction", "operation", ".", "This", "reads", "in", "the", "bucket", "information", "from", "the", "database", "builds", "a", "compacted", "bucket", "record", "inserts", "that", "record", "in", "the", "appropriate", "place", "in", "the", "...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/compactor.py#L379-L415
train
This function performs the compaction operation on the bucket containing the given key.
klmitch/turnstile
turnstile/compactor.py
compactor
def compactor(conf): """ The compactor daemon. This fuction watches the sorted set containing bucket keys that need to be compacted, performing the necessary compaction. :param conf: A turnstile.config.Config instance containing the configuration for the compactor daemon. Note th...
python
def compactor(conf): """ The compactor daemon. This fuction watches the sorted set containing bucket keys that need to be compacted, performing the necessary compaction. :param conf: A turnstile.config.Config instance containing the configuration for the compactor daemon. Note th...
[ "def", "compactor", "(", "conf", ")", ":", "# Get the database handle", "db", "=", "conf", ".", "get_database", "(", "'compactor'", ")", "# Get the limits container", "limit_map", "=", "LimitContainer", "(", "conf", ",", "db", ")", "# Get the compactor configuration",...
The compactor daemon. This fuction watches the sorted set containing bucket keys that need to be compacted, performing the necessary compaction. :param conf: A turnstile.config.Config instance containing the configuration for the compactor daemon. Note that a ControlDaem...
[ "The", "compactor", "daemon", ".", "This", "fuction", "watches", "the", "sorted", "set", "containing", "bucket", "keys", "that", "need", "to", "be", "compacted", "performing", "the", "necessary", "compaction", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/compactor.py#L418-L485
train
This function is called by the daemon to compact the set of bucket keys that need to be compacted.
klmitch/turnstile
turnstile/compactor.py
GetBucketKey.factory
def factory(cls, config, db): """ Given a configuration and database, select and return an appropriate instance of a subclass of GetBucketKey. This will ensure that both client and server support are available for the Lua script feature of Redis, and if not, a lock will be ...
python
def factory(cls, config, db): """ Given a configuration and database, select and return an appropriate instance of a subclass of GetBucketKey. This will ensure that both client and server support are available for the Lua script feature of Redis, and if not, a lock will be ...
[ "def", "factory", "(", "cls", ",", "config", ",", "db", ")", ":", "# Make sure that the client supports register_script()", "if", "not", "hasattr", "(", "db", ",", "'register_script'", ")", ":", "LOG", ".", "debug", "(", "\"Redis client does not support register_scrip...
Given a configuration and database, select and return an appropriate instance of a subclass of GetBucketKey. This will ensure that both client and server support are available for the Lua script feature of Redis, and if not, a lock will be used. :param config: A dictionary of c...
[ "Given", "a", "configuration", "and", "database", "select", "and", "return", "an", "appropriate", "instance", "of", "a", "subclass", "of", "GetBucketKey", ".", "This", "will", "ensure", "that", "both", "client", "and", "server", "support", "are", "available", ...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/compactor.py#L99-L128
train
This method is used to create an instance of GetBucketKey based on a configuration and database.
klmitch/turnstile
turnstile/compactor.py
GetBucketKeyByLock.get
def get(self, now): """ Get a bucket key to compact. If none are available, returns None. This uses a configured lock to ensure that the bucket key is popped off the sorted set in an atomic fashion. :param now: The current time, as a float. Used to ensure the ...
python
def get(self, now): """ Get a bucket key to compact. If none are available, returns None. This uses a configured lock to ensure that the bucket key is popped off the sorted set in an atomic fashion. :param now: The current time, as a float. Used to ensure the ...
[ "def", "get", "(", "self", ",", "now", ")", ":", "with", "self", ".", "lock", ":", "items", "=", "self", ".", "db", ".", "zrangebyscore", "(", "self", ".", "key", ",", "0", ",", "now", "-", "self", ".", "min_age", ",", "start", "=", "0", ",", ...
Get a bucket key to compact. If none are available, returns None. This uses a configured lock to ensure that the bucket key is popped off the sorted set in an atomic fashion. :param now: The current time, as a float. Used to ensure the bucket key has been aged sufficientl...
[ "Get", "a", "bucket", "key", "to", "compact", ".", "If", "none", "are", "available", "returns", "None", ".", "This", "uses", "a", "configured", "lock", "to", "ensure", "that", "the", "bucket", "key", "is", "popped", "off", "the", "sorted", "set", "in", ...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/compactor.py#L210-L236
train
Get a bucket key to compact. If none are available returns None.
klmitch/turnstile
turnstile/compactor.py
GetBucketKeyByScript.get
def get(self, now): """ Get a bucket key to compact. If none are available, returns None. This uses a Lua script to ensure that the bucket key is popped off the sorted set in an atomic fashion. :param now: The current time, as a float. Used to ensure the b...
python
def get(self, now): """ Get a bucket key to compact. If none are available, returns None. This uses a Lua script to ensure that the bucket key is popped off the sorted set in an atomic fashion. :param now: The current time, as a float. Used to ensure the b...
[ "def", "get", "(", "self", ",", "now", ")", ":", "items", "=", "self", ".", "script", "(", "keys", "=", "[", "self", ".", "key", "]", ",", "args", "=", "[", "now", "-", "self", ".", "min_age", "]", ")", "return", "items", "[", "0", "]", "if",...
Get a bucket key to compact. If none are available, returns None. This uses a Lua script to ensure that the bucket key is popped off the sorted set in an atomic fashion. :param now: The current time, as a float. Used to ensure the bucket key has been aged sufficiently to ...
[ "Get", "a", "bucket", "key", "to", "compact", ".", "If", "none", "are", "available", "returns", "None", ".", "This", "uses", "a", "Lua", "script", "to", "ensure", "that", "the", "bucket", "key", "is", "popped", "off", "the", "sorted", "set", "in", "an"...
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/compactor.py#L265-L281
train
Get a bucket key to compact. If none are available returns None.
klmitch/turnstile
turnstile/compactor.py
LimitContainer.recheck_limits
def recheck_limits(self): """ Re-check that the cached limits are the current limits. """ limit_data = self.control_daemon.get_limits() try: # Get the new checksum and list of limits new_sum, new_limits = limit_data.get_limits(self.limit_sum) ...
python
def recheck_limits(self): """ Re-check that the cached limits are the current limits. """ limit_data = self.control_daemon.get_limits() try: # Get the new checksum and list of limits new_sum, new_limits = limit_data.get_limits(self.limit_sum) ...
[ "def", "recheck_limits", "(", "self", ")", ":", "limit_data", "=", "self", ".", "control_daemon", ".", "get_limits", "(", ")", "try", ":", "# Get the new checksum and list of limits", "new_sum", ",", "new_limits", "=", "limit_data", ".", "get_limits", "(", "self",...
Re-check that the cached limits are the current limits.
[ "Re", "-", "check", "that", "the", "cached", "limits", "are", "the", "current", "limits", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/compactor.py#L334-L376
train
Re - check the current limits and save the new limits.
frostming/marko
marko/inline_parser.py
parse
def parse(text, elements, fallback): """Parse given text and produce a list of inline elements. :param text: the text to be parsed. :param elements: the element types to be included in parsing :param fallback: fallback class when no other element type is matched. """ # this is a raw list of ele...
python
def parse(text, elements, fallback): """Parse given text and produce a list of inline elements. :param text: the text to be parsed. :param elements: the element types to be included in parsing :param fallback: fallback class when no other element type is matched. """ # this is a raw list of ele...
[ "def", "parse", "(", "text", ",", "elements", ",", "fallback", ")", ":", "# this is a raw list of elements that may contain overlaps.", "tokens", "=", "[", "]", "for", "etype", "in", "elements", ":", "for", "match", "in", "etype", ".", "find", "(", "text", ")"...
Parse given text and produce a list of inline elements. :param text: the text to be parsed. :param elements: the element types to be included in parsing :param fallback: fallback class when no other element type is matched.
[ "Parse", "given", "text", "and", "produce", "a", "list", "of", "inline", "elements", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/inline_parser.py#L12-L26
train
Parse given text and produce a list of inline elements.
frostming/marko
marko/inline_parser.py
make_elements
def make_elements(tokens, text, start=0, end=None, fallback=None): """Make elements from a list of parsed tokens. It will turn all unmatched holes into fallback elements. :param tokens: a list of parsed tokens. :param text: the original tet. :param start: the offset of where parsing starts. Default...
python
def make_elements(tokens, text, start=0, end=None, fallback=None): """Make elements from a list of parsed tokens. It will turn all unmatched holes into fallback elements. :param tokens: a list of parsed tokens. :param text: the original tet. :param start: the offset of where parsing starts. Default...
[ "def", "make_elements", "(", "tokens", ",", "text", ",", "start", "=", "0", ",", "end", "=", "None", ",", "fallback", "=", "None", ")", ":", "result", "=", "[", "]", "end", "=", "end", "or", "len", "(", "text", ")", "prev_end", "=", "start", "for...
Make elements from a list of parsed tokens. It will turn all unmatched holes into fallback elements. :param tokens: a list of parsed tokens. :param text: the original tet. :param start: the offset of where parsing starts. Defaults to the start of text. :param end: the offset of where parsing ends. ...
[ "Make", "elements", "from", "a", "list", "of", "parsed", "tokens", ".", "It", "will", "turn", "all", "unmatched", "holes", "into", "fallback", "elements", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/inline_parser.py#L47-L68
train
Make elements from a list of parsed tokens.
frostming/marko
marko/inline_parser.py
find_links_or_emphs
def find_links_or_emphs(text, root_node): """Fink links/images or emphasis from text. :param text: the original text. :param root_node: a reference to the root node of the AST. :returns: an iterable of match object. """ delimiters_re = re.compile(r'(?:!?\[|\*+|_+)') i = 0 delimiters = [...
python
def find_links_or_emphs(text, root_node): """Fink links/images or emphasis from text. :param text: the original text. :param root_node: a reference to the root node of the AST. :returns: an iterable of match object. """ delimiters_re = re.compile(r'(?:!?\[|\*+|_+)') i = 0 delimiters = [...
[ "def", "find_links_or_emphs", "(", "text", ",", "root_node", ")", ":", "delimiters_re", "=", "re", ".", "compile", "(", "r'(?:!?\\[|\\*+|_+)'", ")", "i", "=", "0", "delimiters", "=", "[", "]", "escape", "=", "False", "matches", "=", "[", "]", "code_pattern...
Fink links/images or emphasis from text. :param text: the original text. :param root_node: a reference to the root node of the AST. :returns: an iterable of match object.
[ "Fink", "links", "/", "images", "or", "emphasis", "from", "text", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/inline_parser.py#L125-L163
train
Fink links or images or emphasis from text.
frostming/marko
marko/inline_parser.py
_expect_inline_link
def _expect_inline_link(text, start): """(link_dest "link_title")""" if start >= len(text) or text[start] != '(': return None i = start + 1 m = patterns.whitespace.match(text, i) if m: i = m.end() m = patterns.link_dest_1.match(text, i) if m: link_dest = m.start(), m....
python
def _expect_inline_link(text, start): """(link_dest "link_title")""" if start >= len(text) or text[start] != '(': return None i = start + 1 m = patterns.whitespace.match(text, i) if m: i = m.end() m = patterns.link_dest_1.match(text, i) if m: link_dest = m.start(), m....
[ "def", "_expect_inline_link", "(", "text", ",", "start", ")", ":", "if", "start", ">=", "len", "(", "text", ")", "or", "text", "[", "start", "]", "!=", "'('", ":", "return", "None", "i", "=", "start", "+", "1", "m", "=", "patterns", ".", "whitespac...
(link_dest "link_title")
[ "(", "link_dest", "link_title", ")" ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/inline_parser.py#L205-L247
train
expect inline link
azogue/i2csense
i2csense/__main__.py
main_cli
def main_cli(): """CLI minimal interface.""" # Get params args = _cli_argument_parser() delta_secs = args.delay i2cbus = args.bus i2c_address = args.address sensor_key = args.sensor sensor_params = args.params params = {} if sensor_params: def _parse_param(str_param): ...
python
def main_cli(): """CLI minimal interface.""" # Get params args = _cli_argument_parser() delta_secs = args.delay i2cbus = args.bus i2c_address = args.address sensor_key = args.sensor sensor_params = args.params params = {} if sensor_params: def _parse_param(str_param): ...
[ "def", "main_cli", "(", ")", ":", "# Get params", "args", "=", "_cli_argument_parser", "(", ")", "delta_secs", "=", "args", ".", "delay", "i2cbus", "=", "args", ".", "bus", "i2c_address", "=", "args", ".", "address", "sensor_key", "=", "args", ".", "sensor...
CLI minimal interface.
[ "CLI", "minimal", "interface", "." ]
ecc6806dcee9de827a5414a9e836d271fedca9b9
https://github.com/azogue/i2csense/blob/ecc6806dcee9de827a5414a9e836d271fedca9b9/i2csense/__main__.py#L60-L139
train
CLI minimal interface.
BernardFW/bernard
examples/number_bot/src/number_bot/settings.py
extract_domain
def extract_domain(var_name, output): """ Extracts just the domain name from an URL and adds it to a list """ var = getenv(var_name) if var: p = urlparse(var) output.append(p.hostname)
python
def extract_domain(var_name, output): """ Extracts just the domain name from an URL and adds it to a list """ var = getenv(var_name) if var: p = urlparse(var) output.append(p.hostname)
[ "def", "extract_domain", "(", "var_name", ",", "output", ")", ":", "var", "=", "getenv", "(", "var_name", ")", "if", "var", ":", "p", "=", "urlparse", "(", "var", ")", "output", ".", "append", "(", "p", ".", "hostname", ")" ]
Extracts just the domain name from an URL and adds it to a list
[ "Extracts", "just", "the", "domain", "name", "from", "an", "URL", "and", "adds", "it", "to", "a", "list" ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/examples/number_bot/src/number_bot/settings.py#L11-L20
train
Extracts just the domain name from an URL and adds it to a list
gesellkammer/sndfileio
sndfileio/util.py
numchannels
def numchannels(samples:np.ndarray) -> int: """ return the number of channels present in samples samples: a numpy array as returned by sndread for multichannel audio, samples is always interleaved, meaning that samples[n] returns always a frame, which is either a single scalar for mono audio, ...
python
def numchannels(samples:np.ndarray) -> int: """ return the number of channels present in samples samples: a numpy array as returned by sndread for multichannel audio, samples is always interleaved, meaning that samples[n] returns always a frame, which is either a single scalar for mono audio, ...
[ "def", "numchannels", "(", "samples", ":", "np", ".", "ndarray", ")", "->", "int", ":", "if", "len", "(", "samples", ".", "shape", ")", "==", "1", ":", "return", "1", "else", ":", "return", "samples", ".", "shape", "[", "1", "]" ]
return the number of channels present in samples samples: a numpy array as returned by sndread for multichannel audio, samples is always interleaved, meaning that samples[n] returns always a frame, which is either a single scalar for mono audio, or an array for multichannel audio.
[ "return", "the", "number", "of", "channels", "present", "in", "samples" ]
8e2b264cadb652f09d2e775f54090c0a3cb2ced2
https://github.com/gesellkammer/sndfileio/blob/8e2b264cadb652f09d2e775f54090c0a3cb2ced2/sndfileio/util.py#L5-L19
train
Returns the number of channels present in samples
klmitch/turnstile
turnstile/middleware.py
turnstile_filter
def turnstile_filter(global_conf, **local_conf): """ Factory function for turnstile. Returns a function which, when passed the application, returns an instance of the TurnstileMiddleware. """ # Select the appropriate middleware class to return klass = TurnstileMiddleware if 'turnstile'...
python
def turnstile_filter(global_conf, **local_conf): """ Factory function for turnstile. Returns a function which, when passed the application, returns an instance of the TurnstileMiddleware. """ # Select the appropriate middleware class to return klass = TurnstileMiddleware if 'turnstile'...
[ "def", "turnstile_filter", "(", "global_conf", ",", "*", "*", "local_conf", ")", ":", "# Select the appropriate middleware class to return", "klass", "=", "TurnstileMiddleware", "if", "'turnstile'", "in", "local_conf", ":", "klass", "=", "utils", ".", "find_entrypoint",...
Factory function for turnstile. Returns a function which, when passed the application, returns an instance of the TurnstileMiddleware.
[ "Factory", "function", "for", "turnstile", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/middleware.py#L133-L150
train
Returns a function which returns an anonymized version of the application that will be used to filter the application based on the given configuration.
klmitch/turnstile
turnstile/middleware.py
TurnstileMiddleware.recheck_limits
def recheck_limits(self): """ Re-check that the cached limits are the current limits. """ limit_data = self.control_daemon.get_limits() try: # Get the new checksum and list of limits new_sum, new_limits = limit_data.get_limits(self.limit_sum) ...
python
def recheck_limits(self): """ Re-check that the cached limits are the current limits. """ limit_data = self.control_daemon.get_limits() try: # Get the new checksum and list of limits new_sum, new_limits = limit_data.get_limits(self.limit_sum) ...
[ "def", "recheck_limits", "(", "self", ")", ":", "limit_data", "=", "self", ".", "control_daemon", ".", "get_limits", "(", ")", "try", ":", "# Get the new checksum and list of limits", "new_sum", ",", "new_limits", "=", "limit_data", ".", "get_limits", "(", "self",...
Re-check that the cached limits are the current limits.
[ "Re", "-", "check", "that", "the", "cached", "limits", "are", "the", "current", "limits", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/middleware.py#L235-L282
train
Re - check the current limits and return the new cache level.
klmitch/turnstile
turnstile/middleware.py
TurnstileMiddleware.format_delay
def format_delay(self, delay, limit, bucket, environ, start_response): """ Formats the over-limit response for the request. May be overridden in subclasses to allow alternate responses. """ # Set up the default status status = self.conf.status # Set up the retr...
python
def format_delay(self, delay, limit, bucket, environ, start_response): """ Formats the over-limit response for the request. May be overridden in subclasses to allow alternate responses. """ # Set up the default status status = self.conf.status # Set up the retr...
[ "def", "format_delay", "(", "self", ",", "delay", ",", "limit", ",", "bucket", ",", "environ", ",", "start_response", ")", ":", "# Set up the default status", "status", "=", "self", ".", "conf", ".", "status", "# Set up the retry-after header...", "headers", "=", ...
Formats the over-limit response for the request. May be overridden in subclasses to allow alternate responses.
[ "Formats", "the", "over", "-", "limit", "response", "for", "the", "request", ".", "May", "be", "overridden", "in", "subclasses", "to", "allow", "alternate", "responses", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/middleware.py#L337-L355
train
Formats the over - limit response for the request.
klmitch/turnstile
turnstile/middleware.py
TurnstileMiddleware.db
def db(self): """ Obtain a handle for the database. This allows lazy initialization of the database handle. """ # Initialize the database handle if not self._db: self._db = self.conf.get_database() return self._db
python
def db(self): """ Obtain a handle for the database. This allows lazy initialization of the database handle. """ # Initialize the database handle if not self._db: self._db = self.conf.get_database() return self._db
[ "def", "db", "(", "self", ")", ":", "# Initialize the database handle", "if", "not", "self", ".", "_db", ":", "self", ".", "_db", "=", "self", ".", "conf", ".", "get_database", "(", ")", "return", "self", ".", "_db" ]
Obtain a handle for the database. This allows lazy initialization of the database handle.
[ "Obtain", "a", "handle", "for", "the", "database", ".", "This", "allows", "lazy", "initialization", "of", "the", "database", "handle", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/middleware.py#L358-L368
train
Returns a handle for the database.
klmitch/turnstile
turnstile/utils.py
find_entrypoint
def find_entrypoint(group, name, compat=True, required=False): """ Finds the first available entrypoint with the given name in the given group. :param group: The entrypoint group the name can be found in. If None, the name is not presumed to be an entrypoint. :param name: The nam...
python
def find_entrypoint(group, name, compat=True, required=False): """ Finds the first available entrypoint with the given name in the given group. :param group: The entrypoint group the name can be found in. If None, the name is not presumed to be an entrypoint. :param name: The nam...
[ "def", "find_entrypoint", "(", "group", ",", "name", ",", "compat", "=", "True", ",", "required", "=", "False", ")", ":", "if", "group", "is", "None", "or", "(", "compat", "and", "':'", "in", "name", ")", ":", "try", ":", "return", "pkg_resources", "...
Finds the first available entrypoint with the given name in the given group. :param group: The entrypoint group the name can be found in. If None, the name is not presumed to be an entrypoint. :param name: The name of the entrypoint. :param compat: If True, and if the name parameter ...
[ "Finds", "the", "first", "available", "entrypoint", "with", "the", "given", "name", "in", "the", "given", "group", "." ]
8fe9a359b45e505d3192ab193ecf9be177ab1a17
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/utils.py#L21-L60
train
Finds the first available entry point with the given name in the given group.
COALAIP/pycoalaip
coalaip/entities.py
TransferrableEntity.transfer
def transfer(self, transfer_payload=None, *, from_user, to_user): """Transfer this entity to another owner on the backing persistence layer Args: transfer_payload (dict): Payload for the transfer from_user (any): A user based on the model specified by the ...
python
def transfer(self, transfer_payload=None, *, from_user, to_user): """Transfer this entity to another owner on the backing persistence layer Args: transfer_payload (dict): Payload for the transfer from_user (any): A user based on the model specified by the ...
[ "def", "transfer", "(", "self", ",", "transfer_payload", "=", "None", ",", "*", ",", "from_user", ",", "to_user", ")", ":", "if", "self", ".", "persist_id", "is", "None", ":", "raise", "EntityNotYetPersistedError", "(", "(", "'Entities cannot be transferred '", ...
Transfer this entity to another owner on the backing persistence layer Args: transfer_payload (dict): Payload for the transfer from_user (any): A user based on the model specified by the persistence layer to_user (any): A user based on the model speci...
[ "Transfer", "this", "entity", "to", "another", "owner", "on", "the", "backing", "persistence", "layer" ]
cecc8f6ff4733f0525fafcee63647753e832f0be
https://github.com/COALAIP/pycoalaip/blob/cecc8f6ff4733f0525fafcee63647753e832f0be/coalaip/entities.py#L409-L442
train
Transfer this entity to another owner on the backing persistence layer.
COALAIP/pycoalaip
coalaip/entities.py
Right.transfer
def transfer(self, rights_assignment_data=None, *, from_user, to_user, rights_assignment_format='jsonld'): """Transfer this Right to another owner on the backing persistence layer. Args: rights_assignment_data (dict): Model data for the resulting :cl...
python
def transfer(self, rights_assignment_data=None, *, from_user, to_user, rights_assignment_format='jsonld'): """Transfer this Right to another owner on the backing persistence layer. Args: rights_assignment_data (dict): Model data for the resulting :cl...
[ "def", "transfer", "(", "self", ",", "rights_assignment_data", "=", "None", ",", "*", ",", "from_user", ",", "to_user", ",", "rights_assignment_format", "=", "'jsonld'", ")", ":", "rights_assignment", "=", "RightsAssignment", ".", "from_data", "(", "rights_assignm...
Transfer this Right to another owner on the backing persistence layer. Args: rights_assignment_data (dict): Model data for the resulting :class:`~.RightsAssignment` from_user (any, keyword): A user based on the model specified by the persistence l...
[ "Transfer", "this", "Right", "to", "another", "owner", "on", "the", "backing", "persistence", "layer", "." ]
cecc8f6ff4733f0525fafcee63647753e832f0be
https://github.com/COALAIP/pycoalaip/blob/cecc8f6ff4733f0525fafcee63647753e832f0be/coalaip/entities.py#L506-L542
train
Transfer this Right to another owner on the backing persistence layer.
rsgalloway/grit
grit/repo/base.py
Repo._set_repo
def _set_repo(self, url): """sets the underlying repo object""" if url.startswith('http'): try: self.repo = Proxy(url) except ProxyError, e: log.exception('Error setting repo: %s' % url) raise GritError(e) else: ...
python
def _set_repo(self, url): """sets the underlying repo object""" if url.startswith('http'): try: self.repo = Proxy(url) except ProxyError, e: log.exception('Error setting repo: %s' % url) raise GritError(e) else: ...
[ "def", "_set_repo", "(", "self", ",", "url", ")", ":", "if", "url", ".", "startswith", "(", "'http'", ")", ":", "try", ":", "self", ".", "repo", "=", "Proxy", "(", "url", ")", "except", "ProxyError", ",", "e", ":", "log", ".", "exception", "(", "...
sets the underlying repo object
[ "sets", "the", "underlying", "repo", "object" ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/base.py#L73-L88
train
sets the underlying repo object
rsgalloway/grit
grit/repo/base.py
Repo.new
def new(self, url, clone_from=None, bare=True): """ Creates a new Repo instance. :param url: Path or remote URL of new repo. :param clone_from: Path or URL of repo to clone from. :param bare: Create as bare repo. :returns: grit.Repo instance. For example: ...
python
def new(self, url, clone_from=None, bare=True): """ Creates a new Repo instance. :param url: Path or remote URL of new repo. :param clone_from: Path or URL of repo to clone from. :param bare: Create as bare repo. :returns: grit.Repo instance. For example: ...
[ "def", "new", "(", "self", ",", "url", ",", "clone_from", "=", "None", ",", "bare", "=", "True", ")", ":", "#note to self: look into using templates (--template)", "if", "clone_from", ":", "self", ".", "clone", "(", "path", "=", "url", ",", "bare", "=", "b...
Creates a new Repo instance. :param url: Path or remote URL of new repo. :param clone_from: Path or URL of repo to clone from. :param bare: Create as bare repo. :returns: grit.Repo instance. For example: >>> r = Repo.new('/tmp/projects') >>> r ...
[ "Creates", "a", "new", "Repo", "instance", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/base.py#L91-L117
train
Creates a new Repo instance.
rsgalloway/grit
grit/repo/base.py
Repo.clone
def clone(self, path=None, bare=False): """ Clone the repository to path (requires git). :param path: Destination filesystem path. :param bare: Make this a bare repo. :returns: grit.Repo instance. For example: >>> r = Repo("http://localhost/projects/a/b/c"...
python
def clone(self, path=None, bare=False): """ Clone the repository to path (requires git). :param path: Destination filesystem path. :param bare: Make this a bare repo. :returns: grit.Repo instance. For example: >>> r = Repo("http://localhost/projects/a/b/c"...
[ "def", "clone", "(", "self", ",", "path", "=", "None", ",", "bare", "=", "False", ")", ":", "#note to self: see --reference, --shared options", "if", "path", "is", "None", ":", "path", "=", "os", ".", "path", ".", "basename", "(", "url", ")", "try", ":",...
Clone the repository to path (requires git). :param path: Destination filesystem path. :param bare: Make this a bare repo. :returns: grit.Repo instance. For example: >>> r = Repo("http://localhost/projects/a/b/c") >>> c = r.clone('/tmp') >>> c ...
[ "Clone", "the", "repository", "to", "path", "(", "requires", "git", ")", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/repo/base.py#L119-L143
train
Clone the repository to path.
xypnox/email_purifier
epurifier/email_checker.py
EmailPurifier.CheckEmails
def CheckEmails(self, checkTypo=False, fillWrong=True): '''Checks Emails in List Wether they are Correct or not''' self.wrong_emails = [] for email in self.emails: if self.CheckEmail(email, checkTypo) is False: self.wrong_emails.append(email)
python
def CheckEmails(self, checkTypo=False, fillWrong=True): '''Checks Emails in List Wether they are Correct or not''' self.wrong_emails = [] for email in self.emails: if self.CheckEmail(email, checkTypo) is False: self.wrong_emails.append(email)
[ "def", "CheckEmails", "(", "self", ",", "checkTypo", "=", "False", ",", "fillWrong", "=", "True", ")", ":", "self", ".", "wrong_emails", "=", "[", "]", "for", "email", "in", "self", ".", "emails", ":", "if", "self", ".", "CheckEmail", "(", "email", "...
Checks Emails in List Wether they are Correct or not
[ "Checks", "Emails", "in", "List", "Wether", "they", "are", "Correct", "or", "not" ]
a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f
https://github.com/xypnox/email_purifier/blob/a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f/epurifier/email_checker.py#L31-L36
train
Checks Emails in List Wether they are Correct or not
xypnox/email_purifier
epurifier/email_checker.py
EmailPurifier.CheckEmail
def CheckEmail(self, email, checkTypo=False): '''Checks a Single email if it is correct''' contents = email.split('@') if len(contents) == 2: if contents[1] in self.valid: return True return False
python
def CheckEmail(self, email, checkTypo=False): '''Checks a Single email if it is correct''' contents = email.split('@') if len(contents) == 2: if contents[1] in self.valid: return True return False
[ "def", "CheckEmail", "(", "self", ",", "email", ",", "checkTypo", "=", "False", ")", ":", "contents", "=", "email", ".", "split", "(", "'@'", ")", "if", "len", "(", "contents", ")", "==", "2", ":", "if", "contents", "[", "1", "]", "in", "self", "...
Checks a Single email if it is correct
[ "Checks", "a", "Single", "email", "if", "it", "is", "correct" ]
a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f
https://github.com/xypnox/email_purifier/blob/a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f/epurifier/email_checker.py#L38-L44
train
Checks a Single email if it is correct
xypnox/email_purifier
epurifier/email_checker.py
EmailPurifier.CorrectWrongEmails
def CorrectWrongEmails(self, askInput=True): '''Corrects Emails in wrong_emails''' for email in self.wrong_emails: corrected_email = self.CorrectEmail(email) self.emails[self.emails.index(email)] = corrected_email self.wrong_emails = []
python
def CorrectWrongEmails(self, askInput=True): '''Corrects Emails in wrong_emails''' for email in self.wrong_emails: corrected_email = self.CorrectEmail(email) self.emails[self.emails.index(email)] = corrected_email self.wrong_emails = []
[ "def", "CorrectWrongEmails", "(", "self", ",", "askInput", "=", "True", ")", ":", "for", "email", "in", "self", ".", "wrong_emails", ":", "corrected_email", "=", "self", ".", "CorrectEmail", "(", "email", ")", "self", ".", "emails", "[", "self", ".", "em...
Corrects Emails in wrong_emails
[ "Corrects", "Emails", "in", "wrong_emails" ]
a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f
https://github.com/xypnox/email_purifier/blob/a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f/epurifier/email_checker.py#L46-L52
train
Corrects Emails in wrong_emails
xypnox/email_purifier
epurifier/email_checker.py
EmailPurifier.CorrectEmail
def CorrectEmail(self, email): '''Returns a Corrected email USER INPUT REQUIRED''' print("Wrong Email : "+email) contents = email.split('@') if len(contents) == 2: domain_data = contents[1].split('.') for vemail in self.valid: alters = perms(vemai...
python
def CorrectEmail(self, email): '''Returns a Corrected email USER INPUT REQUIRED''' print("Wrong Email : "+email) contents = email.split('@') if len(contents) == 2: domain_data = contents[1].split('.') for vemail in self.valid: alters = perms(vemai...
[ "def", "CorrectEmail", "(", "self", ",", "email", ")", ":", "print", "(", "\"Wrong Email : \"", "+", "email", ")", "contents", "=", "email", ".", "split", "(", "'@'", ")", "if", "len", "(", "contents", ")", "==", "2", ":", "domain_data", "=", "contents...
Returns a Corrected email USER INPUT REQUIRED
[ "Returns", "a", "Corrected", "email", "USER", "INPUT", "REQUIRED" ]
a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f
https://github.com/xypnox/email_purifier/blob/a9ecde9c5293b5c283e0c5b4cf8744c76418fb6f/epurifier/email_checker.py#L54-L80
train
Returns a Corrected email USER INPUT REQUIRED
frostming/marko
marko/parser.py
Parser.add_element
def add_element(self, element, override=False): """Add an element to the parser. :param element: the element class. :param override: whether to replace the default element based on. .. note:: If one needs to call it inside ``__init__()``, please call it after ``super().__i...
python
def add_element(self, element, override=False): """Add an element to the parser. :param element: the element class. :param override: whether to replace the default element based on. .. note:: If one needs to call it inside ``__init__()``, please call it after ``super().__i...
[ "def", "add_element", "(", "self", ",", "element", ",", "override", "=", "False", ")", ":", "if", "issubclass", "(", "element", ",", "inline", ".", "InlineElement", ")", ":", "dest", "=", "self", ".", "inline_elements", "elif", "issubclass", "(", "element"...
Add an element to the parser. :param element: the element class. :param override: whether to replace the default element based on. .. note:: If one needs to call it inside ``__init__()``, please call it after ``super().__init__()`` is called.
[ "Add", "an", "element", "to", "the", "parser", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/parser.py#L37-L63
train
Add an element to the parser.
frostming/marko
marko/parser.py
Parser.parse
def parse(self, source_or_text): """Do the actual parsing and returns an AST or parsed element. :param source_or_text: the text or source object. Based on the type, it will do following: - text: returns the parsed Document element. - source: parse the source and retu...
python
def parse(self, source_or_text): """Do the actual parsing and returns an AST or parsed element. :param source_or_text: the text or source object. Based on the type, it will do following: - text: returns the parsed Document element. - source: parse the source and retu...
[ "def", "parse", "(", "self", ",", "source_or_text", ")", ":", "if", "isinstance", "(", "source_or_text", ",", "string_types", ")", ":", "block", ".", "parser", "=", "self", "inline", ".", "parser", "=", "self", "return", "self", ".", "block_elements", "[",...
Do the actual parsing and returns an AST or parsed element. :param source_or_text: the text or source object. Based on the type, it will do following: - text: returns the parsed Document element. - source: parse the source and returns the parsed children as a list.
[ "Do", "the", "actual", "parsing", "and", "returns", "an", "AST", "or", "parsed", "element", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/parser.py#L65-L90
train
Do the actual parsing and returns an AST or parsed element.
frostming/marko
marko/parser.py
Parser.parse_inline
def parse_inline(self, text): """Parses text into inline elements. RawText is not considered in parsing but created as a wrapper of holes that don't match any other elements. :param text: the text to be parsed. :returns: a list of inline elements. """ element_lis...
python
def parse_inline(self, text): """Parses text into inline elements. RawText is not considered in parsing but created as a wrapper of holes that don't match any other elements. :param text: the text to be parsed. :returns: a list of inline elements. """ element_lis...
[ "def", "parse_inline", "(", "self", ",", "text", ")", ":", "element_list", "=", "self", ".", "_build_inline_element_list", "(", ")", "return", "inline_parser", ".", "parse", "(", "text", ",", "element_list", ",", "fallback", "=", "self", ".", "inline_elements"...
Parses text into inline elements. RawText is not considered in parsing but created as a wrapper of holes that don't match any other elements. :param text: the text to be parsed. :returns: a list of inline elements.
[ "Parses", "text", "into", "inline", "elements", ".", "RawText", "is", "not", "considered", "in", "parsing", "but", "created", "as", "a", "wrapper", "of", "holes", "that", "don", "t", "match", "any", "other", "elements", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/parser.py#L92-L103
train
Parses the given text into inline elements.
frostming/marko
marko/parser.py
Parser._build_block_element_list
def _build_block_element_list(self): """Return a list of block elements, ordered from highest priority to lowest. """ return sorted( [e for e in self.block_elements.values() if not e.virtual], key=lambda e: e.priority, reverse=True )
python
def _build_block_element_list(self): """Return a list of block elements, ordered from highest priority to lowest. """ return sorted( [e for e in self.block_elements.values() if not e.virtual], key=lambda e: e.priority, reverse=True )
[ "def", "_build_block_element_list", "(", "self", ")", ":", "return", "sorted", "(", "[", "e", "for", "e", "in", "self", ".", "block_elements", ".", "values", "(", ")", "if", "not", "e", ".", "virtual", "]", ",", "key", "=", "lambda", "e", ":", "e", ...
Return a list of block elements, ordered from highest priority to lowest.
[ "Return", "a", "list", "of", "block", "elements", "ordered", "from", "highest", "priority", "to", "lowest", "." ]
1cd030b665fa37bad1f8b3a25a89ce1a7c491dde
https://github.com/frostming/marko/blob/1cd030b665fa37bad1f8b3a25a89ce1a7c491dde/marko/parser.py#L105-L112
train
Build a list of block elements ordered from highest priority to lowest.
rsgalloway/grit
grit/server/server.py
make_app
def make_app(*args, **kw): ''' Assembles basic WSGI-compatible application providing functionality of git-http-backend. content_path (Defaults to '.' = "current" directory) The path to the folder that will be the root of served files. Accepts relative paths. uri_marker (Defaults to '') ...
python
def make_app(*args, **kw): ''' Assembles basic WSGI-compatible application providing functionality of git-http-backend. content_path (Defaults to '.' = "current" directory) The path to the folder that will be the root of served files. Accepts relative paths. uri_marker (Defaults to '') ...
[ "def", "make_app", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "default_options", "=", "[", "[", "'content_path'", ",", "'.'", "]", ",", "[", "'uri_marker'", ",", "''", "]", "]", "args", "=", "list", "(", "args", ")", "options", "=", "dict", ...
Assembles basic WSGI-compatible application providing functionality of git-http-backend. content_path (Defaults to '.' = "current" directory) The path to the folder that will be the root of served files. Accepts relative paths. uri_marker (Defaults to '') Acts as a "virtual folder" separator b...
[ "Assembles", "basic", "WSGI", "-", "compatible", "application", "providing", "functionality", "of", "git", "-", "http", "-", "backend", "." ]
e6434ad8a1f4ac5d0903ebad630c81f8a5164d78
https://github.com/rsgalloway/grit/blob/e6434ad8a1f4ac5d0903ebad630c81f8a5164d78/grit/server/server.py#L41-L116
train
This function creates a WSGI application that can be used to serve files from the server.
polyaxon/hestia
hestia/tz_utils.py
now
def now(tzinfo=True): """ Return an aware or naive datetime.datetime, depending on settings.USE_TZ. """ if dj_now: return dj_now() if tzinfo: # timeit shows that datetime.now(tz=utc) is 24% slower return datetime.utcnow().replace(tzinfo=utc) return datetime.now()
python
def now(tzinfo=True): """ Return an aware or naive datetime.datetime, depending on settings.USE_TZ. """ if dj_now: return dj_now() if tzinfo: # timeit shows that datetime.now(tz=utc) is 24% slower return datetime.utcnow().replace(tzinfo=utc) return datetime.now()
[ "def", "now", "(", "tzinfo", "=", "True", ")", ":", "if", "dj_now", ":", "return", "dj_now", "(", ")", "if", "tzinfo", ":", "# timeit shows that datetime.now(tz=utc) is 24% slower", "return", "datetime", ".", "utcnow", "(", ")", ".", "replace", "(", "tzinfo", ...
Return an aware or naive datetime.datetime, depending on settings.USE_TZ.
[ "Return", "an", "aware", "or", "naive", "datetime", ".", "datetime", "depending", "on", "settings", ".", "USE_TZ", "." ]
382ed139cff8bf35c987cfc30a31b72c0d6b808e
https://github.com/polyaxon/hestia/blob/382ed139cff8bf35c987cfc30a31b72c0d6b808e/hestia/tz_utils.py#L21-L31
train
Return an aware or naive datetime. datetime depending on settings. USE_TZ.
inveniosoftware/invenio-query-parser
invenio_query_parser/walkers/match_unit.py
dottable_getitem
def dottable_getitem(data, dottable_key, default=None): """Return item as ``dict.__getitem__` but using keys with dots. It does not address indexes in iterables. """ def getitem(value, *keys): if not keys: return default elif len(keys) == 1: key = keys[0] ...
python
def dottable_getitem(data, dottable_key, default=None): """Return item as ``dict.__getitem__` but using keys with dots. It does not address indexes in iterables. """ def getitem(value, *keys): if not keys: return default elif len(keys) == 1: key = keys[0] ...
[ "def", "dottable_getitem", "(", "data", ",", "dottable_key", ",", "default", "=", "None", ")", ":", "def", "getitem", "(", "value", ",", "*", "keys", ")", ":", "if", "not", "keys", ":", "return", "default", "elif", "len", "(", "keys", ")", "==", "1",...
Return item as ``dict.__getitem__` but using keys with dots. It does not address indexes in iterables.
[ "Return", "item", "as", "dict", ".", "__getitem__", "but", "using", "keys", "with", "dots", "." ]
21a2c36318003ff52d2e18e7196bb420db8ecb4b
https://github.com/inveniosoftware/invenio-query-parser/blob/21a2c36318003ff52d2e18e7196bb420db8ecb4b/invenio_query_parser/walkers/match_unit.py#L37-L54
train
Return item as dict. __getitem__ but using keys with dots.
inveniosoftware/invenio-query-parser
invenio_query_parser/walkers/match_unit.py
match_unit
def match_unit(data, p, m='a'): """Match data to basic match unit.""" if data is None: return p is None # compile search value only once for non exact search if m != 'e' and isinstance(p, six.string_types): p = re.compile(p) if isinstance(data, Sequence) and not isinstance(data, si...
python
def match_unit(data, p, m='a'): """Match data to basic match unit.""" if data is None: return p is None # compile search value only once for non exact search if m != 'e' and isinstance(p, six.string_types): p = re.compile(p) if isinstance(data, Sequence) and not isinstance(data, si...
[ "def", "match_unit", "(", "data", ",", "p", ",", "m", "=", "'a'", ")", ":", "if", "data", "is", "None", ":", "return", "p", "is", "None", "# compile search value only once for non exact search", "if", "m", "!=", "'e'", "and", "isinstance", "(", "p", ",", ...
Match data to basic match unit.
[ "Match", "data", "to", "basic", "match", "unit", "." ]
21a2c36318003ff52d2e18e7196bb420db8ecb4b
https://github.com/inveniosoftware/invenio-query-parser/blob/21a2c36318003ff52d2e18e7196bb420db8ecb4b/invenio_query_parser/walkers/match_unit.py#L57-L80
train
Match data to basic match unit.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/pipeline.py
generate_ppi_network
def generate_ppi_network( ppi_graph_path: str, dge_list: List[Gene], max_adj_p: float, max_log2_fold_change: float, min_log2_fold_change: float, ppi_edge_min_confidence: Optional[float] = None, current_disease_ids_path: Optional[str] = None, disease_associ...
python
def generate_ppi_network( ppi_graph_path: str, dge_list: List[Gene], max_adj_p: float, max_log2_fold_change: float, min_log2_fold_change: float, ppi_edge_min_confidence: Optional[float] = None, current_disease_ids_path: Optional[str] = None, disease_associ...
[ "def", "generate_ppi_network", "(", "ppi_graph_path", ":", "str", ",", "dge_list", ":", "List", "[", "Gene", "]", ",", "max_adj_p", ":", "float", ",", "max_log2_fold_change", ":", "float", ",", "min_log2_fold_change", ":", "float", ",", "ppi_edge_min_confidence", ...
Generate the protein-protein interaction network. :return Network: Protein-protein interaction network with information on differential expression.
[ "Generate", "the", "protein", "-", "protein", "interaction", "network", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/pipeline.py#L20-L54
train
Generate a protein - protein interaction network with information on differential expression.
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/pipeline.py
parse_dge
def parse_dge( dge_path: str, entrez_id_header: str, log2_fold_change_header: str, adj_p_header: str, entrez_delimiter: str, base_mean_header: Optional[str] = None ) -> List[Gene]: """Parse a differential expression file. :param dge_path: Path to the file. :p...
python
def parse_dge( dge_path: str, entrez_id_header: str, log2_fold_change_header: str, adj_p_header: str, entrez_delimiter: str, base_mean_header: Optional[str] = None ) -> List[Gene]: """Parse a differential expression file. :param dge_path: Path to the file. :p...
[ "def", "parse_dge", "(", "dge_path", ":", "str", ",", "entrez_id_header", ":", "str", ",", "log2_fold_change_header", ":", "str", ",", "adj_p_header", ":", "str", ",", "entrez_delimiter", ":", "str", ",", "base_mean_header", ":", "Optional", "[", "str", "]", ...
Parse a differential expression file. :param dge_path: Path to the file. :param entrez_id_header: Header for the Entrez identifier column :param log2_fold_change_header: Header for the log2 fold change column :param adj_p_header: Header for the adjusted p-value column :param entrez_delimiter: Delim...
[ "Parse", "a", "differential", "expression", "file", "." ]
4d7b6713485f2d0a0957e6457edc1b1b5a237460
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/pipeline.py#L57-L106
train
Parses a differential expression file.
BernardFW/bernard
src/bernard/conf/loader.py
Settings._load
def _load(self, file_path: Text) -> None: """ Load the configuration from a plain Python file. This file is executed on its own. Only keys matching the CONFIG_ATTR will be loaded. Basically, it's CONFIG_KEYS_LIKE_THIS. :param file_path: Path to the file to load ...
python
def _load(self, file_path: Text) -> None: """ Load the configuration from a plain Python file. This file is executed on its own. Only keys matching the CONFIG_ATTR will be loaded. Basically, it's CONFIG_KEYS_LIKE_THIS. :param file_path: Path to the file to load ...
[ "def", "_load", "(", "self", ",", "file_path", ":", "Text", ")", "->", "None", ":", "# noinspection PyUnresolvedReferences", "module_", "=", "types", ".", "ModuleType", "(", "'settings'", ")", "module_", ".", "__file__", "=", "file_path", "try", ":", "with", ...
Load the configuration from a plain Python file. This file is executed on its own. Only keys matching the CONFIG_ATTR will be loaded. Basically, it's CONFIG_KEYS_LIKE_THIS. :param file_path: Path to the file to load
[ "Load", "the", "configuration", "from", "a", "plain", "Python", "file", ".", "This", "file", "is", "executed", "on", "its", "own", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/conf/loader.py#L38-L63
train
Load the configuration from a plain Python file.
BernardFW/bernard
src/bernard/conf/loader.py
LazySettings._settings
def _settings(self) -> Settings: """ Return the actual settings object, or create it if missing. """ if self.__dict__['__settings'] is None: self.__dict__['__settings'] = Settings() for file_path in self._get_files(): if file_path: ...
python
def _settings(self) -> Settings: """ Return the actual settings object, or create it if missing. """ if self.__dict__['__settings'] is None: self.__dict__['__settings'] = Settings() for file_path in self._get_files(): if file_path: ...
[ "def", "_settings", "(", "self", ")", "->", "Settings", ":", "if", "self", ".", "__dict__", "[", "'__settings'", "]", "is", "None", ":", "self", ".", "__dict__", "[", "'__settings'", "]", "=", "Settings", "(", ")", "for", "file_path", "in", "self", "."...
Return the actual settings object, or create it if missing.
[ "Return", "the", "actual", "settings", "object", "or", "create", "it", "if", "missing", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/conf/loader.py#L84-L94
train
Returns the actual settings object or creates it if missing.
BernardFW/bernard
src/bernard/storage/register/redis.py
RedisRegisterStore._start
async def _start(self, key: Text) -> None: """ Start the lock. Here we use a SETNX-based algorithm. It's quite shitty, change it. """ for _ in range(0, 1000): with await self.pool as r: just_set = await r.set( self.lock_key(key), ...
python
async def _start(self, key: Text) -> None: """ Start the lock. Here we use a SETNX-based algorithm. It's quite shitty, change it. """ for _ in range(0, 1000): with await self.pool as r: just_set = await r.set( self.lock_key(key), ...
[ "async", "def", "_start", "(", "self", ",", "key", ":", "Text", ")", "->", "None", ":", "for", "_", "in", "range", "(", "0", ",", "1000", ")", ":", "with", "await", "self", ".", "pool", "as", "r", ":", "just_set", "=", "await", "r", ".", "set",...
Start the lock. Here we use a SETNX-based algorithm. It's quite shitty, change it.
[ "Start", "the", "lock", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/storage/register/redis.py#L42-L60
train
Start the lock.
BernardFW/bernard
src/bernard/storage/register/redis.py
RedisRegisterStore._finish
async def _finish(self, key: Text) -> None: """ Remove the lock. """ with await self.pool as r: await r.delete(self.lock_key(key))
python
async def _finish(self, key: Text) -> None: """ Remove the lock. """ with await self.pool as r: await r.delete(self.lock_key(key))
[ "async", "def", "_finish", "(", "self", ",", "key", ":", "Text", ")", "->", "None", ":", "with", "await", "self", ".", "pool", "as", "r", ":", "await", "r", ".", "delete", "(", "self", ".", "lock_key", "(", "key", ")", ")" ]
Remove the lock.
[ "Remove", "the", "lock", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/storage/register/redis.py#L62-L68
train
Remove the lock.
BernardFW/bernard
src/bernard/storage/register/redis.py
RedisRegisterStore._get
async def _get(self, key: Text) -> Dict[Text, Any]: """ Get the value for the key. It is automatically deserialized from JSON and returns an empty dictionary by default. """ try: with await self.pool as r: return ujson.loads(await r.get(self.register_...
python
async def _get(self, key: Text) -> Dict[Text, Any]: """ Get the value for the key. It is automatically deserialized from JSON and returns an empty dictionary by default. """ try: with await self.pool as r: return ujson.loads(await r.get(self.register_...
[ "async", "def", "_get", "(", "self", ",", "key", ":", "Text", ")", "->", "Dict", "[", "Text", ",", "Any", "]", ":", "try", ":", "with", "await", "self", ".", "pool", "as", "r", ":", "return", "ujson", ".", "loads", "(", "await", "r", ".", "get"...
Get the value for the key. It is automatically deserialized from JSON and returns an empty dictionary by default.
[ "Get", "the", "value", "for", "the", "key", ".", "It", "is", "automatically", "deserialized", "from", "JSON", "and", "returns", "an", "empty", "dictionary", "by", "default", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/storage/register/redis.py#L70-L80
train
Get the value for the key. It is automatically deserialized from JSON and returns an empty dictionary by default.
BernardFW/bernard
src/bernard/storage/register/redis.py
RedisRegisterStore._replace
async def _replace(self, key: Text, data: Dict[Text, Any]) -> None: """ Replace the register with a new value. """ with await self.pool as r: await r.set(self.register_key(key), ujson.dumps(data))
python
async def _replace(self, key: Text, data: Dict[Text, Any]) -> None: """ Replace the register with a new value. """ with await self.pool as r: await r.set(self.register_key(key), ujson.dumps(data))
[ "async", "def", "_replace", "(", "self", ",", "key", ":", "Text", ",", "data", ":", "Dict", "[", "Text", ",", "Any", "]", ")", "->", "None", ":", "with", "await", "self", ".", "pool", "as", "r", ":", "await", "r", ".", "set", "(", "self", ".", ...
Replace the register with a new value.
[ "Replace", "the", "register", "with", "a", "new", "value", "." ]
9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/storage/register/redis.py#L82-L88
train
Replace the register with a new value.
giancosta86/Iris
info/gianlucacosta/iris/maven.py
MavenArtifact.getFileName
def getFileName(self, suffix=None, extension="jar"): """ Returns the basename of the artifact's file, using Maven's conventions. In particular, it will be: <artifactId>-<version>[-<suffix>][.<extension>] """ assert (self._artifactId is not None) assert (sel...
python
def getFileName(self, suffix=None, extension="jar"): """ Returns the basename of the artifact's file, using Maven's conventions. In particular, it will be: <artifactId>-<version>[-<suffix>][.<extension>] """ assert (self._artifactId is not None) assert (sel...
[ "def", "getFileName", "(", "self", ",", "suffix", "=", "None", ",", "extension", "=", "\"jar\"", ")", ":", "assert", "(", "self", ".", "_artifactId", "is", "not", "None", ")", "assert", "(", "self", ".", "_version", "is", "not", "None", ")", "return", ...
Returns the basename of the artifact's file, using Maven's conventions. In particular, it will be: <artifactId>-<version>[-<suffix>][.<extension>]
[ "Returns", "the", "basename", "of", "the", "artifact", "s", "file", "using", "Maven", "s", "conventions", "." ]
b3d92cca5cce3653519bd032346b211c46a57d05
https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/maven.py#L50-L67
train
Returns the basename of the artifact s file using Maven s conventions.
giancosta86/Iris
info/gianlucacosta/iris/maven.py
MavenArtifact.getPath
def getPath(self, suffix=None, extension="jar", separator=os.sep): """ Returns the full path, relative to the root of a Maven repository, of the current artifact, using Maven's conventions. In particular, it will be: <groupId with "." replaced by <separator>>[<separator><ar...
python
def getPath(self, suffix=None, extension="jar", separator=os.sep): """ Returns the full path, relative to the root of a Maven repository, of the current artifact, using Maven's conventions. In particular, it will be: <groupId with "." replaced by <separator>>[<separator><ar...
[ "def", "getPath", "(", "self", ",", "suffix", "=", "None", ",", "extension", "=", "\"jar\"", ",", "separator", "=", "os", ".", "sep", ")", ":", "assert", "(", "self", ".", "_groupId", "is", "not", "None", ")", "resultComponents", "=", "[", "self", "....
Returns the full path, relative to the root of a Maven repository, of the current artifact, using Maven's conventions. In particular, it will be: <groupId with "." replaced by <separator>>[<separator><artifactId><separator>[<version><separator><basename obtained via getFileName()>]] ...
[ "Returns", "the", "full", "path", "relative", "to", "the", "root", "of", "a", "Maven", "repository", "of", "the", "current", "artifact", "using", "Maven", "s", "conventions", "." ]
b3d92cca5cce3653519bd032346b211c46a57d05
https://github.com/giancosta86/Iris/blob/b3d92cca5cce3653519bd032346b211c46a57d05/info/gianlucacosta/iris/maven.py#L70-L96
train
Returns the full path of the current artifact in a Maven repository.