repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
psss/fmf
fmf/base.py
Tree.get
def get(self, name=None, default=None): """ Get attribute value or return default Whole data dictionary is returned when no attribute provided. Supports direct values retrieval from deep dictionaries as well. Dictionary path should be provided as list. The following two ...
python
def get(self, name=None, default=None): """ Get attribute value or return default Whole data dictionary is returned when no attribute provided. Supports direct values retrieval from deep dictionaries as well. Dictionary path should be provided as list. The following two ...
[ "def", "get", "(", "self", ",", "name", "=", "None", ",", "default", "=", "None", ")", ":", "# Return the whole dictionary if no attribute specified", "if", "name", "is", "None", ":", "return", "self", ".", "data", "if", "not", "isinstance", "(", "name", ","...
Get attribute value or return default Whole data dictionary is returned when no attribute provided. Supports direct values retrieval from deep dictionaries as well. Dictionary path should be provided as list. The following two examples are equal: tree.data['hardware']['memory']...
[ "Get", "attribute", "value", "or", "return", "default" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L175-L202
psss/fmf
fmf/base.py
Tree.child
def child(self, name, data, source=None): """ Create or update child with given data """ try: if isinstance(data, dict): self.children[name].update(data) else: self.children[name].grow(data) except KeyError: self.children[name] ...
python
def child(self, name, data, source=None): """ Create or update child with given data """ try: if isinstance(data, dict): self.children[name].update(data) else: self.children[name].grow(data) except KeyError: self.children[name] ...
[ "def", "child", "(", "self", ",", "name", ",", "data", ",", "source", "=", "None", ")", ":", "try", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "self", ".", "children", "[", "name", "]", ".", "update", "(", "data", ")", "else", ...
Create or update child with given data
[ "Create", "or", "update", "child", "with", "given", "data" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L204-L215
psss/fmf
fmf/base.py
Tree.grow
def grow(self, path): """ Grow the metadata tree for the given directory path Note: For each path, grow() should be run only once. Growing the tree from the same path multiple times with attribute adding using the "+" sign leads to adding the value more than once! """ ...
python
def grow(self, path): """ Grow the metadata tree for the given directory path Note: For each path, grow() should be run only once. Growing the tree from the same path multiple times with attribute adding using the "+" sign leads to adding the value more than once! """ ...
[ "def", "grow", "(", "self", ",", "path", ")", ":", "if", "path", "is", "None", ":", "return", "path", "=", "path", ".", "rstrip", "(", "\"/\"", ")", "log", ".", "info", "(", "\"Walking through directory {0}\"", ".", "format", "(", "os", ".", "path", ...
Grow the metadata tree for the given directory path Note: For each path, grow() should be run only once. Growing the tree from the same path multiple times with attribute adding using the "+" sign leads to adding the value more than once!
[ "Grow", "the", "metadata", "tree", "for", "the", "given", "directory", "path" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L217-L276
psss/fmf
fmf/base.py
Tree.climb
def climb(self, whole=False): """ Climb through the tree (iterate leaf/all nodes) """ if whole or not self.children: yield self for name, child in self.children.items(): for node in child.climb(whole): yield node
python
def climb(self, whole=False): """ Climb through the tree (iterate leaf/all nodes) """ if whole or not self.children: yield self for name, child in self.children.items(): for node in child.climb(whole): yield node
[ "def", "climb", "(", "self", ",", "whole", "=", "False", ")", ":", "if", "whole", "or", "not", "self", ".", "children", ":", "yield", "self", "for", "name", ",", "child", "in", "self", ".", "children", ".", "items", "(", ")", ":", "for", "node", ...
Climb through the tree (iterate leaf/all nodes)
[ "Climb", "through", "the", "tree", "(", "iterate", "leaf", "/", "all", "nodes", ")" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L278-L284
psss/fmf
fmf/base.py
Tree.find
def find(self, name): """ Find node with given name """ for node in self.climb(whole=True): if node.name == name: return node return None
python
def find(self, name): """ Find node with given name """ for node in self.climb(whole=True): if node.name == name: return node return None
[ "def", "find", "(", "self", ",", "name", ")", ":", "for", "node", "in", "self", ".", "climb", "(", "whole", "=", "True", ")", ":", "if", "node", ".", "name", "==", "name", ":", "return", "node", "return", "None" ]
Find node with given name
[ "Find", "node", "with", "given", "name" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L286-L291
psss/fmf
fmf/base.py
Tree.prune
def prune(self, whole=False, keys=[], names=[], filters=[]): """ Filter tree nodes based on given criteria """ for node in self.climb(whole): # Select only nodes with key content if not all([key in node.data for key in keys]): continue # Select nodes w...
python
def prune(self, whole=False, keys=[], names=[], filters=[]): """ Filter tree nodes based on given criteria """ for node in self.climb(whole): # Select only nodes with key content if not all([key in node.data for key in keys]): continue # Select nodes w...
[ "def", "prune", "(", "self", ",", "whole", "=", "False", ",", "keys", "=", "[", "]", ",", "names", "=", "[", "]", ",", "filters", "=", "[", "]", ")", ":", "for", "node", "in", "self", ".", "climb", "(", "whole", ")", ":", "# Select only nodes wit...
Filter tree nodes based on given criteria
[ "Filter", "tree", "nodes", "based", "on", "given", "criteria" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L293-L312
psss/fmf
fmf/base.py
Tree.show
def show(self, brief=False, formatting=None, values=[]): """ Show metadata """ # Show nothing if there's nothing if not self.data: return None # Custom formatting if formatting is not None: formatting = re.sub("\\\\n", "\n", formatting) name =...
python
def show(self, brief=False, formatting=None, values=[]): """ Show metadata """ # Show nothing if there's nothing if not self.data: return None # Custom formatting if formatting is not None: formatting = re.sub("\\\\n", "\n", formatting) name =...
[ "def", "show", "(", "self", ",", "brief", "=", "False", ",", "formatting", "=", "None", ",", "values", "=", "[", "]", ")", ":", "# Show nothing if there's nothing", "if", "not", "self", ".", "data", ":", "return", "None", "# Custom formatting", "if", "form...
Show metadata
[ "Show", "metadata" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/base.py#L314-L347
samluescher/django-media-tree
media_tree/contrib/legacy_mptt_support/forms.py
TreeNodeChoiceField.label_from_instance
def label_from_instance(self, obj): """ Creates labels which represent the tree level of each node when generating option labels. """ level = getattr(obj, obj._mptt_meta.level_attr) level_indicator = mark_safe(conditional_escape(self.level_indicator) * level) retu...
python
def label_from_instance(self, obj): """ Creates labels which represent the tree level of each node when generating option labels. """ level = getattr(obj, obj._mptt_meta.level_attr) level_indicator = mark_safe(conditional_escape(self.level_indicator) * level) retu...
[ "def", "label_from_instance", "(", "self", ",", "obj", ")", ":", "level", "=", "getattr", "(", "obj", ",", "obj", ".", "_mptt_meta", ".", "level_attr", ")", "level_indicator", "=", "mark_safe", "(", "conditional_escape", "(", "self", ".", "level_indicator", ...
Creates labels which represent the tree level of each node when generating option labels.
[ "Creates", "labels", "which", "represent", "the", "tree", "level", "of", "each", "node", "when", "generating", "option", "labels", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/contrib/legacy_mptt_support/forms.py#L33-L40
samluescher/django-media-tree
media_tree/contrib/legacy_mptt_support/forms.py
MoveNodeForm.save
def save(self): """ Attempts to move the node using the selected target and position. If an invalid move is attempted, the related error message will be added to the form's non-field errors and the error will be re-raised. Callers should attempt to catch ``InvalidNode`` ...
python
def save(self): """ Attempts to move the node using the selected target and position. If an invalid move is attempted, the related error message will be added to the form's non-field errors and the error will be re-raised. Callers should attempt to catch ``InvalidNode`` ...
[ "def", "save", "(", "self", ")", ":", "try", ":", "self", ".", "node", ".", "move_to", "(", "self", ".", "cleaned_data", "[", "'target'", "]", ",", "self", ".", "cleaned_data", "[", "'position'", "]", ")", "return", "self", ".", "node", "except", "In...
Attempts to move the node using the selected target and position. If an invalid move is attempted, the related error message will be added to the form's non-field errors and the error will be re-raised. Callers should attempt to catch ``InvalidNode`` to redisplay the form with t...
[ "Attempts", "to", "move", "the", "node", "using", "the", "selected", "target", "and", "position", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/contrib/legacy_mptt_support/forms.py#L136-L152
samluescher/django-media-tree
media_tree/utils/staticfiles.py
StaticPathFinder.find
def find(names, dirs, file_ext): """ Iterating a set of dirs under the static root, this method tries to find a file named like one of the names and file ext passed, and returns the storage path to the first file it encounters. Usage this method makes it possible to over...
python
def find(names, dirs, file_ext): """ Iterating a set of dirs under the static root, this method tries to find a file named like one of the names and file ext passed, and returns the storage path to the first file it encounters. Usage this method makes it possible to over...
[ "def", "find", "(", "names", ",", "dirs", ",", "file_ext", ")", ":", "if", "not", "isinstance", "(", "names", ",", "list", ")", "or", "isinstance", "(", "names", ",", "tuple", ")", ":", "names", "=", "(", "names", ",", ")", "for", "dir_name", "in",...
Iterating a set of dirs under the static root, this method tries to find a file named like one of the names and file ext passed, and returns the storage path to the first file it encounters. Usage this method makes it possible to override static files (such as icon sets) in a s...
[ "Iterating", "a", "set", "of", "dirs", "under", "the", "static", "root", "this", "method", "tries", "to", "find", "a", "file", "named", "like", "one", "of", "the", "names", "and", "file", "ext", "passed", "and", "returns", "the", "storage", "path", "to",...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/staticfiles.py#L83-L102
samluescher/django-media-tree
media_tree/utils/staticfiles.py
MimetypeStaticIconFileFinder.find
def find(file_node, dirs=ICON_DIRS, default_name=None, file_ext='.png'): """ Iterating all icon dirs, try to find a file called like the node's extension / mime subtype / mime type (in that order). For instance, for an MP3 file ("audio/mpeg"), this would look for: "mp3.png" / "au...
python
def find(file_node, dirs=ICON_DIRS, default_name=None, file_ext='.png'): """ Iterating all icon dirs, try to find a file called like the node's extension / mime subtype / mime type (in that order). For instance, for an MP3 file ("audio/mpeg"), this would look for: "mp3.png" / "au...
[ "def", "find", "(", "file_node", ",", "dirs", "=", "ICON_DIRS", ",", "default_name", "=", "None", ",", "file_ext", "=", "'.png'", ")", ":", "names", "=", "[", "]", "for", "attr_name", "in", "(", "'extension'", ",", "'mimetype'", ",", "'mime_supertype'", ...
Iterating all icon dirs, try to find a file called like the node's extension / mime subtype / mime type (in that order). For instance, for an MP3 file ("audio/mpeg"), this would look for: "mp3.png" / "audio/mpeg.png" / "audio.png"
[ "Iterating", "all", "icon", "dirs", "try", "to", "find", "a", "file", "called", "like", "the", "node", "s", "extension", "/", "mime", "subtype", "/", "mime", "type", "(", "in", "that", "order", ")", ".", "For", "instance", "for", "an", "MP3", "file", ...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/staticfiles.py#L108-L124
samluescher/django-media-tree
media_tree/templatetags/media_tree_admin.py
result_tree_flat
def result_tree_flat(context, cl, request): """ Added 'filtered' param, so the template's js knows whether the results have been affected by a GET param or not. Only when the results are not filtered you can drag and sort the tree """ return { #'filtered': is_filtered_cl(cl, request), ...
python
def result_tree_flat(context, cl, request): """ Added 'filtered' param, so the template's js knows whether the results have been affected by a GET param or not. Only when the results are not filtered you can drag and sort the tree """ return { #'filtered': is_filtered_cl(cl, request), ...
[ "def", "result_tree_flat", "(", "context", ",", "cl", ",", "request", ")", ":", "return", "{", "#'filtered': is_filtered_cl(cl, request),", "'results'", ":", "(", "th_for_result", "(", "cl", ",", "res", ")", "for", "res", "in", "list", "(", "cl", ".", "resul...
Added 'filtered' param, so the template's js knows whether the results have been affected by a GET param or not. Only when the results are not filtered you can drag and sort the tree
[ "Added", "filtered", "param", "so", "the", "template", "s", "js", "knows", "whether", "the", "results", "have", "been", "affected", "by", "a", "GET", "param", "or", "not", ".", "Only", "when", "the", "results", "are", "not", "filtered", "you", "can", "dr...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/templatetags/media_tree_admin.py#L19-L29
samluescher/django-media-tree
media_tree/contrib/views/detail/__init__.py
FileNodeDetailView.get_object
def get_object(self, queryset=None): """ Returns the object the view is displaying. By default this requires `self.queryset` and a `pk` or `path` argument in the URLconf, but subclasses can override this to return any object. """ # Use a custom queryset if provided; this...
python
def get_object(self, queryset=None): """ Returns the object the view is displaying. By default this requires `self.queryset` and a `pk` or `path` argument in the URLconf, but subclasses can override this to return any object. """ # Use a custom queryset if provided; this...
[ "def", "get_object", "(", "self", ",", "queryset", "=", "None", ")", ":", "# Use a custom queryset if provided; this is required for subclasses", "# like DateDetailView", "if", "queryset", "is", "None", ":", "queryset", "=", "self", ".", "get_queryset", "(", ")", "pat...
Returns the object the view is displaying. By default this requires `self.queryset` and a `pk` or `path` argument in the URLconf, but subclasses can override this to return any object.
[ "Returns", "the", "object", "the", "view", "is", "displaying", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/contrib/views/detail/__init__.py#L49-L74
samluescher/django-media-tree
media_tree/contrib/views/detail/__init__.py
FileNodeDetailMixin.get_detail_view
def get_detail_view(self, request, object, opts=None): """ Instantiates and returns the view class that will generate the actual context for this plugin. """ view = self.get_view(request, self.view_class, opts) view.object = object return view
python
def get_detail_view(self, request, object, opts=None): """ Instantiates and returns the view class that will generate the actual context for this plugin. """ view = self.get_view(request, self.view_class, opts) view.object = object return view
[ "def", "get_detail_view", "(", "self", ",", "request", ",", "object", ",", "opts", "=", "None", ")", ":", "view", "=", "self", ".", "get_view", "(", "request", ",", "self", ".", "view_class", ",", "opts", ")", "view", ".", "object", "=", "object", "r...
Instantiates and returns the view class that will generate the actual context for this plugin.
[ "Instantiates", "and", "returns", "the", "view", "class", "that", "will", "generate", "the", "actual", "context", "for", "this", "plugin", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/contrib/views/detail/__init__.py#L97-L104
samluescher/django-media-tree
media_tree/contrib/views/listing/__init__.py
FileNodeListingMixin.get_listing_view
def get_listing_view(self, request, queryset, opts=None): """ Instantiates and returns the view class that will generate the actual context for this plugin. ``queryset`` can be an actual QuerySet or any iterable. """ view = self.get_view(request, self.view_class, opts) ...
python
def get_listing_view(self, request, queryset, opts=None): """ Instantiates and returns the view class that will generate the actual context for this plugin. ``queryset`` can be an actual QuerySet or any iterable. """ view = self.get_view(request, self.view_class, opts) ...
[ "def", "get_listing_view", "(", "self", ",", "request", ",", "queryset", ",", "opts", "=", "None", ")", ":", "view", "=", "self", ".", "get_view", "(", "request", ",", "self", ".", "view_class", ",", "opts", ")", "view", ".", "queryset", "=", "queryset...
Instantiates and returns the view class that will generate the actual context for this plugin. ``queryset`` can be an actual QuerySet or any iterable.
[ "Instantiates", "and", "returns", "the", "view", "class", "that", "will", "generate", "the", "actual", "context", "for", "this", "plugin", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/contrib/views/listing/__init__.py#L221-L230
samluescher/django-media-tree
media_tree/contrib/views/mixin_base.py
PluginMixin.get_view
def get_view(self, request, view_class, opts=None): """ Instantiates and returns the view class that will generate the actual context for this plugin. """ kwargs = {} if opts: if not isinstance(opts, dict): opts = opts.__dict__ else: ...
python
def get_view(self, request, view_class, opts=None): """ Instantiates and returns the view class that will generate the actual context for this plugin. """ kwargs = {} if opts: if not isinstance(opts, dict): opts = opts.__dict__ else: ...
[ "def", "get_view", "(", "self", ",", "request", ",", "view_class", ",", "opts", "=", "None", ")", ":", "kwargs", "=", "{", "}", "if", "opts", ":", "if", "not", "isinstance", "(", "opts", ",", "dict", ")", ":", "opts", "=", "opts", ".", "__dict__", ...
Instantiates and returns the view class that will generate the actual context for this plugin.
[ "Instantiates", "and", "returns", "the", "view", "class", "that", "will", "generate", "the", "actual", "context", "for", "this", "plugin", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/contrib/views/mixin_base.py#L24-L52
psss/fmf
fmf/cli.py
Parser.options_formatting
def options_formatting(self): """ Formating options """ group = self.parser.add_argument_group("Format") group.add_argument( "--format", dest="formatting", default=None, help="Custom output format using the {} expansion") group.add_argument( "--value",...
python
def options_formatting(self): """ Formating options """ group = self.parser.add_argument_group("Format") group.add_argument( "--format", dest="formatting", default=None, help="Custom output format using the {} expansion") group.add_argument( "--value",...
[ "def", "options_formatting", "(", "self", ")", ":", "group", "=", "self", ".", "parser", ".", "add_argument_group", "(", "\"Format\"", ")", "group", ".", "add_argument", "(", "\"--format\"", ",", "dest", "=", "\"formatting\"", ",", "default", "=", "None", ",...
Formating options
[ "Formating", "options" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/cli.py#L91-L99
psss/fmf
fmf/cli.py
Parser.options_utils
def options_utils(self): """ Utilities """ group = self.parser.add_argument_group("Utils") group.add_argument( "--path", action="append", dest="paths", help="Path to the metadata tree (default: current directory)") group.add_argument( "--verbose", acti...
python
def options_utils(self): """ Utilities """ group = self.parser.add_argument_group("Utils") group.add_argument( "--path", action="append", dest="paths", help="Path to the metadata tree (default: current directory)") group.add_argument( "--verbose", acti...
[ "def", "options_utils", "(", "self", ")", ":", "group", "=", "self", ".", "parser", ".", "add_argument_group", "(", "\"Utils\"", ")", "group", ".", "add_argument", "(", "\"--path\"", ",", "action", "=", "\"append\"", ",", "dest", "=", "\"paths\"", ",", "he...
Utilities
[ "Utilities" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/cli.py#L101-L112
psss/fmf
fmf/cli.py
Parser.command_ls
def command_ls(self): """ List names """ self.parser = argparse.ArgumentParser( description="List names of available objects") self.options_select() self.options_utils() self.options = self.parser.parse_args(self.arguments[2:]) self.show(brief=True)
python
def command_ls(self): """ List names """ self.parser = argparse.ArgumentParser( description="List names of available objects") self.options_select() self.options_utils() self.options = self.parser.parse_args(self.arguments[2:]) self.show(brief=True)
[ "def", "command_ls", "(", "self", ")", ":", "self", ".", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"List names of available objects\"", ")", "self", ".", "options_select", "(", ")", "self", ".", "options_utils", "(", ")", "se...
List names
[ "List", "names" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/cli.py#L114-L121
psss/fmf
fmf/cli.py
Parser.command_show
def command_show(self): """ Show metadata """ self.parser = argparse.ArgumentParser( description="Show metadata of available objects") self.options_select() self.options_formatting() self.options_utils() self.options = self.parser.parse_args(self.arguments[2:]...
python
def command_show(self): """ Show metadata """ self.parser = argparse.ArgumentParser( description="Show metadata of available objects") self.options_select() self.options_formatting() self.options_utils() self.options = self.parser.parse_args(self.arguments[2:]...
[ "def", "command_show", "(", "self", ")", ":", "self", ".", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Show metadata of available objects\"", ")", "self", ".", "options_select", "(", ")", "self", ".", "options_formatting", "(", ...
Show metadata
[ "Show", "metadata" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/cli.py#L123-L131
psss/fmf
fmf/cli.py
Parser.command_init
def command_init(self): """ Initialize tree """ self.parser = argparse.ArgumentParser( description="Initialize a new metadata tree") self.options_utils() self.options = self.parser.parse_args(self.arguments[2:]) # For each path create an .fmf directory and version fil...
python
def command_init(self): """ Initialize tree """ self.parser = argparse.ArgumentParser( description="Initialize a new metadata tree") self.options_utils() self.options = self.parser.parse_args(self.arguments[2:]) # For each path create an .fmf directory and version fil...
[ "def", "command_init", "(", "self", ")", ":", "self", ".", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Initialize a new metadata tree\"", ")", "self", ".", "options_utils", "(", ")", "self", ".", "options", "=", "self", ".", ...
Initialize tree
[ "Initialize", "tree" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/cli.py#L133-L148
psss/fmf
fmf/cli.py
Parser.show
def show(self, brief=False): """ Show metadata for each path given """ output = [] for path in self.options.paths or ["."]: if self.options.verbose: utils.info("Checking {0} for metadata.".format(path)) tree = fmf.Tree(path) for node in tree.pr...
python
def show(self, brief=False): """ Show metadata for each path given """ output = [] for path in self.options.paths or ["."]: if self.options.verbose: utils.info("Checking {0} for metadata.".format(path)) tree = fmf.Tree(path) for node in tree.pr...
[ "def", "show", "(", "self", ",", "brief", "=", "False", ")", ":", "output", "=", "[", "]", "for", "path", "in", "self", ".", "options", ".", "paths", "or", "[", "\".\"", "]", ":", "if", "self", ".", "options", ".", "verbose", ":", "utils", ".", ...
Show metadata for each path given
[ "Show", "metadata", "for", "each", "path", "given" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/cli.py#L150-L186
psss/fmf
fmf/utils.py
filter
def filter(filter, data, sensitive=True, regexp=False): """ Return true if provided filter matches given dictionary of values Filter supports disjunctive normal form with '|' used for OR, '&' for AND and '-' for negation. Individual values are prefixed with 'value:', leading/trailing white-space is...
python
def filter(filter, data, sensitive=True, regexp=False): """ Return true if provided filter matches given dictionary of values Filter supports disjunctive normal form with '|' used for OR, '&' for AND and '-' for negation. Individual values are prefixed with 'value:', leading/trailing white-space is...
[ "def", "filter", "(", "filter", ",", "data", ",", "sensitive", "=", "True", ",", "regexp", "=", "False", ")", ":", "def", "match_value", "(", "pattern", ",", "text", ")", ":", "\"\"\" Match value against data (simple or regexp) \"\"\"", "if", "regexp", ":", "r...
Return true if provided filter matches given dictionary of values Filter supports disjunctive normal form with '|' used for OR, '&' for AND and '-' for negation. Individual values are prefixed with 'value:', leading/trailing white-space is stripped. For example:: tag: Tier1 | tag: Tier2 | tag: Tie...
[ "Return", "true", "if", "provided", "filter", "matches", "given", "dictionary", "of", "values" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/utils.py#L150-L267
psss/fmf
fmf/utils.py
color
def color(text, color=None, background=None, light=False, enabled="auto"): """ Return text in desired color if coloring enabled Available colors: black red green yellow blue magenta cyan white. Alternatively color can be prefixed with "light", e.g. lightgreen. """ colors = {"black": 30, "red": ...
python
def color(text, color=None, background=None, light=False, enabled="auto"): """ Return text in desired color if coloring enabled Available colors: black red green yellow blue magenta cyan white. Alternatively color can be prefixed with "light", e.g. lightgreen. """ colors = {"black": 30, "red": ...
[ "def", "color", "(", "text", ",", "color", "=", "None", ",", "background", "=", "None", ",", "light", "=", "False", ",", "enabled", "=", "\"auto\"", ")", ":", "colors", "=", "{", "\"black\"", ":", "30", ",", "\"red\"", ":", "31", ",", "\"green\"", ...
Return text in desired color if coloring enabled Available colors: black red green yellow blue magenta cyan white. Alternatively color can be prefixed with "light", e.g. lightgreen.
[ "Return", "text", "in", "desired", "color", "if", "coloring", "enabled" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/utils.py#L391-L415
psss/fmf
fmf/utils.py
Logging._create_logger
def _create_logger(name='fmf', level=None): """ Create fmf logger """ # Create logger, handler and formatter logger = logging.getLogger(name) handler = logging.StreamHandler() handler.setFormatter(Logging.ColoredFormatter()) logger.addHandler(handler) # Save log l...
python
def _create_logger(name='fmf', level=None): """ Create fmf logger """ # Create logger, handler and formatter logger = logging.getLogger(name) handler = logging.StreamHandler() handler.setFormatter(Logging.ColoredFormatter()) logger.addHandler(handler) # Save log l...
[ "def", "_create_logger", "(", "name", "=", "'fmf'", ",", "level", "=", "None", ")", ":", "# Create logger, handler and formatter", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "handler", "=", "logging", ".", "StreamHandler", "(", ")", "handler...
Create fmf logger
[ "Create", "fmf", "logger" ]
train
https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/utils.py#L338-L355
samluescher/django-media-tree
media_tree/models.py
FileNodeManager.filter
def filter(self, *args, **kwargs): """ Works just like the default Manager's :func:`filter` method, but you can pass an additional keyword argument named ``path`` specifying the full **path of the folder whose immediate child objects** you want to retrieve, e.g. ``"path/to/folder...
python
def filter(self, *args, **kwargs): """ Works just like the default Manager's :func:`filter` method, but you can pass an additional keyword argument named ``path`` specifying the full **path of the folder whose immediate child objects** you want to retrieve, e.g. ``"path/to/folder...
[ "def", "filter", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'path'", "in", "kwargs", ":", "kwargs", "=", "self", ".", "get_filter_args_with_path", "(", "False", ",", "*", "*", "kwargs", ")", "return", "super", "(", "File...
Works just like the default Manager's :func:`filter` method, but you can pass an additional keyword argument named ``path`` specifying the full **path of the folder whose immediate child objects** you want to retrieve, e.g. ``"path/to/folder"``.
[ "Works", "just", "like", "the", "default", "Manager", "s", ":", "func", ":", "filter", "method", "but", "you", "can", "pass", "an", "additional", "keyword", "argument", "named", "path", "specifying", "the", "full", "**", "path", "of", "the", "folder", "who...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L80-L89
samluescher/django-media-tree
media_tree/models.py
FileNodeManager.exclude
def exclude(self, *args, **kwargs): """ Works just like the default Manager's :func:`exclude` method, but you can pass an additional keyword argument named ``path`` specifying the full **path of the folder whose immediate child objects** you want to exclude, e.g. ``"path/to/folde...
python
def exclude(self, *args, **kwargs): """ Works just like the default Manager's :func:`exclude` method, but you can pass an additional keyword argument named ``path`` specifying the full **path of the folder whose immediate child objects** you want to exclude, e.g. ``"path/to/folde...
[ "def", "exclude", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'path'", "in", "kwargs", ":", "kwargs", "=", "self", ".", "get_filter_args_with_path", "(", "False", ",", "*", "*", "kwargs", ")", "return", "super", "(", "Fil...
Works just like the default Manager's :func:`exclude` method, but you can pass an additional keyword argument named ``path`` specifying the full **path of the folder whose immediate child objects** you want to exclude, e.g. ``"path/to/folder"``.
[ "Works", "just", "like", "the", "default", "Manager", "s", ":", "func", ":", "exclude", "method", "but", "you", "can", "pass", "an", "additional", "keyword", "argument", "named", "path", "specifying", "the", "full", "**", "path", "of", "the", "folder", "wh...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L91-L100
samluescher/django-media-tree
media_tree/models.py
FileNodeManager.get
def get(self, *args, **kwargs): """ Works just like the default Manager's :func:`get` method, but you can pass an additional keyword argument named ``path`` specifying the full path of the object you want to retrieve, e.g. ``"path/to/folder/readme.txt"``. """ if '...
python
def get(self, *args, **kwargs): """ Works just like the default Manager's :func:`get` method, but you can pass an additional keyword argument named ``path`` specifying the full path of the object you want to retrieve, e.g. ``"path/to/folder/readme.txt"``. """ if '...
[ "def", "get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'path'", "in", "kwargs", ":", "kwargs", "=", "self", ".", "get_filter_args_with_path", "(", "True", ",", "*", "*", "kwargs", ")", "return", "super", "(", "FileNode...
Works just like the default Manager's :func:`get` method, but you can pass an additional keyword argument named ``path`` specifying the full path of the object you want to retrieve, e.g. ``"path/to/folder/readme.txt"``.
[ "Works", "just", "like", "the", "default", "Manager", "s", ":", "func", ":", "get", "method", "but", "you", "can", "pass", "an", "additional", "keyword", "argument", "named", "path", "specifying", "the", "full", "path", "of", "the", "object", "you", "want"...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L102-L112
samluescher/django-media-tree
media_tree/models.py
MultipleChoiceCommaSeparatedIntegerField.validate
def validate(self, value, model_instance): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ if not self.editable: # Skip validation for non-editable fields. return if self._choices and...
python
def validate(self, value, model_instance): """ Validates value and throws ValidationError. Subclasses should override this to provide validation logic. """ if not self.editable: # Skip validation for non-editable fields. return if self._choices and...
[ "def", "validate", "(", "self", ",", "value", ",", "model_instance", ")", ":", "if", "not", "self", ".", "editable", ":", "# Skip validation for non-editable fields.", "return", "if", "self", ".", "_choices", "and", "value", ":", "print", "(", "value", ")", ...
Validates value and throws ValidationError. Subclasses should override this to provide validation logic.
[ "Validates", "value", "and", "throws", "ValidationError", ".", "Subclasses", "should", "override", "this", "to", "provide", "validation", "logic", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L151-L181
samluescher/django-media-tree
media_tree/models.py
FileNode.get_qualified_file_url
def get_qualified_file_url(self, field_name='file'): """Returns a fully qualified URL for the :attr:`file` field, including protocol, domain and port. In most cases, you can just use ``file.url`` instead, which (depending on your ``MEDIA_URL``) may or may not contain the domain. In some ...
python
def get_qualified_file_url(self, field_name='file'): """Returns a fully qualified URL for the :attr:`file` field, including protocol, domain and port. In most cases, you can just use ``file.url`` instead, which (depending on your ``MEDIA_URL``) may or may not contain the domain. In some ...
[ "def", "get_qualified_file_url", "(", "self", ",", "field_name", "=", "'file'", ")", ":", "url", "=", "getattr", "(", "self", ",", "field_name", ")", ".", "url", "if", "'://'", "in", "url", ":", "# `MEDIA_URL` already contains domain", "return", "url", "protoc...
Returns a fully qualified URL for the :attr:`file` field, including protocol, domain and port. In most cases, you can just use ``file.url`` instead, which (depending on your ``MEDIA_URL``) may or may not contain the domain. In some cases however, you always need a fully qualified URL. Th...
[ "Returns", "a", "fully", "qualified", "URL", "for", "the", ":", "attr", ":", "file", "field", "including", "protocol", "domain", "and", "port", ".", "In", "most", "cases", "you", "can", "just", "use", "file", ".", "url", "instead", "which", "(", "dependi...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L412-L432
samluescher/django-media-tree
media_tree/models.py
FileNode.get_admin_url
def get_admin_url(self, query_params=None, use_path=False): """Returns the URL for viewing a FileNode in the admin.""" if not query_params: query_params = {} url = '' if self.is_top_node(): url = reverse('admin:media_tree_filenode_changelist'); elif use_...
python
def get_admin_url(self, query_params=None, use_path=False): """Returns the URL for viewing a FileNode in the admin.""" if not query_params: query_params = {} url = '' if self.is_top_node(): url = reverse('admin:media_tree_filenode_changelist'); elif use_...
[ "def", "get_admin_url", "(", "self", ",", "query_params", "=", "None", ",", "use_path", "=", "False", ")", ":", "if", "not", "query_params", ":", "query_params", "=", "{", "}", "url", "=", "''", "if", "self", ".", "is_top_node", "(", ")", ":", "url", ...
Returns the URL for viewing a FileNode in the admin.
[ "Returns", "the", "URL", "for", "viewing", "a", "FileNode", "in", "the", "admin", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L482-L503
samluescher/django-media-tree
media_tree/models.py
FileNode.get_metadata_display
def get_metadata_display(self, field_formats = {}, escape=True): """Returns object metadata that has been selected to be displayed to users, compiled as a string. """ def field_format(field): if field in field_formats: return field_formats[field] r...
python
def get_metadata_display(self, field_formats = {}, escape=True): """Returns object metadata that has been selected to be displayed to users, compiled as a string. """ def field_format(field): if field in field_formats: return field_formats[field] r...
[ "def", "get_metadata_display", "(", "self", ",", "field_formats", "=", "{", "}", ",", "escape", "=", "True", ")", ":", "def", "field_format", "(", "field", ")", ":", "if", "field", "in", "field_formats", ":", "return", "field_formats", "[", "field", "]", ...
Returns object metadata that has been selected to be displayed to users, compiled as a string.
[ "Returns", "object", "metadata", "that", "has", "been", "selected", "to", "be", "displayed", "to", "users", "compiled", "as", "a", "string", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L665-L682
samluescher/django-media-tree
media_tree/models.py
FileNode.get_caption_formatted
def get_caption_formatted(self, field_formats = app_settings.MEDIA_TREE_METADATA_FORMATS, escape=True): """Returns object metadata that has been selected to be displayed to users, compiled as a string including default formatting, for example bold titles. You can use this method in temp...
python
def get_caption_formatted(self, field_formats = app_settings.MEDIA_TREE_METADATA_FORMATS, escape=True): """Returns object metadata that has been selected to be displayed to users, compiled as a string including default formatting, for example bold titles. You can use this method in temp...
[ "def", "get_caption_formatted", "(", "self", ",", "field_formats", "=", "app_settings", ".", "MEDIA_TREE_METADATA_FORMATS", ",", "escape", "=", "True", ")", ":", "if", "self", ".", "override_caption", "!=", "''", ":", "return", "self", ".", "override_caption", "...
Returns object metadata that has been selected to be displayed to users, compiled as a string including default formatting, for example bold titles. You can use this method in templates where you want to output image captions.
[ "Returns", "object", "metadata", "that", "has", "been", "selected", "to", "be", "displayed", "to", "users", "compiled", "as", "a", "string", "including", "default", "formatting", "for", "example", "bold", "titles", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L693-L704
samluescher/django-media-tree
media_tree/models.py
FileNode.alt
def alt(self): """Returns object metadata suitable for use as the HTML ``alt`` attribute. You can use this method in templates:: <img src="{{ node.file.url }}" alt="{{ node.alt }}" /> """ if self.override_alt != '' and self.override_alt is not None: return self....
python
def alt(self): """Returns object metadata suitable for use as the HTML ``alt`` attribute. You can use this method in templates:: <img src="{{ node.file.url }}" alt="{{ node.alt }}" /> """ if self.override_alt != '' and self.override_alt is not None: return self....
[ "def", "alt", "(", "self", ")", ":", "if", "self", ".", "override_alt", "!=", "''", "and", "self", ".", "override_alt", "is", "not", "None", ":", "return", "self", ".", "override_alt", "elif", "self", ".", "override_caption", "!=", "''", "and", "self", ...
Returns object metadata suitable for use as the HTML ``alt`` attribute. You can use this method in templates:: <img src="{{ node.file.url }}" alt="{{ node.alt }}" />
[ "Returns", "object", "metadata", "suitable", "for", "use", "as", "the", "HTML", "alt", "attribute", ".", "You", "can", "use", "this", "method", "in", "templates", "::" ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/models.py#L718-L730
samluescher/django-media-tree
media_tree/admin/actions/forms.py
MoveSelectedForm.save
def save(self): """ Attempts to move the nodes using the selected target and position. If an invalid move is attempted, the related error message will be added to the form's non-field errors and the error will be re-raised. Callers should attempt to catch ``InvalidMove``...
python
def save(self): """ Attempts to move the nodes using the selected target and position. If an invalid move is attempted, the related error message will be added to the form's non-field errors and the error will be re-raised. Callers should attempt to catch ``InvalidMove``...
[ "def", "save", "(", "self", ")", ":", "self", ".", "success_count", "=", "0", "for", "node", "in", "self", ".", "get_selected_nodes", "(", ")", ":", "self", ".", "move_node", "(", "node", ",", "self", ".", "cleaned_data", "[", "'target_node'", "]", ")"...
Attempts to move the nodes using the selected target and position. If an invalid move is attempted, the related error message will be added to the form's non-field errors and the error will be re-raised. Callers should attempt to catch ``InvalidMove`` to redisplay the form with ...
[ "Attempts", "to", "move", "the", "nodes", "using", "the", "selected", "target", "and", "position", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/admin/actions/forms.py#L86-L98
samluescher/django-media-tree
media_tree/admin/actions/forms.py
DeleteStorageFilesForm.save
def save(self): """ Deletes the selected files from storage """ storage = get_media_storage() for storage_name in self.cleaned_data['selected_files']: full_path = storage.path(storage_name) try: storage.delete(storage_name) ...
python
def save(self): """ Deletes the selected files from storage """ storage = get_media_storage() for storage_name in self.cleaned_data['selected_files']: full_path = storage.path(storage_name) try: storage.delete(storage_name) ...
[ "def", "save", "(", "self", ")", ":", "storage", "=", "get_media_storage", "(", ")", "for", "storage_name", "in", "self", ".", "cleaned_data", "[", "'selected_files'", "]", ":", "full_path", "=", "storage", ".", "path", "(", "storage_name", ")", "try", ":"...
Deletes the selected files from storage
[ "Deletes", "the", "selected", "files", "from", "storage" ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/admin/actions/forms.py#L204-L215
samluescher/django-media-tree
media_tree/utils/filenode.py
get_merged_filenode_list
def get_merged_filenode_list(nodes, filter_media_types=None, exclude_media_types=None, filter=None, ordering=None, processors=None, max_depth=None, max_nodes=None): """ Almost the same as :func:`get_nested_filenode_list`, but returns a flat (one-dimensional) list. Using the same QuerySet as in the example f...
python
def get_merged_filenode_list(nodes, filter_media_types=None, exclude_media_types=None, filter=None, ordering=None, processors=None, max_depth=None, max_nodes=None): """ Almost the same as :func:`get_nested_filenode_list`, but returns a flat (one-dimensional) list. Using the same QuerySet as in the example f...
[ "def", "get_merged_filenode_list", "(", "nodes", ",", "filter_media_types", "=", "None", ",", "exclude_media_types", "=", "None", ",", "filter", "=", "None", ",", "ordering", "=", "None", ",", "processors", "=", "None", ",", "max_depth", "=", "None", ",", "m...
Almost the same as :func:`get_nested_filenode_list`, but returns a flat (one-dimensional) list. Using the same QuerySet as in the example for `get_nested_filenode_list`, this method would return:: [ <FileNode: Empty folder>, <FileNode: Photo folder>, <FileNode: photo1.jp...
[ "Almost", "the", "same", "as", ":", "func", ":", "get_nested_filenode_list", "but", "returns", "a", "flat", "(", "one", "-", "dimensional", ")", "list", ".", "Using", "the", "same", "QuerySet", "as", "in", "the", "example", "for", "get_nested_filenode_list", ...
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/filenode.py#L115-L131
samluescher/django-media-tree
media_tree/utils/filenode.py
get_file_link
def get_file_link(node, use_metadata=False, include_size=False, include_extension=False, include_icon=False, href=None, extra_class='', extra=''): """ Returns a formatted HTML link tag to the FileNode's file, optionally including some meta information about the file. """ link_text = None if use_meta...
python
def get_file_link(node, use_metadata=False, include_size=False, include_extension=False, include_icon=False, href=None, extra_class='', extra=''): """ Returns a formatted HTML link tag to the FileNode's file, optionally including some meta information about the file. """ link_text = None if use_meta...
[ "def", "get_file_link", "(", "node", ",", "use_metadata", "=", "False", ",", "include_size", "=", "False", ",", "include_extension", "=", "False", ",", "include_icon", "=", "False", ",", "href", "=", "None", ",", "extra_class", "=", "''", ",", "extra", "="...
Returns a formatted HTML link tag to the FileNode's file, optionally including some meta information about the file.
[ "Returns", "a", "formatted", "HTML", "link", "tag", "to", "the", "FileNode", "s", "file", "optionally", "including", "some", "meta", "information", "about", "the", "file", "." ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/utils/filenode.py#L134-L177
samluescher/django-media-tree
media_tree/admin/old_filenode_admin.py
FileNodeAdmin.delete_selected_tree
def delete_selected_tree(self, modeladmin, request, queryset): """ Deletes multiple instances and makes sure the MPTT fields get recalculated properly. (Because merely doing a bulk delete doesn't trigger the post_delete hooks.) """ # If the user has not yet confirmed the deletion...
python
def delete_selected_tree(self, modeladmin, request, queryset): """ Deletes multiple instances and makes sure the MPTT fields get recalculated properly. (Because merely doing a bulk delete doesn't trigger the post_delete hooks.) """ # If the user has not yet confirmed the deletion...
[ "def", "delete_selected_tree", "(", "self", ",", "modeladmin", ",", "request", ",", "queryset", ")", ":", "# If the user has not yet confirmed the deletion, call the regular delete", "# action that will present a confirmation page", "if", "not", "request", ".", "POST", ".", "...
Deletes multiple instances and makes sure the MPTT fields get recalculated properly. (Because merely doing a bulk delete doesn't trigger the post_delete hooks.)
[ "Deletes", "multiple", "instances", "and", "makes", "sure", "the", "MPTT", "fields", "get", "recalculated", "properly", ".", "(", "Because", "merely", "doing", "a", "bulk", "delete", "doesn", "t", "trigger", "the", "post_delete", "hooks", ".", ")" ]
train
https://github.com/samluescher/django-media-tree/blob/3eb6345faaf57e2fbe35ca431d4d133f950f2b5f/media_tree/admin/old_filenode_admin.py#L198-L212
resonai/ybt
yabt/target_utils.py
norm_name
def norm_name(build_module: str, target_name: str): """Return a normalized canonical target name for the `target_name` observed in build module `build_module`. A normalized canonical target name is of the form "<build module>:<name>", where <build module> is the relative normalized path from the pro...
python
def norm_name(build_module: str, target_name: str): """Return a normalized canonical target name for the `target_name` observed in build module `build_module`. A normalized canonical target name is of the form "<build module>:<name>", where <build module> is the relative normalized path from the pro...
[ "def", "norm_name", "(", "build_module", ":", "str", ",", "target_name", ":", "str", ")", ":", "if", "':'", "not", "in", "target_name", ":", "raise", "ValueError", "(", "\"Must provide fully-qualified target name (with `:') to avoid \"", "\"possible ambiguity - `{}' not v...
Return a normalized canonical target name for the `target_name` observed in build module `build_module`. A normalized canonical target name is of the form "<build module>:<name>", where <build module> is the relative normalized path from the project root to the target build module (POSIX), and <name...
[ "Return", "a", "normalized", "canonical", "target", "name", "for", "the", "target_name", "observed", "in", "build", "module", "build_module", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L75-L92
resonai/ybt
yabt/target_utils.py
expand_target_selector
def expand_target_selector(target_selector: str, conf: Config): """Return a normalized target name (where `**:*` is the normalized form of itself). Target specifier can be: - `**:*` - means to recursively build all targets under current working dir. - relative path from current working di...
python
def expand_target_selector(target_selector: str, conf: Config): """Return a normalized target name (where `**:*` is the normalized form of itself). Target specifier can be: - `**:*` - means to recursively build all targets under current working dir. - relative path from current working di...
[ "def", "expand_target_selector", "(", "target_selector", ":", "str", ",", "conf", ":", "Config", ")", ":", "if", "target_selector", "==", "'**:*'", ":", "return", "target_selector", "if", "':'", "not", "in", "target_selector", ":", "target_selector", "+=", "':*'...
Return a normalized target name (where `**:*` is the normalized form of itself). Target specifier can be: - `**:*` - means to recursively build all targets under current working dir. - relative path from current working directory to another directory - means to build all targets defin...
[ "Return", "a", "normalized", "target", "name", "(", "where", "**", ":", "*", "is", "the", "normalized", "form", "of", "itself", ")", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L95-L121
resonai/ybt
yabt/target_utils.py
hashify_targets
def hashify_targets(targets: list, build_context) -> list: """Return sorted hashes of `targets`.""" return sorted(build_context.targets[target_name].hash(build_context) for target_name in listify(targets))
python
def hashify_targets(targets: list, build_context) -> list: """Return sorted hashes of `targets`.""" return sorted(build_context.targets[target_name].hash(build_context) for target_name in listify(targets))
[ "def", "hashify_targets", "(", "targets", ":", "list", ",", "build_context", ")", "->", "list", ":", "return", "sorted", "(", "build_context", ".", "targets", "[", "target_name", "]", ".", "hash", "(", "build_context", ")", "for", "target_name", "in", "listi...
Return sorted hashes of `targets`.
[ "Return", "sorted", "hashes", "of", "targets", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L129-L132
resonai/ybt
yabt/target_utils.py
hashify_files
def hashify_files(files: list) -> dict: """Return mapping from file path to file hash.""" return {filepath.replace('\\', '/'): hash_tree(filepath) for filepath in listify(files)}
python
def hashify_files(files: list) -> dict: """Return mapping from file path to file hash.""" return {filepath.replace('\\', '/'): hash_tree(filepath) for filepath in listify(files)}
[ "def", "hashify_files", "(", "files", ":", "list", ")", "->", "dict", ":", "return", "{", "filepath", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ":", "hash_tree", "(", "filepath", ")", "for", "filepath", "in", "listify", "(", "files", ")", "}" ]
Return mapping from file path to file hash.
[ "Return", "mapping", "from", "file", "path", "to", "file", "hash", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L135-L138
resonai/ybt
yabt/target_utils.py
process_prop
def process_prop(prop_type: PT, value, build_context): """Return a cachable representation of the prop `value` given its type.""" if prop_type in (PT.Target, PT.TargetList): return hashify_targets(value, build_context) elif prop_type in (PT.File, PT.FileList): return hashify_files(value) ...
python
def process_prop(prop_type: PT, value, build_context): """Return a cachable representation of the prop `value` given its type.""" if prop_type in (PT.Target, PT.TargetList): return hashify_targets(value, build_context) elif prop_type in (PT.File, PT.FileList): return hashify_files(value) ...
[ "def", "process_prop", "(", "prop_type", ":", "PT", ",", "value", ",", "build_context", ")", ":", "if", "prop_type", "in", "(", "PT", ".", "Target", ",", "PT", ".", "TargetList", ")", ":", "return", "hashify_targets", "(", "value", ",", "build_context", ...
Return a cachable representation of the prop `value` given its type.
[ "Return", "a", "cachable", "representation", "of", "the", "prop", "value", "given", "its", "type", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L141-L147
resonai/ybt
yabt/target_utils.py
Target.compute_json
def compute_json(self, build_context): """Compute and store a JSON serialization of this target for caching purposes. The serialization includes: - The build flavor - The builder name - Target tags - Hashes of target dependencies & buildenv - Processed...
python
def compute_json(self, build_context): """Compute and store a JSON serialization of this target for caching purposes. The serialization includes: - The build flavor - The builder name - Target tags - Hashes of target dependencies & buildenv - Processed...
[ "def", "compute_json", "(", "self", ",", "build_context", ")", ":", "props", "=", "{", "}", "test_props", "=", "{", "}", "for", "prop", "in", "self", ".", "props", ":", "if", "prop", "in", "self", ".", "_prop_json_blacklist", ":", "continue", "sig_spec",...
Compute and store a JSON serialization of this target for caching purposes. The serialization includes: - The build flavor - The builder name - Target tags - Hashes of target dependencies & buildenv - Processed props (where target props are replaced with their...
[ "Compute", "and", "store", "a", "JSON", "serialization", "of", "this", "target", "for", "caching", "purposes", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L191-L245
resonai/ybt
yabt/target_utils.py
Target.json
def json(self, build_context) -> str: """Return JSON serialization of this target for caching purposes.""" if self._json is None: self.compute_json(build_context) return self._json
python
def json(self, build_context) -> str: """Return JSON serialization of this target for caching purposes.""" if self._json is None: self.compute_json(build_context) return self._json
[ "def", "json", "(", "self", ",", "build_context", ")", "->", "str", ":", "if", "self", ".", "_json", "is", "None", ":", "self", ".", "compute_json", "(", "build_context", ")", "return", "self", ".", "_json" ]
Return JSON serialization of this target for caching purposes.
[ "Return", "JSON", "serialization", "of", "this", "target", "for", "caching", "purposes", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L247-L251
resonai/ybt
yabt/target_utils.py
Target.compute_hash
def compute_hash(self, build_context): """Compute and store the hash of this target for caching purposes. The hash is computed over the target JSON representation. """ m = md5() m.update(self.json(build_context).encode('utf8')) self._hash = m.hexdigest() m = md5(...
python
def compute_hash(self, build_context): """Compute and store the hash of this target for caching purposes. The hash is computed over the target JSON representation. """ m = md5() m.update(self.json(build_context).encode('utf8')) self._hash = m.hexdigest() m = md5(...
[ "def", "compute_hash", "(", "self", ",", "build_context", ")", ":", "m", "=", "md5", "(", ")", "m", ".", "update", "(", "self", ".", "json", "(", "build_context", ")", ".", "encode", "(", "'utf8'", ")", ")", "self", ".", "_hash", "=", "m", ".", "...
Compute and store the hash of this target for caching purposes. The hash is computed over the target JSON representation.
[ "Compute", "and", "store", "the", "hash", "of", "this", "target", "for", "caching", "purposes", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L260-L270
resonai/ybt
yabt/target_utils.py
Target.hash
def hash(self, build_context) -> str: """Return the hash of this target for caching purposes.""" if self._hash is None: self.compute_hash(build_context) return self._hash
python
def hash(self, build_context) -> str: """Return the hash of this target for caching purposes.""" if self._hash is None: self.compute_hash(build_context) return self._hash
[ "def", "hash", "(", "self", ",", "build_context", ")", "->", "str", ":", "if", "self", ".", "_hash", "is", "None", ":", "self", ".", "compute_hash", "(", "build_context", ")", "return", "self", ".", "_hash" ]
Return the hash of this target for caching purposes.
[ "Return", "the", "hash", "of", "this", "target", "for", "caching", "purposes", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/target_utils.py#L272-L276
resonai/ybt
yabt/docker.py
handle_build_cache
def handle_build_cache( conf: Config, name: str, tag: str, icb: ImageCachingBehavior): """Handle Docker image build cache. Return image ID if image is cached, and there's no need to redo the build. Return None if need to build the image (whether cached locally or not). Raise RuntimeError if not...
python
def handle_build_cache( conf: Config, name: str, tag: str, icb: ImageCachingBehavior): """Handle Docker image build cache. Return image ID if image is cached, and there's no need to redo the build. Return None if need to build the image (whether cached locally or not). Raise RuntimeError if not...
[ "def", "handle_build_cache", "(", "conf", ":", "Config", ",", "name", ":", "str", ",", "tag", ":", "str", ",", "icb", ":", "ImageCachingBehavior", ")", ":", "if", "icb", ".", "pull_if_cached", "or", "(", "icb", ".", "pull_if_not_cached", "and", "get_cached...
Handle Docker image build cache. Return image ID if image is cached, and there's no need to redo the build. Return None if need to build the image (whether cached locally or not). Raise RuntimeError if not allowed to build the image because of state of local cache. TODO(itamar): figure out a bette...
[ "Handle", "Docker", "image", "build", "cache", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/docker.py#L152-L181
resonai/ybt
yabt/docker.py
build_docker_image
def build_docker_image( build_context, name: str, tag: str, base_image, deps: list=None, env: dict=None, work_dir: str=None, entrypoint: list=None, cmd: list=None, full_path_cmd: bool=False, distro: dict=None, image_caching_behavior: dict=None, runtime_params: dict=None, ybt_bin_...
python
def build_docker_image( build_context, name: str, tag: str, base_image, deps: list=None, env: dict=None, work_dir: str=None, entrypoint: list=None, cmd: list=None, full_path_cmd: bool=False, distro: dict=None, image_caching_behavior: dict=None, runtime_params: dict=None, ybt_bin_...
[ "def", "build_docker_image", "(", "build_context", ",", "name", ":", "str", ",", "tag", ":", "str", ",", "base_image", ",", "deps", ":", "list", "=", "None", ",", "env", ":", "dict", "=", "None", ",", "work_dir", ":", "str", "=", "None", ",", "entryp...
Build Docker image, and return a (image_id, image_name:tag) tuple of built image, if built successfully. Notes: Using the given image name & tag as they are, but using the global host Docker image namespace (as opposed to a private-project-workspace), so collisions between projects are possible ...
[ "Build", "Docker", "image", "and", "return", "a", "(", "image_id", "image_name", ":", "tag", ")", "tuple", "of", "built", "image", "if", "built", "successfully", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/docker.py#L184-L611
resonai/ybt
yabt/logging.py
add_stream_handler
def add_stream_handler(logger, stream): """Add a brace-handler stream-handler using `stream` to `logger`.""" handler = logging.StreamHandler(stream=stream) # Using Brace Formatter (see # https://docs.python.org/3.5/howto/logging-cookbook.html#use-of-alternative-formatting-styles) formatter = logging...
python
def add_stream_handler(logger, stream): """Add a brace-handler stream-handler using `stream` to `logger`.""" handler = logging.StreamHandler(stream=stream) # Using Brace Formatter (see # https://docs.python.org/3.5/howto/logging-cookbook.html#use-of-alternative-formatting-styles) formatter = logging...
[ "def", "add_stream_handler", "(", "logger", ",", "stream", ")", ":", "handler", "=", "logging", ".", "StreamHandler", "(", "stream", "=", "stream", ")", "# Using Brace Formatter (see", "# https://docs.python.org/3.5/howto/logging-cookbook.html#use-of-alternative-formatting-styl...
Add a brace-handler stream-handler using `stream` to `logger`.
[ "Add", "a", "brace", "-", "handler", "stream", "-", "handler", "using", "stream", "to", "logger", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/logging.py#L60-L68
resonai/ybt
yabt/logging.py
configure_logging
def configure_logging(conf): """Initialize and configure logging.""" root_logger = logging.getLogger() root_logger.setLevel(getattr(logging, conf.loglevel.upper())) if conf.logtostderr: add_stream_handler(root_logger, sys.stderr) if conf.logtostdout: add_stream_handler(root_logger, s...
python
def configure_logging(conf): """Initialize and configure logging.""" root_logger = logging.getLogger() root_logger.setLevel(getattr(logging, conf.loglevel.upper())) if conf.logtostderr: add_stream_handler(root_logger, sys.stderr) if conf.logtostdout: add_stream_handler(root_logger, s...
[ "def", "configure_logging", "(", "conf", ")", ":", "root_logger", "=", "logging", ".", "getLogger", "(", ")", "root_logger", ".", "setLevel", "(", "getattr", "(", "logging", ",", "conf", ".", "loglevel", ".", "upper", "(", ")", ")", ")", "if", "conf", ...
Initialize and configure logging.
[ "Initialize", "and", "configure", "logging", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/logging.py#L71-L78
resonai/ybt
yabt/glob.py
iglob
def iglob(pathname, *, recursive=False): """Return an iterator which yields the paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns...
python
def iglob(pathname, *, recursive=False): """Return an iterator which yields the paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns...
[ "def", "iglob", "(", "pathname", ",", "*", ",", "recursive", "=", "False", ")", ":", "it", "=", "_iglob", "(", "pathname", ",", "recursive", ")", "if", "recursive", "and", "_isrecursive", "(", "pathname", ")", ":", "s", "=", "next", "(", "it", ")", ...
Return an iterator which yields the paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns. If recursive is true, the pattern '**' wi...
[ "Return", "an", "iterator", "which", "yields", "the", "paths", "matching", "a", "pathname", "pattern", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/glob.py#L46-L61
resonai/ybt
yabt/extend.py
Builder.register_sig
def register_sig(self, builder_name: str, sig: list, docstring: str, cachable: bool=True, attempts=1): """Register a builder signature & docstring for `builder_name`. The input for the builder signature is a list of "sig-spec"s representing the builder function arguments. ...
python
def register_sig(self, builder_name: str, sig: list, docstring: str, cachable: bool=True, attempts=1): """Register a builder signature & docstring for `builder_name`. The input for the builder signature is a list of "sig-spec"s representing the builder function arguments. ...
[ "def", "register_sig", "(", "self", ",", "builder_name", ":", "str", ",", "sig", ":", "list", ",", "docstring", ":", "str", ",", "cachable", ":", "bool", "=", "True", ",", "attempts", "=", "1", ")", ":", "if", "self", ".", "sig", "is", "not", "None...
Register a builder signature & docstring for `builder_name`. The input for the builder signature is a list of "sig-spec"s representing the builder function arguments. Each sig-spec in the list can be: 1. A string. This represents a simple untyped positional argument name, w...
[ "Register", "a", "builder", "signature", "&", "docstring", "for", "builder_name", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/extend.py#L97-L162
resonai/ybt
yabt/extend.py
Plugin.remove_builder
def remove_builder(cls, builder_name: str): """Remove a registered builder `builder_name`. No reason to use this except for tests. """ cls.builders.pop(builder_name, None) for hook_spec in cls.hooks.values(): hook_spec.pop(builder_name, None)
python
def remove_builder(cls, builder_name: str): """Remove a registered builder `builder_name`. No reason to use this except for tests. """ cls.builders.pop(builder_name, None) for hook_spec in cls.hooks.values(): hook_spec.pop(builder_name, None)
[ "def", "remove_builder", "(", "cls", ",", "builder_name", ":", "str", ")", ":", "cls", ".", "builders", ".", "pop", "(", "builder_name", ",", "None", ")", "for", "hook_spec", "in", "cls", ".", "hooks", ".", "values", "(", ")", ":", "hook_spec", ".", ...
Remove a registered builder `builder_name`. No reason to use this except for tests.
[ "Remove", "a", "registered", "builder", "builder_name", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/extend.py#L198-L205
resonai/ybt
yabt/buildfile_utils.py
to_build_module
def to_build_module(build_file_path: str, conf: Config) -> str: """Return a normalized build module name for `build_file_path`.""" build_file = Path(build_file_path) root = Path(conf.project_root) return build_file.resolve().relative_to(root).parent.as_posix().strip('.')
python
def to_build_module(build_file_path: str, conf: Config) -> str: """Return a normalized build module name for `build_file_path`.""" build_file = Path(build_file_path) root = Path(conf.project_root) return build_file.resolve().relative_to(root).parent.as_posix().strip('.')
[ "def", "to_build_module", "(", "build_file_path", ":", "str", ",", "conf", ":", "Config", ")", "->", "str", ":", "build_file", "=", "Path", "(", "build_file_path", ")", "root", "=", "Path", "(", "conf", ".", "project_root", ")", "return", "build_file", "."...
Return a normalized build module name for `build_file_path`.
[ "Return", "a", "normalized", "build", "module", "name", "for", "build_file_path", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildfile_utils.py#L29-L33
resonai/ybt
yabt/yabt.py
cmd_version
def cmd_version(unused_conf): """Print out version information about YABT and detected builders.""" import pkg_resources print('This is {} version {}, imported from {}' .format(__oneliner__, __version__, __file__)) if len(Plugin.builders) > 0: print('setuptools registered builders:') ...
python
def cmd_version(unused_conf): """Print out version information about YABT and detected builders.""" import pkg_resources print('This is {} version {}, imported from {}' .format(__oneliner__, __version__, __file__)) if len(Plugin.builders) > 0: print('setuptools registered builders:') ...
[ "def", "cmd_version", "(", "unused_conf", ")", ":", "import", "pkg_resources", "print", "(", "'This is {} version {}, imported from {}'", ".", "format", "(", "__oneliner__", ",", "__version__", ",", "__file__", ")", ")", "if", "len", "(", "Plugin", ".", "builders"...
Print out version information about YABT and detected builders.
[ "Print", "out", "version", "information", "about", "YABT", "and", "detected", "builders", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/yabt.py#L44-L52
resonai/ybt
yabt/yabt.py
cmd_list
def cmd_list(unused_conf: Config): """Print out information on loaded builders and hooks.""" for name, builder in sorted(Plugin.builders.items()): if builder.func: print('+- {0:16s} implemented in {1.__module__}.{1.__name__}()' .format(name, builder.func)) else: ...
python
def cmd_list(unused_conf: Config): """Print out information on loaded builders and hooks.""" for name, builder in sorted(Plugin.builders.items()): if builder.func: print('+- {0:16s} implemented in {1.__module__}.{1.__name__}()' .format(name, builder.func)) else: ...
[ "def", "cmd_list", "(", "unused_conf", ":", "Config", ")", ":", "for", "name", ",", "builder", "in", "sorted", "(", "Plugin", ".", "builders", ".", "items", "(", ")", ")", ":", "if", "builder", ".", "func", ":", "print", "(", "'+- {0:16s} implemented in ...
Print out information on loaded builders and hooks.
[ "Print", "out", "information", "on", "loaded", "builders", "and", "hooks", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/yabt.py#L60-L71
resonai/ybt
yabt/yabt.py
cmd_build
def cmd_build(conf: Config, run_tests: bool=False): """Build requested targets, and their dependencies.""" build_context = BuildContext(conf) populate_targets_graph(build_context, conf) build_context.build_graph(run_tests=run_tests) build_context.write_artifacts_metadata()
python
def cmd_build(conf: Config, run_tests: bool=False): """Build requested targets, and their dependencies.""" build_context = BuildContext(conf) populate_targets_graph(build_context, conf) build_context.build_graph(run_tests=run_tests) build_context.write_artifacts_metadata()
[ "def", "cmd_build", "(", "conf", ":", "Config", ",", "run_tests", ":", "bool", "=", "False", ")", ":", "build_context", "=", "BuildContext", "(", "conf", ")", "populate_targets_graph", "(", "build_context", ",", "conf", ")", "build_context", ".", "build_graph"...
Build requested targets, and their dependencies.
[ "Build", "requested", "targets", "and", "their", "dependencies", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/yabt.py#L74-L79
resonai/ybt
yabt/yabt.py
cmd_dot
def cmd_dot(conf: Config): """Print out a neat targets dependency tree based on requested targets. Use graphviz to render the dot file, e.g.: > ybt dot :foo :bar | dot -Tpng -o graph.png """ build_context = BuildContext(conf) populate_targets_graph(build_context, conf) if conf.output_dot_f...
python
def cmd_dot(conf: Config): """Print out a neat targets dependency tree based on requested targets. Use graphviz to render the dot file, e.g.: > ybt dot :foo :bar | dot -Tpng -o graph.png """ build_context = BuildContext(conf) populate_targets_graph(build_context, conf) if conf.output_dot_f...
[ "def", "cmd_dot", "(", "conf", ":", "Config", ")", ":", "build_context", "=", "BuildContext", "(", "conf", ")", "populate_targets_graph", "(", "build_context", ",", "conf", ")", "if", "conf", ".", "output_dot_file", "is", "None", ":", "write_dot", "(", "buil...
Print out a neat targets dependency tree based on requested targets. Use graphviz to render the dot file, e.g.: > ybt dot :foo :bar | dot -Tpng -o graph.png
[ "Print", "out", "a", "neat", "targets", "dependency", "tree", "based", "on", "requested", "targets", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/yabt.py#L88-L101
resonai/ybt
yabt/yabt.py
cmd_tree
def cmd_tree(conf: Config): """Print out a neat targets dependency tree based on requested targets.""" build_context = BuildContext(conf) populate_targets_graph(build_context, conf) def print_target_with_deps(target, depth=2): print('{: >{}}{}'.format('+-', depth, target.name)) for dep ...
python
def cmd_tree(conf: Config): """Print out a neat targets dependency tree based on requested targets.""" build_context = BuildContext(conf) populate_targets_graph(build_context, conf) def print_target_with_deps(target, depth=2): print('{: >{}}{}'.format('+-', depth, target.name)) for dep ...
[ "def", "cmd_tree", "(", "conf", ":", "Config", ")", ":", "build_context", "=", "BuildContext", "(", "conf", ")", "populate_targets_graph", "(", "build_context", ",", "conf", ")", "def", "print_target_with_deps", "(", "target", ",", "depth", "=", "2", ")", ":...
Print out a neat targets dependency tree based on requested targets.
[ "Print", "out", "a", "neat", "targets", "dependency", "tree", "based", "on", "requested", "targets", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/yabt.py#L104-L126
resonai/ybt
yabt/yabt.py
main
def main(): """Main `ybt` console script entry point - run YABT from command-line.""" conf = init_and_get_conf() logger = make_logger(__name__) logger.info('YaBT version {}', __version__) handlers = { 'build': YabtCommand(func=cmd_build, requires_project=True), 'dot': YabtCommand(fun...
python
def main(): """Main `ybt` console script entry point - run YABT from command-line.""" conf = init_and_get_conf() logger = make_logger(__name__) logger.info('YaBT version {}', __version__) handlers = { 'build': YabtCommand(func=cmd_build, requires_project=True), 'dot': YabtCommand(fun...
[ "def", "main", "(", ")", ":", "conf", "=", "init_and_get_conf", "(", ")", "logger", "=", "make_logger", "(", "__name__", ")", "logger", ".", "info", "(", "'YaBT version {}'", ",", "__version__", ")", "handlers", "=", "{", "'build'", ":", "YabtCommand", "("...
Main `ybt` console script entry point - run YABT from command-line.
[ "Main", "ybt", "console", "script", "entry", "point", "-", "run", "YABT", "from", "command", "-", "line", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/yabt.py#L129-L149
resonai/ybt
yabt/builders/cpp.py
cpp_app_builder
def cpp_app_builder(build_context, target): """Pack a C++ binary as a Docker image with its runtime dependencies. TODO(itamar): Dynamically analyze the binary and copy shared objects from its buildenv image to the runtime image, unless they're installed. """ yprint(build_context.conf, 'Build CppApp...
python
def cpp_app_builder(build_context, target): """Pack a C++ binary as a Docker image with its runtime dependencies. TODO(itamar): Dynamically analyze the binary and copy shared objects from its buildenv image to the runtime image, unless they're installed. """ yprint(build_context.conf, 'Build CppApp...
[ "def", "cpp_app_builder", "(", "build_context", ",", "target", ")", ":", "yprint", "(", "build_context", ".", "conf", ",", "'Build CppApp'", ",", "target", ")", "if", "target", ".", "props", ".", "executable", "and", "target", ".", "props", ".", "main", ":...
Pack a C++ binary as a Docker image with its runtime dependencies. TODO(itamar): Dynamically analyze the binary and copy shared objects from its buildenv image to the runtime image, unless they're installed.
[ "Pack", "a", "C", "++", "binary", "as", "a", "Docker", "image", "with", "its", "runtime", "dependencies", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L163-L184
resonai/ybt
yabt/builders/cpp.py
make_pre_build_hook
def make_pre_build_hook(extra_compiler_config_params): """Return a pre-build hook function for C++ builders. When called, during graph build, it computes and stores the compiler-config object on the target, as well as adding it to the internal_dict prop for hashing purposes. """ def pre_build_...
python
def make_pre_build_hook(extra_compiler_config_params): """Return a pre-build hook function for C++ builders. When called, during graph build, it computes and stores the compiler-config object on the target, as well as adding it to the internal_dict prop for hashing purposes. """ def pre_build_...
[ "def", "make_pre_build_hook", "(", "extra_compiler_config_params", ")", ":", "def", "pre_build_hook", "(", "build_context", ",", "target", ")", ":", "target", ".", "compiler_config", "=", "CompilerConfig", "(", "build_context", ",", "target", ",", "extra_compiler_conf...
Return a pre-build hook function for C++ builders. When called, during graph build, it computes and stores the compiler-config object on the target, as well as adding it to the internal_dict prop for hashing purposes.
[ "Return", "a", "pre", "-", "build", "hook", "function", "for", "C", "++", "builders", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L200-L214
resonai/ybt
yabt/builders/cpp.py
compile_cc
def compile_cc(build_context, compiler_config, buildenv, sources, workspace_dir, buildenv_workspace, cmd_env): """Compile list of C++ source files in a buildenv image and return list of generated object file. """ objects = [] for src in sources: obj_rel_path = '{}.o'.format...
python
def compile_cc(build_context, compiler_config, buildenv, sources, workspace_dir, buildenv_workspace, cmd_env): """Compile list of C++ source files in a buildenv image and return list of generated object file. """ objects = [] for src in sources: obj_rel_path = '{}.o'.format...
[ "def", "compile_cc", "(", "build_context", ",", "compiler_config", ",", "buildenv", ",", "sources", ",", "workspace_dir", ",", "buildenv_workspace", ",", "cmd_env", ")", ":", "objects", "=", "[", "]", "for", "src", "in", "sources", ":", "obj_rel_path", "=", ...
Compile list of C++ source files in a buildenv image and return list of generated object file.
[ "Compile", "list", "of", "C", "++", "source", "files", "in", "a", "buildenv", "image", "and", "return", "list", "of", "generated", "object", "file", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L244-L265
resonai/ybt
yabt/builders/cpp.py
link_cpp_artifacts
def link_cpp_artifacts(build_context, target, workspace_dir, include_objects: bool): """Link required artifacts from dependencies under target workspace dir. Return list of object files of dependencies (if `include_objects`). Includes: - Generated code from proto dependencies ...
python
def link_cpp_artifacts(build_context, target, workspace_dir, include_objects: bool): """Link required artifacts from dependencies under target workspace dir. Return list of object files of dependencies (if `include_objects`). Includes: - Generated code from proto dependencies ...
[ "def", "link_cpp_artifacts", "(", "build_context", ",", "target", ",", "workspace_dir", ",", "include_objects", ":", "bool", ")", ":", "# include the source & header files of the current target", "# add objects of all dependencies (direct & transitive), if needed", "source_files", ...
Link required artifacts from dependencies under target workspace dir. Return list of object files of dependencies (if `include_objects`). Includes: - Generated code from proto dependencies - Header files from all dependencies - Generated header files from all dependencies - If `include_objec...
[ "Link", "required", "artifacts", "from", "dependencies", "under", "target", "workspace", "dir", ".", "Return", "list", "of", "object", "files", "of", "dependencies", "(", "if", "include_objects", ")", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L268-L304
resonai/ybt
yabt/builders/cpp.py
get_source_files
def get_source_files(target, build_context) -> list: """Return list of source files for `target`.""" all_sources = list(target.props.sources) for proto_dep_name in target.props.protos: proto_dep = build_context.targets[proto_dep_name] all_sources.extend(proto_dep.artifacts.get(AT.gen_cc).key...
python
def get_source_files(target, build_context) -> list: """Return list of source files for `target`.""" all_sources = list(target.props.sources) for proto_dep_name in target.props.protos: proto_dep = build_context.targets[proto_dep_name] all_sources.extend(proto_dep.artifacts.get(AT.gen_cc).key...
[ "def", "get_source_files", "(", "target", ",", "build_context", ")", "->", "list", ":", "all_sources", "=", "list", "(", "target", ".", "props", ".", "sources", ")", "for", "proto_dep_name", "in", "target", ".", "props", ".", "protos", ":", "proto_dep", "=...
Return list of source files for `target`.
[ "Return", "list", "of", "source", "files", "for", "target", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L307-L313
resonai/ybt
yabt/builders/cpp.py
build_cpp
def build_cpp(build_context, target, compiler_config, workspace_dir): """Compile and link a C++ binary for `target`.""" rmtree(workspace_dir) binary = join(*split(target.name)) objects = link_cpp_artifacts(build_context, target, workspace_dir, True) buildenv_workspace = build_context.conf.host_to_bu...
python
def build_cpp(build_context, target, compiler_config, workspace_dir): """Compile and link a C++ binary for `target`.""" rmtree(workspace_dir) binary = join(*split(target.name)) objects = link_cpp_artifacts(build_context, target, workspace_dir, True) buildenv_workspace = build_context.conf.host_to_bu...
[ "def", "build_cpp", "(", "build_context", ",", "target", ",", "compiler_config", ",", "workspace_dir", ")", ":", "rmtree", "(", "workspace_dir", ")", "binary", "=", "join", "(", "*", "split", "(", "target", ".", "name", ")", ")", "objects", "=", "link_cpp_...
Compile and link a C++ binary for `target`.
[ "Compile", "and", "link", "a", "C", "++", "binary", "for", "target", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L316-L334
resonai/ybt
yabt/builders/cpp.py
cpp_prog_builder
def cpp_prog_builder(build_context, target): """Build a C++ binary executable""" yprint(build_context.conf, 'Build CppProg', target) workspace_dir = build_context.get_workspace('CppProg', target.name) build_cpp(build_context, target, target.compiler_config, workspace_dir)
python
def cpp_prog_builder(build_context, target): """Build a C++ binary executable""" yprint(build_context.conf, 'Build CppProg', target) workspace_dir = build_context.get_workspace('CppProg', target.name) build_cpp(build_context, target, target.compiler_config, workspace_dir)
[ "def", "cpp_prog_builder", "(", "build_context", ",", "target", ")", ":", "yprint", "(", "build_context", ".", "conf", ",", "'Build CppProg'", ",", "target", ")", "workspace_dir", "=", "build_context", ".", "get_workspace", "(", "'CppProg'", ",", "target", ".", ...
Build a C++ binary executable
[ "Build", "a", "C", "++", "binary", "executable" ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L338-L342
resonai/ybt
yabt/builders/cpp.py
cpp_lib_builder
def cpp_lib_builder(build_context, target): """Build C++ object files""" yprint(build_context.conf, 'Build CppLib', target) workspace_dir = build_context.get_workspace('CppLib', target.name) workspace_src_dir = join(workspace_dir, 'src') rmtree(workspace_src_dir) link_cpp_artifacts(build_context...
python
def cpp_lib_builder(build_context, target): """Build C++ object files""" yprint(build_context.conf, 'Build CppLib', target) workspace_dir = build_context.get_workspace('CppLib', target.name) workspace_src_dir = join(workspace_dir, 'src') rmtree(workspace_src_dir) link_cpp_artifacts(build_context...
[ "def", "cpp_lib_builder", "(", "build_context", ",", "target", ")", ":", "yprint", "(", "build_context", ".", "conf", ",", "'Build CppLib'", ",", "target", ")", "workspace_dir", "=", "build_context", ".", "get_workspace", "(", "'CppLib'", ",", "target", ".", "...
Build C++ object files
[ "Build", "C", "++", "object", "files" ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L389-L403
resonai/ybt
yabt/builders/cpp.py
CompilerConfig.get
def get(self, param, config, target, fallback): """Return the value of `param`, according to priority / expansion. First priority - the target itself. Second priority - the project config. Third priority - a global default ("fallback"). In list-params, a '$*' term processed as ...
python
def get(self, param, config, target, fallback): """Return the value of `param`, according to priority / expansion. First priority - the target itself. Second priority - the project config. Third priority - a global default ("fallback"). In list-params, a '$*' term processed as ...
[ "def", "get", "(", "self", ",", "param", ",", "config", ",", "target", ",", "fallback", ")", ":", "target_val", "=", "target", ".", "props", ".", "get", "(", "param", ")", "config_val", "=", "config", ".", "get", "(", "param", ",", "fallback", ")", ...
Return the value of `param`, according to priority / expansion. First priority - the target itself. Second priority - the project config. Third priority - a global default ("fallback"). In list-params, a '$*' term processed as "expansion term", meaning it is replaced with all t...
[ "Return", "the", "value", "of", "param", "according", "to", "priority", "/", "expansion", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/builders/cpp.py#L104-L126
resonai/ybt
yabt/policy.py
standard_licenses_only
def standard_licenses_only(build_context, target) -> str: """A policy function for allowing specifying only known licenses. Return error message (string) if policy for `target` is violated, otherwise return `None`. To apply in project, include this function in the ilst returned by the `get_policie...
python
def standard_licenses_only(build_context, target) -> str: """A policy function for allowing specifying only known licenses. Return error message (string) if policy for `target` is violated, otherwise return `None`. To apply in project, include this function in the ilst returned by the `get_policie...
[ "def", "standard_licenses_only", "(", "build_context", ",", "target", ")", "->", "str", ":", "for", "license_name", "in", "target", ".", "props", ".", "license", ":", "if", "license_name", "not", "in", "KNOWN_LICENSES", ":", "# TODO: include suggestion for similar k...
A policy function for allowing specifying only known licenses. Return error message (string) if policy for `target` is violated, otherwise return `None`. To apply in project, include this function in the ilst returned by the `get_policies` function implemented in the project `YSettings` file. See...
[ "A", "policy", "function", "for", "allowing", "specifying", "only", "known", "licenses", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/policy.py#L131-L146
resonai/ybt
yabt/policy.py
whitelist_licenses_policy
def whitelist_licenses_policy(policy_name: str, allowed_licenses: set): """A policy factory for making license-based whitelist policies. To apply in project, include the function returned from this factory in the ilst returned by the `get_policies` function implemented in the project `YSettings` file. ...
python
def whitelist_licenses_policy(policy_name: str, allowed_licenses: set): """A policy factory for making license-based whitelist policies. To apply in project, include the function returned from this factory in the ilst returned by the `get_policies` function implemented in the project `YSettings` file. ...
[ "def", "whitelist_licenses_policy", "(", "policy_name", ":", "str", ",", "allowed_licenses", ":", "set", ")", ":", "def", "policy_func", "(", "build_context", ",", "target", ")", ":", "\"\"\"whitelist_{policy_name}_licenses policy function.\n\n Return error message (st...
A policy factory for making license-based whitelist policies. To apply in project, include the function returned from this factory in the ilst returned by the `get_policies` function implemented in the project `YSettings` file. The factory returns a policy function named `whitelist_{policy_name}_l...
[ "A", "policy", "factory", "for", "making", "license", "-", "based", "whitelist", "policies", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/policy.py#L149-L183
resonai/ybt
yabt/cli.py
make_parser
def make_parser(project_config_file: str) -> configargparse.ArgumentParser: """Return the argument parser. :param project_config_file: Absolute path to project-specific config file. If cached parser already exists - return it immediately. Otherwise, initialize a new `ConfigArgParser` that is able to t...
python
def make_parser(project_config_file: str) -> configargparse.ArgumentParser: """Return the argument parser. :param project_config_file: Absolute path to project-specific config file. If cached parser already exists - return it immediately. Otherwise, initialize a new `ConfigArgParser` that is able to t...
[ "def", "make_parser", "(", "project_config_file", ":", "str", ")", "->", "configargparse", ".", "ArgumentParser", ":", "global", "PARSER", "# pylint: disable=global-statement", "if", "PARSER", "is", "None", ":", "config_files", "=", "[", "'/etc/yabt.conf'", ",", "'~...
Return the argument parser. :param project_config_file: Absolute path to project-specific config file. If cached parser already exists - return it immediately. Otherwise, initialize a new `ConfigArgParser` that is able to take default values from a hierarchy of config files and environment variables, ...
[ "Return", "the", "argument", "parser", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/cli.py#L44-L131
resonai/ybt
yabt/cli.py
find_project_config_file
def find_project_config_file(project_root: str) -> str: """Return absolute path to project-specific config file, if it exists. :param project_root: Absolute path to project root directory. A project config file is a file named `YCONFIG_FILE` found at the top level of the project root dir. Return ...
python
def find_project_config_file(project_root: str) -> str: """Return absolute path to project-specific config file, if it exists. :param project_root: Absolute path to project root directory. A project config file is a file named `YCONFIG_FILE` found at the top level of the project root dir. Return ...
[ "def", "find_project_config_file", "(", "project_root", ":", "str", ")", "->", "str", ":", "if", "project_root", ":", "project_config_file", "=", "os", ".", "path", ".", "join", "(", "project_root", ",", "YCONFIG_FILE", ")", "if", "os", ".", "path", ".", "...
Return absolute path to project-specific config file, if it exists. :param project_root: Absolute path to project root directory. A project config file is a file named `YCONFIG_FILE` found at the top level of the project root dir. Return `None` if project root dir is not specified, or if no such ...
[ "Return", "absolute", "path", "to", "project", "-", "specific", "config", "file", "if", "it", "exists", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/cli.py#L134-L148
resonai/ybt
yabt/cli.py
get_user_settings_module
def get_user_settings_module(project_root: str): """Return project-specific user settings module, if it exists. :param project_root: Absolute path to project root directory. A project settings file is a file named `YSETTINGS_FILE` found at the top level of the project root dir. Return `None` if p...
python
def get_user_settings_module(project_root: str): """Return project-specific user settings module, if it exists. :param project_root: Absolute path to project root directory. A project settings file is a file named `YSETTINGS_FILE` found at the top level of the project root dir. Return `None` if p...
[ "def", "get_user_settings_module", "(", "project_root", ":", "str", ")", ":", "if", "project_root", ":", "project_settings_file", "=", "os", ".", "path", ".", "join", "(", "project_root", ",", "YSETTINGS_FILE", ")", "if", "os", ".", "path", ".", "isfile", "(...
Return project-specific user settings module, if it exists. :param project_root: Absolute path to project root directory. A project settings file is a file named `YSETTINGS_FILE` found at the top level of the project root dir. Return `None` if project root dir is not specified, or if no such file...
[ "Return", "project", "-", "specific", "user", "settings", "module", "if", "it", "exists", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/cli.py#L151-L182
resonai/ybt
yabt/cli.py
call_user_func
def call_user_func(settings_module, func_name, *args, **kwargs): """Call a user-supplied settings function and clean it up afterwards. settings_module may be None, or the function may not exist. If the function exists, it is called with the specified *args and **kwargs, and the result is returned. ...
python
def call_user_func(settings_module, func_name, *args, **kwargs): """Call a user-supplied settings function and clean it up afterwards. settings_module may be None, or the function may not exist. If the function exists, it is called with the specified *args and **kwargs, and the result is returned. ...
[ "def", "call_user_func", "(", "settings_module", ",", "func_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "settings_module", ":", "if", "hasattr", "(", "settings_module", ",", "func_name", ")", ":", "func", "=", "getattr", "(", "setting...
Call a user-supplied settings function and clean it up afterwards. settings_module may be None, or the function may not exist. If the function exists, it is called with the specified *args and **kwargs, and the result is returned.
[ "Call", "a", "user", "-", "supplied", "settings", "function", "and", "clean", "it", "up", "afterwards", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/cli.py#L185-L199
resonai/ybt
yabt/cli.py
get_build_flavor
def get_build_flavor(settings_module, args): """Update the flavor arg based on the settings API""" known_flavors = listify(call_user_func(settings_module, 'known_flavors')) if args.flavor: if args.flavor not in known_flavors: raise ValueError('Unknown build flavor: {}'.format(args.flavor...
python
def get_build_flavor(settings_module, args): """Update the flavor arg based on the settings API""" known_flavors = listify(call_user_func(settings_module, 'known_flavors')) if args.flavor: if args.flavor not in known_flavors: raise ValueError('Unknown build flavor: {}'.format(args.flavor...
[ "def", "get_build_flavor", "(", "settings_module", ",", "args", ")", ":", "known_flavors", "=", "listify", "(", "call_user_func", "(", "settings_module", ",", "'known_flavors'", ")", ")", "if", "args", ".", "flavor", ":", "if", "args", ".", "flavor", "not", ...
Update the flavor arg based on the settings API
[ "Update", "the", "flavor", "arg", "based", "on", "the", "settings", "API" ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/cli.py#L202-L212
resonai/ybt
yabt/cli.py
init_and_get_conf
def init_and_get_conf(argv: list=None) -> Config: """Initialize a YABT CLI environment and return a Config instance. :param argv: Manual override of command-line params to parse (for tests). """ colorama.init() work_dir = os.path.abspath(os.curdir) project_root = search_for_parent_dir(work_dir,...
python
def init_and_get_conf(argv: list=None) -> Config: """Initialize a YABT CLI environment and return a Config instance. :param argv: Manual override of command-line params to parse (for tests). """ colorama.init() work_dir = os.path.abspath(os.curdir) project_root = search_for_parent_dir(work_dir,...
[ "def", "init_and_get_conf", "(", "argv", ":", "list", "=", "None", ")", "->", "Config", ":", "colorama", ".", "init", "(", ")", "work_dir", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "curdir", ")", "project_root", "=", "search_for_parent_dir...
Initialize a YABT CLI environment and return a Config instance. :param argv: Manual override of command-line params to parse (for tests).
[ "Initialize", "a", "YABT", "CLI", "environment", "and", "return", "a", "Config", "instance", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/cli.py#L215-L239
resonai/ybt
yabt/graph.py
stable_reverse_topological_sort
def stable_reverse_topological_sort(graph): """Return a list of nodes in topological sort order. This topological sort is a **unique** permutation of the nodes such that an edge from u to v implies that u appears before v in the topological sort order. Parameters ---------- graph : Network...
python
def stable_reverse_topological_sort(graph): """Return a list of nodes in topological sort order. This topological sort is a **unique** permutation of the nodes such that an edge from u to v implies that u appears before v in the topological sort order. Parameters ---------- graph : Network...
[ "def", "stable_reverse_topological_sort", "(", "graph", ")", ":", "if", "not", "graph", ".", "is_directed", "(", ")", ":", "raise", "networkx", ".", "NetworkXError", "(", "'Topological sort not defined on undirected graphs.'", ")", "# nonrecursive version", "seen", "=",...
Return a list of nodes in topological sort order. This topological sort is a **unique** permutation of the nodes such that an edge from u to v implies that u appears before v in the topological sort order. Parameters ---------- graph : NetworkX digraph A directed graph Raises ...
[ "Return", "a", "list", "of", "nodes", "in", "topological", "sort", "order", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/graph.py#L42-L113
resonai/ybt
yabt/graph.py
raise_unresolved_targets
def raise_unresolved_targets(build_context, conf, unknown_seeds, seed_refs): """Raise error about unresolved targets during graph parsing.""" def format_target(target_name): # TODO: suggest similar known target names build_module = split_build_module(target_name) return '{} (in {})'.for...
python
def raise_unresolved_targets(build_context, conf, unknown_seeds, seed_refs): """Raise error about unresolved targets during graph parsing.""" def format_target(target_name): # TODO: suggest similar known target names build_module = split_build_module(target_name) return '{} (in {})'.for...
[ "def", "raise_unresolved_targets", "(", "build_context", ",", "conf", ",", "unknown_seeds", ",", "seed_refs", ")", ":", "def", "format_target", "(", "target_name", ")", ":", "# TODO: suggest similar known target names", "build_module", "=", "split_build_module", "(", "t...
Raise error about unresolved targets during graph parsing.
[ "Raise", "error", "about", "unresolved", "targets", "during", "graph", "parsing", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/graph.py#L170-L208
resonai/ybt
yabt/scm.py
register_scm_provider
def register_scm_provider(scm_name: str): """Return a decorator for registering a SCM provider named `scm_name`.""" def register_decorator(scm_class: SourceControl): """Decorator for registering SCM provider.""" if scm_name in ScmManager.providers: raise KeyError('{} already registe...
python
def register_scm_provider(scm_name: str): """Return a decorator for registering a SCM provider named `scm_name`.""" def register_decorator(scm_class: SourceControl): """Decorator for registering SCM provider.""" if scm_name in ScmManager.providers: raise KeyError('{} already registe...
[ "def", "register_scm_provider", "(", "scm_name", ":", "str", ")", ":", "def", "register_decorator", "(", "scm_class", ":", "SourceControl", ")", ":", "\"\"\"Decorator for registering SCM provider.\"\"\"", "if", "scm_name", "in", "ScmManager", ".", "providers", ":", "r...
Return a decorator for registering a SCM provider named `scm_name`.
[ "Return", "a", "decorator", "for", "registering", "a", "SCM", "provider", "named", "scm_name", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/scm.py#L83-L95
resonai/ybt
yabt/scm.py
ScmManager.get_provider
def get_provider(cls, scm_name: str, conf) -> SourceControl: """Load and return named SCM provider instance. :param conf: A yabt.config.Config object used to initialize the SCM provider instance. :raises KeyError: If no SCM provider with name `scm_name` registered. ...
python
def get_provider(cls, scm_name: str, conf) -> SourceControl: """Load and return named SCM provider instance. :param conf: A yabt.config.Config object used to initialize the SCM provider instance. :raises KeyError: If no SCM provider with name `scm_name` registered. ...
[ "def", "get_provider", "(", "cls", ",", "scm_name", ":", "str", ",", "conf", ")", "->", "SourceControl", ":", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "'yabt.scm'", ",", "scm_name", ")", ":", "entry_point", ".", "load", "("...
Load and return named SCM provider instance. :param conf: A yabt.config.Config object used to initialize the SCM provider instance. :raises KeyError: If no SCM provider with name `scm_name` registered.
[ "Load", "and", "return", "named", "SCM", "provider", "instance", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/scm.py#L58-L74
resonai/ybt
yabt/dot.py
write_dot
def write_dot(build_context, conf: Config, out_f): """Write build graph in dot format to `out_f` file-like object.""" not_buildenv_targets = get_not_buildenv_targets(build_context) prebuilt_targets = get_prebuilt_targets(build_context) out_f.write('strict digraph {\n') for node in build_context.tar...
python
def write_dot(build_context, conf: Config, out_f): """Write build graph in dot format to `out_f` file-like object.""" not_buildenv_targets = get_not_buildenv_targets(build_context) prebuilt_targets = get_prebuilt_targets(build_context) out_f.write('strict digraph {\n') for node in build_context.tar...
[ "def", "write_dot", "(", "build_context", ",", "conf", ":", "Config", ",", "out_f", ")", ":", "not_buildenv_targets", "=", "get_not_buildenv_targets", "(", "build_context", ")", "prebuilt_targets", "=", "get_prebuilt_targets", "(", "build_context", ")", "out_f", "."...
Write build graph in dot format to `out_f` file-like object.
[ "Write", "build", "graph", "in", "dot", "format", "to", "out_f", "file", "-", "like", "object", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/dot.py#L62-L79
resonai/ybt
yabt/buildcontext.py
BuildContext.get_workspace
def get_workspace(self, *parts) -> str: """Return a path to a private workspace dir. Create sub-tree of dirs using strings from `parts` inside workspace, and return full path to innermost directory. Upon returning successfully, the directory will exist (potentially changed...
python
def get_workspace(self, *parts) -> str: """Return a path to a private workspace dir. Create sub-tree of dirs using strings from `parts` inside workspace, and return full path to innermost directory. Upon returning successfully, the directory will exist (potentially changed...
[ "def", "get_workspace", "(", "self", ",", "*", "parts", ")", "->", "str", ":", "workspace_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "conf", ".", "get_workspace_path", "(", ")", ",", "*", "(", "get_safe_path", "(", "part", ")", "for...
Return a path to a private workspace dir. Create sub-tree of dirs using strings from `parts` inside workspace, and return full path to innermost directory. Upon returning successfully, the directory will exist (potentially changed to a safe FS name), even if it didn't exist before...
[ "Return", "a", "path", "to", "a", "private", "workspace", "dir", ".", "Create", "sub", "-", "tree", "of", "dirs", "using", "strings", "from", "parts", "inside", "workspace", "and", "return", "full", "path", "to", "innermost", "directory", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L101-L115
resonai/ybt
yabt/buildcontext.py
BuildContext.get_bin_dir
def get_bin_dir(self, build_module: str) -> str: """Return a path to the binaries dir for a build module dir. Create sub-tree of missing dirs as needed, and return full path to innermost directory. """ bin_dir = os.path.join(self.conf.get_bin_path(), build_module) i...
python
def get_bin_dir(self, build_module: str) -> str: """Return a path to the binaries dir for a build module dir. Create sub-tree of missing dirs as needed, and return full path to innermost directory. """ bin_dir = os.path.join(self.conf.get_bin_path(), build_module) i...
[ "def", "get_bin_dir", "(", "self", ",", "build_module", ":", "str", ")", "->", "str", ":", "bin_dir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "conf", ".", "get_bin_path", "(", ")", ",", "build_module", ")", "if", "not", "os", ".", "p...
Return a path to the binaries dir for a build module dir. Create sub-tree of missing dirs as needed, and return full path to innermost directory.
[ "Return", "a", "path", "to", "the", "binaries", "dir", "for", "a", "build", "module", "dir", ".", "Create", "sub", "-", "tree", "of", "missing", "dirs", "as", "needed", "and", "return", "full", "path", "to", "innermost", "directory", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L117-L126
resonai/ybt
yabt/buildcontext.py
BuildContext.walk_target_deps_topological_order
def walk_target_deps_topological_order(self, target: Target): """Generate all dependencies of `target` by topological sort order.""" all_deps = get_descendants(self.target_graph, target.name) for dep_name in topological_sort(self.target_graph): if dep_name in all_deps: ...
python
def walk_target_deps_topological_order(self, target: Target): """Generate all dependencies of `target` by topological sort order.""" all_deps = get_descendants(self.target_graph, target.name) for dep_name in topological_sort(self.target_graph): if dep_name in all_deps: ...
[ "def", "walk_target_deps_topological_order", "(", "self", ",", "target", ":", "Target", ")", ":", "all_deps", "=", "get_descendants", "(", "self", ".", "target_graph", ",", "target", ".", "name", ")", "for", "dep_name", "in", "topological_sort", "(", "self", "...
Generate all dependencies of `target` by topological sort order.
[ "Generate", "all", "dependencies", "of", "target", "by", "topological", "sort", "order", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L128-L133
resonai/ybt
yabt/buildcontext.py
BuildContext.generate_direct_deps
def generate_direct_deps(self, target: Target): """Generate only direct dependencies of `target`.""" yield from (self.targets[dep_name] for dep_name in sorted(target.deps))
python
def generate_direct_deps(self, target: Target): """Generate only direct dependencies of `target`.""" yield from (self.targets[dep_name] for dep_name in sorted(target.deps))
[ "def", "generate_direct_deps", "(", "self", ",", "target", ":", "Target", ")", ":", "yield", "from", "(", "self", ".", "targets", "[", "dep_name", "]", "for", "dep_name", "in", "sorted", "(", "target", ".", "deps", ")", ")" ]
Generate only direct dependencies of `target`.
[ "Generate", "only", "direct", "dependencies", "of", "target", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L135-L137
resonai/ybt
yabt/buildcontext.py
BuildContext.generate_dep_names
def generate_dep_names(self, target: Target): """Generate names of all dependencies (descendants) of `target`.""" yield from sorted(get_descendants(self.target_graph, target.name))
python
def generate_dep_names(self, target: Target): """Generate names of all dependencies (descendants) of `target`.""" yield from sorted(get_descendants(self.target_graph, target.name))
[ "def", "generate_dep_names", "(", "self", ",", "target", ":", "Target", ")", ":", "yield", "from", "sorted", "(", "get_descendants", "(", "self", ".", "target_graph", ",", "target", ".", "name", ")", ")" ]
Generate names of all dependencies (descendants) of `target`.
[ "Generate", "names", "of", "all", "dependencies", "(", "descendants", ")", "of", "target", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L139-L141
resonai/ybt
yabt/buildcontext.py
BuildContext.generate_all_deps
def generate_all_deps(self, target: Target): """Generate all dependencies of `target` (the target nodes).""" yield from (self.targets[dep_name] for dep_name in self.generate_dep_names(target))
python
def generate_all_deps(self, target: Target): """Generate all dependencies of `target` (the target nodes).""" yield from (self.targets[dep_name] for dep_name in self.generate_dep_names(target))
[ "def", "generate_all_deps", "(", "self", ",", "target", ":", "Target", ")", ":", "yield", "from", "(", "self", ".", "targets", "[", "dep_name", "]", "for", "dep_name", "in", "self", ".", "generate_dep_names", "(", "target", ")", ")" ]
Generate all dependencies of `target` (the target nodes).
[ "Generate", "all", "dependencies", "of", "target", "(", "the", "target", "nodes", ")", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L143-L146
resonai/ybt
yabt/buildcontext.py
BuildContext.register_target
def register_target(self, target: Target): """Register a `target` instance in this build context. A registered target is saved in the `targets` map and in the `targets_by_module` map, but is not added to the target graph until target extraction is completed (thread safety considerations...
python
def register_target(self, target: Target): """Register a `target` instance in this build context. A registered target is saved in the `targets` map and in the `targets_by_module` map, but is not added to the target graph until target extraction is completed (thread safety considerations...
[ "def", "register_target", "(", "self", ",", "target", ":", "Target", ")", ":", "if", "target", ".", "name", "in", "self", ".", "targets", ":", "first", "=", "self", ".", "targets", "[", "target", ".", "name", "]", "raise", "NameError", "(", "'Target wi...
Register a `target` instance in this build context. A registered target is saved in the `targets` map and in the `targets_by_module` map, but is not added to the target graph until target extraction is completed (thread safety considerations).
[ "Register", "a", "target", "instance", "in", "this", "build", "context", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L148-L165
resonai/ybt
yabt/buildcontext.py
BuildContext.remove_target
def remove_target(self, target_name: str): """Remove (unregister) a `target` from this build context. Removes the target instance with the given name, if it exists, from both the `targets` map and the `targets_by_module` map. Doesn't do anything if no target with that name is found. ...
python
def remove_target(self, target_name: str): """Remove (unregister) a `target` from this build context. Removes the target instance with the given name, if it exists, from both the `targets` map and the `targets_by_module` map. Doesn't do anything if no target with that name is found. ...
[ "def", "remove_target", "(", "self", ",", "target_name", ":", "str", ")", ":", "if", "target_name", "in", "self", ".", "targets", ":", "del", "self", ".", "targets", "[", "target_name", "]", "build_module", "=", "split_build_module", "(", "target_name", ")",...
Remove (unregister) a `target` from this build context. Removes the target instance with the given name, if it exists, from both the `targets` map and the `targets_by_module` map. Doesn't do anything if no target with that name is found. Doesn't touch the target graph, if it exists.
[ "Remove", "(", "unregister", ")", "a", "target", "from", "this", "build", "context", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L167-L181
resonai/ybt
yabt/buildcontext.py
BuildContext.get_target_extraction_context
def get_target_extraction_context(self, build_file_path: str) -> dict: """Return a build file parser target extraction context. The target extraction context is a build-file-specific mapping from builder-name to target extraction function, for every registered builder. """ ...
python
def get_target_extraction_context(self, build_file_path: str) -> dict: """Return a build file parser target extraction context. The target extraction context is a build-file-specific mapping from builder-name to target extraction function, for every registered builder. """ ...
[ "def", "get_target_extraction_context", "(", "self", ",", "build_file_path", ":", "str", ")", "->", "dict", ":", "extraction_context", "=", "{", "}", "for", "name", ",", "builder", "in", "Plugin", ".", "builders", ".", "items", "(", ")", ":", "extraction_con...
Return a build file parser target extraction context. The target extraction context is a build-file-specific mapping from builder-name to target extraction function, for every registered builder.
[ "Return", "a", "build", "file", "parser", "target", "extraction", "context", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L183-L194
resonai/ybt
yabt/buildcontext.py
BuildContext.get_buildenv_graph
def get_buildenv_graph(self): """Return a graph induced by buildenv nodes""" # This implementation first obtains all subsets of nodes that all # buildenvs depend on, and then builds a subgraph induced by the union # of these subsets. This can be very non-optimal. # TODO(itamar): ...
python
def get_buildenv_graph(self): """Return a graph induced by buildenv nodes""" # This implementation first obtains all subsets of nodes that all # buildenvs depend on, and then builds a subgraph induced by the union # of these subsets. This can be very non-optimal. # TODO(itamar): ...
[ "def", "get_buildenv_graph", "(", "self", ")", ":", "# This implementation first obtains all subsets of nodes that all", "# buildenvs depend on, and then builds a subgraph induced by the union", "# of these subsets. This can be very non-optimal.", "# TODO(itamar): Reimplement efficient algo, or re...
Return a graph induced by buildenv nodes
[ "Return", "a", "graph", "induced", "by", "buildenv", "nodes" ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L200-L211
resonai/ybt
yabt/buildcontext.py
BuildContext.ready_nodes_iter
def ready_nodes_iter(self, graph_copy): """Generate ready targets from the graph `graph_copy`. The input graph is mutated by this method, so it has to be a mutable copy of the graph (e.g. not original copy, or read-only view). Caller **must** call `done()` after processing every genera...
python
def ready_nodes_iter(self, graph_copy): """Generate ready targets from the graph `graph_copy`. The input graph is mutated by this method, so it has to be a mutable copy of the graph (e.g. not original copy, or read-only view). Caller **must** call `done()` after processing every genera...
[ "def", "ready_nodes_iter", "(", "self", ",", "graph_copy", ")", ":", "def", "is_ready", "(", "target_name", ")", ":", "\"\"\"Return True if the node `target_name` is \"ready\" in the graph\n `graph_copy`.\n\n \"Ready\" means that the graph doesn't contain any mor...
Generate ready targets from the graph `graph_copy`. The input graph is mutated by this method, so it has to be a mutable copy of the graph (e.g. not original copy, or read-only view). Caller **must** call `done()` after processing every generated target, so additional ready targets can...
[ "Generate", "ready", "targets", "from", "the", "graph", "graph_copy", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L213-L326
resonai/ybt
yabt/buildcontext.py
BuildContext.run_in_buildenv
def run_in_buildenv( self, buildenv_target_name: str, cmd: list, cmd_env: dict=None, work_dir: str=None, auto_uid: bool=True, runtime: str=None, **kwargs): """Run a command in a named BuildEnv Docker image. :param buildenv_target_name: A named Docker image target in ...
python
def run_in_buildenv( self, buildenv_target_name: str, cmd: list, cmd_env: dict=None, work_dir: str=None, auto_uid: bool=True, runtime: str=None, **kwargs): """Run a command in a named BuildEnv Docker image. :param buildenv_target_name: A named Docker image target in ...
[ "def", "run_in_buildenv", "(", "self", ",", "buildenv_target_name", ":", "str", ",", "cmd", ":", "list", ",", "cmd_env", ":", "dict", "=", "None", ",", "work_dir", ":", "str", "=", "None", ",", "auto_uid", ":", "bool", "=", "True", ",", "runtime", ":",...
Run a command in a named BuildEnv Docker image. :param buildenv_target_name: A named Docker image target in which the command should be run. :param cmd: The command to run, as you'd pass to subprocess.run() :param cmd_env: A dictionary of environment variabl...
[ "Run", "a", "command", "in", "a", "named", "BuildEnv", "Docker", "image", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L350-L441
resonai/ybt
yabt/buildcontext.py
BuildContext.build_target
def build_target(self, target: Target): """Invoke the builder function for a target.""" builder = Plugin.builders[target.builder_name] if builder.func: logger.debug('About to invoke the {} builder function for {}', target.builder_name, target.name) ...
python
def build_target(self, target: Target): """Invoke the builder function for a target.""" builder = Plugin.builders[target.builder_name] if builder.func: logger.debug('About to invoke the {} builder function for {}', target.builder_name, target.name) ...
[ "def", "build_target", "(", "self", ",", "target", ":", "Target", ")", ":", "builder", "=", "Plugin", ".", "builders", "[", "target", ".", "builder_name", "]", "if", "builder", ".", "func", ":", "logger", ".", "debug", "(", "'About to invoke the {} builder f...
Invoke the builder function for a target.
[ "Invoke", "the", "builder", "function", "for", "a", "target", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L443-L452
resonai/ybt
yabt/buildcontext.py
BuildContext.register_target_artifact_metadata
def register_target_artifact_metadata(self, target: str, metadata: dict): """Register the artifact metadata dictionary for a built target.""" with self.context_lock: self.artifacts_metadata[target.name] = metadata
python
def register_target_artifact_metadata(self, target: str, metadata: dict): """Register the artifact metadata dictionary for a built target.""" with self.context_lock: self.artifacts_metadata[target.name] = metadata
[ "def", "register_target_artifact_metadata", "(", "self", ",", "target", ":", "str", ",", "metadata", ":", "dict", ")", ":", "with", "self", ".", "context_lock", ":", "self", ".", "artifacts_metadata", "[", "target", ".", "name", "]", "=", "metadata" ]
Register the artifact metadata dictionary for a built target.
[ "Register", "the", "artifact", "metadata", "dictionary", "for", "a", "built", "target", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L465-L468
resonai/ybt
yabt/buildcontext.py
BuildContext.write_artifacts_metadata
def write_artifacts_metadata(self): """Write out a JSON file with all built targets artifact metadata, if such output file is specified.""" if self.conf.artifacts_metadata_file: logger.info('Writing artifacts metadata to file "%s"', self.conf.artifacts_meta...
python
def write_artifacts_metadata(self): """Write out a JSON file with all built targets artifact metadata, if such output file is specified.""" if self.conf.artifacts_metadata_file: logger.info('Writing artifacts metadata to file "%s"', self.conf.artifacts_meta...
[ "def", "write_artifacts_metadata", "(", "self", ")", ":", "if", "self", ".", "conf", ".", "artifacts_metadata_file", ":", "logger", ".", "info", "(", "'Writing artifacts metadata to file \"%s\"'", ",", "self", ".", "conf", ".", "artifacts_metadata_file", ")", "with"...
Write out a JSON file with all built targets artifact metadata, if such output file is specified.
[ "Write", "out", "a", "JSON", "file", "with", "all", "built", "targets", "artifact", "metadata", "if", "such", "output", "file", "is", "specified", "." ]
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L470-L477
resonai/ybt
yabt/buildcontext.py
BuildContext.can_use_cache
def can_use_cache(self, target: Target) -> bool: """Return True if should attempt to load `target` from cache. Return False if `target` has to be built, regardless of its cache status (because cache is disabled, or dependencies are dirty). """ # if caching is disabled for t...
python
def can_use_cache(self, target: Target) -> bool: """Return True if should attempt to load `target` from cache. Return False if `target` has to be built, regardless of its cache status (because cache is disabled, or dependencies are dirty). """ # if caching is disabled for t...
[ "def", "can_use_cache", "(", "self", ",", "target", ":", "Target", ")", "->", "bool", ":", "# if caching is disabled for this execution, then all targets are dirty", "if", "self", ".", "conf", ".", "no_build_cache", ":", "return", "False", "# if the target's `cachable` pr...
Return True if should attempt to load `target` from cache. Return False if `target` has to be built, regardless of its cache status (because cache is disabled, or dependencies are dirty).
[ "Return", "True", "if", "should", "attempt", "to", "load", "target", "from", "cache", ".", "Return", "False", "if", "target", "has", "to", "be", "built", "regardless", "of", "its", "cache", "status", "(", "because", "cache", "is", "disabled", "or", "depend...
train
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/buildcontext.py#L479-L496