repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
jd/tenacity
tenacity/compat.py
wait_func_accept_retry_state
def wait_func_accept_retry_state(wait_func): """Wrap wait function to accept "retry_state" parameter.""" if not six.callable(wait_func): return wait_func if func_takes_retry_state(wait_func): return wait_func if func_takes_last_result(wait_func): @_utils.wraps(wait_func) ...
python
def wait_func_accept_retry_state(wait_func): """Wrap wait function to accept "retry_state" parameter.""" if not six.callable(wait_func): return wait_func if func_takes_retry_state(wait_func): return wait_func if func_takes_last_result(wait_func): @_utils.wraps(wait_func) ...
[ "def", "wait_func_accept_retry_state", "(", "wait_func", ")", ":", "if", "not", "six", ".", "callable", "(", "wait_func", ")", ":", "return", "wait_func", "if", "func_takes_retry_state", "(", "wait_func", ")", ":", "return", "wait_func", "if", "func_takes_last_res...
Wrap wait function to accept "retry_state" parameter.
[ "Wrap", "wait", "function", "to", "accept", "retry_state", "parameter", "." ]
354c40b7dc8e728c438668100dd020b65c84dfc6
https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L164-L191
train
jd/tenacity
tenacity/compat.py
retry_func_accept_retry_state
def retry_func_accept_retry_state(retry_func): """Wrap "retry" function to accept "retry_state" parameter.""" if not six.callable(retry_func): return retry_func if func_takes_retry_state(retry_func): return retry_func @_utils.wraps(retry_func) def wrapped_retry_func(retry_state): ...
python
def retry_func_accept_retry_state(retry_func): """Wrap "retry" function to accept "retry_state" parameter.""" if not six.callable(retry_func): return retry_func if func_takes_retry_state(retry_func): return retry_func @_utils.wraps(retry_func) def wrapped_retry_func(retry_state): ...
[ "def", "retry_func_accept_retry_state", "(", "retry_func", ")", ":", "if", "not", "six", ".", "callable", "(", "retry_func", ")", ":", "return", "retry_func", "if", "func_takes_retry_state", "(", "retry_func", ")", ":", "return", "retry_func", "@", "_utils", "."...
Wrap "retry" function to accept "retry_state" parameter.
[ "Wrap", "retry", "function", "to", "accept", "retry_state", "parameter", "." ]
354c40b7dc8e728c438668100dd020b65c84dfc6
https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L215-L228
train
jd/tenacity
tenacity/compat.py
before_func_accept_retry_state
def before_func_accept_retry_state(fn): """Wrap "before" function to accept "retry_state".""" if not six.callable(fn): return fn if func_takes_retry_state(fn): return fn @_utils.wraps(fn) def wrapped_before_func(retry_state): # func, trial_number, trial_time_taken w...
python
def before_func_accept_retry_state(fn): """Wrap "before" function to accept "retry_state".""" if not six.callable(fn): return fn if func_takes_retry_state(fn): return fn @_utils.wraps(fn) def wrapped_before_func(retry_state): # func, trial_number, trial_time_taken w...
[ "def", "before_func_accept_retry_state", "(", "fn", ")", ":", "if", "not", "six", ".", "callable", "(", "fn", ")", ":", "return", "fn", "if", "func_takes_retry_state", "(", "fn", ")", ":", "return", "fn", "@", "_utils", ".", "wraps", "(", "fn", ")", "d...
Wrap "before" function to accept "retry_state".
[ "Wrap", "before", "function", "to", "accept", "retry_state", "." ]
354c40b7dc8e728c438668100dd020b65c84dfc6
https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L231-L247
train
jd/tenacity
tenacity/compat.py
after_func_accept_retry_state
def after_func_accept_retry_state(fn): """Wrap "after" function to accept "retry_state".""" if not six.callable(fn): return fn if func_takes_retry_state(fn): return fn @_utils.wraps(fn) def wrapped_after_sleep_func(retry_state): # func, trial_number, trial_time_taken ...
python
def after_func_accept_retry_state(fn): """Wrap "after" function to accept "retry_state".""" if not six.callable(fn): return fn if func_takes_retry_state(fn): return fn @_utils.wraps(fn) def wrapped_after_sleep_func(retry_state): # func, trial_number, trial_time_taken ...
[ "def", "after_func_accept_retry_state", "(", "fn", ")", ":", "if", "not", "six", ".", "callable", "(", "fn", ")", ":", "return", "fn", "if", "func_takes_retry_state", "(", "fn", ")", ":", "return", "fn", "@", "_utils", ".", "wraps", "(", "fn", ")", "de...
Wrap "after" function to accept "retry_state".
[ "Wrap", "after", "function", "to", "accept", "retry_state", "." ]
354c40b7dc8e728c438668100dd020b65c84dfc6
https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L250-L266
train
jd/tenacity
tenacity/compat.py
before_sleep_func_accept_retry_state
def before_sleep_func_accept_retry_state(fn): """Wrap "before_sleep" function to accept "retry_state".""" if not six.callable(fn): return fn if func_takes_retry_state(fn): return fn @_utils.wraps(fn) def wrapped_before_sleep_func(retry_state): # retry_object, sleep, last_re...
python
def before_sleep_func_accept_retry_state(fn): """Wrap "before_sleep" function to accept "retry_state".""" if not six.callable(fn): return fn if func_takes_retry_state(fn): return fn @_utils.wraps(fn) def wrapped_before_sleep_func(retry_state): # retry_object, sleep, last_re...
[ "def", "before_sleep_func_accept_retry_state", "(", "fn", ")", ":", "if", "not", "six", ".", "callable", "(", "fn", ")", ":", "return", "fn", "if", "func_takes_retry_state", "(", "fn", ")", ":", "return", "fn", "@", "_utils", ".", "wraps", "(", "fn", ")"...
Wrap "before_sleep" function to accept "retry_state".
[ "Wrap", "before_sleep", "function", "to", "accept", "retry_state", "." ]
354c40b7dc8e728c438668100dd020b65c84dfc6
https://github.com/jd/tenacity/blob/354c40b7dc8e728c438668100dd020b65c84dfc6/tenacity/compat.py#L269-L286
train
divio/django-filer
filer/admin/patched/admin_utils.py
NestedObjects.nested
def nested(self, format_callback=None): """ Return the graph as a nested list. """ seen = set() roots = [] for root in self.edges.get(None, ()): roots.extend(self._nested(root, seen, format_callback)) return roots
python
def nested(self, format_callback=None): """ Return the graph as a nested list. """ seen = set() roots = [] for root in self.edges.get(None, ()): roots.extend(self._nested(root, seen, format_callback)) return roots
[ "def", "nested", "(", "self", ",", "format_callback", "=", "None", ")", ":", "seen", "=", "set", "(", ")", "roots", "=", "[", "]", "for", "root", "in", "self", ".", "edges", ".", "get", "(", "None", ",", "(", ")", ")", ":", "roots", ".", "exten...
Return the graph as a nested list.
[ "Return", "the", "graph", "as", "a", "nested", "list", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/patched/admin_utils.py#L132-L140
train
divio/django-filer
filer/utils/files.py
get_valid_filename
def get_valid_filename(s): """ like the regular get_valid_filename, but also slugifies away umlauts and stuff. """ s = get_valid_filename_django(s) filename, ext = os.path.splitext(s) filename = slugify(filename) ext = slugify(ext) if ext: return "%s.%s" % (filename, ext) ...
python
def get_valid_filename(s): """ like the regular get_valid_filename, but also slugifies away umlauts and stuff. """ s = get_valid_filename_django(s) filename, ext = os.path.splitext(s) filename = slugify(filename) ext = slugify(ext) if ext: return "%s.%s" % (filename, ext) ...
[ "def", "get_valid_filename", "(", "s", ")", ":", "s", "=", "get_valid_filename_django", "(", "s", ")", "filename", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "s", ")", "filename", "=", "slugify", "(", "filename", ")", "ext", "=", "slugif...
like the regular get_valid_filename, but also slugifies away umlauts and stuff.
[ "like", "the", "regular", "get_valid_filename", "but", "also", "slugifies", "away", "umlauts", "and", "stuff", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/files.py#L122-L134
train
divio/django-filer
filer/management/commands/import_files.py
FileImporter.walker
def walker(self, path=None, base_folder=None): """ This method walk a directory structure and create the Folders and Files as they appear. """ path = path or self.path or '' base_folder = base_folder or self.base_folder # prevent trailing slashes and other inconsi...
python
def walker(self, path=None, base_folder=None): """ This method walk a directory structure and create the Folders and Files as they appear. """ path = path or self.path or '' base_folder = base_folder or self.base_folder # prevent trailing slashes and other inconsi...
[ "def", "walker", "(", "self", ",", "path", "=", "None", ",", "base_folder", "=", "None", ")", ":", "path", "=", "path", "or", "self", ".", "path", "or", "''", "base_folder", "=", "base_folder", "or", "self", ".", "base_folder", "path", "=", "os", "."...
This method walk a directory structure and create the Folders and Files as they appear.
[ "This", "method", "walk", "a", "directory", "structure", "and", "create", "the", "Folders", "and", "Files", "as", "they", "appear", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/management/commands/import_files.py#L79-L108
train
divio/django-filer
filer/utils/zip.py
unzip
def unzip(file_obj): """ Take a path to a zipfile and checks if it is a valid zip file and returns... """ files = [] # TODO: implement try-except here zip = ZipFile(file_obj) bad_file = zip.testzip() if bad_file: raise Exception('"%s" in the .zip archive is corrupt.' % bad_fi...
python
def unzip(file_obj): """ Take a path to a zipfile and checks if it is a valid zip file and returns... """ files = [] # TODO: implement try-except here zip = ZipFile(file_obj) bad_file = zip.testzip() if bad_file: raise Exception('"%s" in the .zip archive is corrupt.' % bad_fi...
[ "def", "unzip", "(", "file_obj", ")", ":", "files", "=", "[", "]", "zip", "=", "ZipFile", "(", "file_obj", ")", "bad_file", "=", "zip", ".", "testzip", "(", ")", "if", "bad_file", ":", "raise", "Exception", "(", "'\"%s\" in the .zip archive is corrupt.'", ...
Take a path to a zipfile and checks if it is a valid zip file and returns...
[ "Take", "a", "path", "to", "a", "zipfile", "and", "checks", "if", "it", "is", "a", "valid", "zip", "file", "and", "returns", "..." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/zip.py#L9-L27
train
divio/django-filer
filer/utils/filer_easy_thumbnails.py
ThumbnailerNameMixin.get_thumbnail_name
def get_thumbnail_name(self, thumbnail_options, transparent=False, high_resolution=False): """ A version of ``Thumbnailer.get_thumbnail_name`` that produces a reproducible thumbnail name that can be converted back to the original filename. """ p...
python
def get_thumbnail_name(self, thumbnail_options, transparent=False, high_resolution=False): """ A version of ``Thumbnailer.get_thumbnail_name`` that produces a reproducible thumbnail name that can be converted back to the original filename. """ p...
[ "def", "get_thumbnail_name", "(", "self", ",", "thumbnail_options", ",", "transparent", "=", "False", ",", "high_resolution", "=", "False", ")", ":", "path", ",", "source_filename", "=", "os", ".", "path", ".", "split", "(", "self", ".", "name", ")", "sour...
A version of ``Thumbnailer.get_thumbnail_name`` that produces a reproducible thumbnail name that can be converted back to the original filename.
[ "A", "version", "of", "Thumbnailer", ".", "get_thumbnail_name", "that", "produces", "a", "reproducible", "thumbnail", "name", "that", "can", "be", "converted", "back", "to", "the", "original", "filename", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/filer_easy_thumbnails.py#L29-L72
train
divio/django-filer
filer/utils/filer_easy_thumbnails.py
ActionThumbnailerMixin.get_thumbnail_name
def get_thumbnail_name(self, thumbnail_options, transparent=False, high_resolution=False): """ A version of ``Thumbnailer.get_thumbnail_name`` that returns the original filename to resize. """ path, filename = os.path.split(self.name) basedir =...
python
def get_thumbnail_name(self, thumbnail_options, transparent=False, high_resolution=False): """ A version of ``Thumbnailer.get_thumbnail_name`` that returns the original filename to resize. """ path, filename = os.path.split(self.name) basedir =...
[ "def", "get_thumbnail_name", "(", "self", ",", "thumbnail_options", ",", "transparent", "=", "False", ",", "high_resolution", "=", "False", ")", ":", "path", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "self", ".", "name", ")", "basedir", ...
A version of ``Thumbnailer.get_thumbnail_name`` that returns the original filename to resize.
[ "A", "version", "of", "Thumbnailer", ".", "get_thumbnail_name", "that", "returns", "the", "original", "filename", "to", "resize", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/filer_easy_thumbnails.py#L80-L91
train
divio/django-filer
filer/admin/folderadmin.py
FolderAdmin.owner_search_fields
def owner_search_fields(self): """ Returns all the fields that are CharFields except for password from the User model. For the built-in User model, that means username, first_name, last_name, and email. """ try: from django.contrib.auth import get_user_model ...
python
def owner_search_fields(self): """ Returns all the fields that are CharFields except for password from the User model. For the built-in User model, that means username, first_name, last_name, and email. """ try: from django.contrib.auth import get_user_model ...
[ "def", "owner_search_fields", "(", "self", ")", ":", "try", ":", "from", "django", ".", "contrib", ".", "auth", "import", "get_user_model", "except", "ImportError", ":", "from", "django", ".", "contrib", ".", "auth", ".", "models", "import", "User", "else", ...
Returns all the fields that are CharFields except for password from the User model. For the built-in User model, that means username, first_name, last_name, and email.
[ "Returns", "all", "the", "fields", "that", "are", "CharFields", "except", "for", "password", "from", "the", "User", "model", ".", "For", "the", "built", "-", "in", "User", "model", "that", "means", "username", "first_name", "last_name", "and", "email", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/folderadmin.py#L481-L496
train
divio/django-filer
filer/admin/folderadmin.py
FolderAdmin.move_to_clipboard
def move_to_clipboard(self, request, files_queryset, folders_queryset): """ Action which moves the selected files and files in selected folders to clipboard. """ if not self.has_change_permission(request): raise PermissionDenied if request.method != 'POST': ...
python
def move_to_clipboard(self, request, files_queryset, folders_queryset): """ Action which moves the selected files and files in selected folders to clipboard. """ if not self.has_change_permission(request): raise PermissionDenied if request.method != 'POST': ...
[ "def", "move_to_clipboard", "(", "self", ",", "request", ",", "files_queryset", ",", "folders_queryset", ")", ":", "if", "not", "self", ".", "has_change_permission", "(", "request", ")", ":", "raise", "PermissionDenied", "if", "request", ".", "method", "!=", "...
Action which moves the selected files and files in selected folders to clipboard.
[ "Action", "which", "moves", "the", "selected", "files", "and", "files", "in", "selected", "folders", "to", "clipboard", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/folderadmin.py#L596-L634
train
divio/django-filer
filer/admin/tools.py
admin_url_params
def admin_url_params(request, params=None): """ given a request, looks at GET and POST values to determine which params should be added. Is used to keep the context of popup and picker mode. """ params = params or {} if popup_status(request): params[IS_POPUP_VAR] = '1' pick_type = po...
python
def admin_url_params(request, params=None): """ given a request, looks at GET and POST values to determine which params should be added. Is used to keep the context of popup and picker mode. """ params = params or {} if popup_status(request): params[IS_POPUP_VAR] = '1' pick_type = po...
[ "def", "admin_url_params", "(", "request", ",", "params", "=", "None", ")", ":", "params", "=", "params", "or", "{", "}", "if", "popup_status", "(", "request", ")", ":", "params", "[", "IS_POPUP_VAR", "]", "=", "'1'", "pick_type", "=", "popup_pick_type", ...
given a request, looks at GET and POST values to determine which params should be added. Is used to keep the context of popup and picker mode.
[ "given", "a", "request", "looks", "at", "GET", "and", "POST", "values", "to", "determine", "which", "params", "should", "be", "added", ".", "Is", "used", "to", "keep", "the", "context", "of", "popup", "and", "picker", "mode", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/tools.py#L70-L81
train
divio/django-filer
filer/admin/imageadmin.py
ImageAdminForm.clean_subject_location
def clean_subject_location(self): """ Validate subject_location preserving last saved value. Last valid value of the subject_location field is shown to the user for subject location widget to receive valid coordinates on field validation errors. """ cleaned_data ...
python
def clean_subject_location(self): """ Validate subject_location preserving last saved value. Last valid value of the subject_location field is shown to the user for subject location widget to receive valid coordinates on field validation errors. """ cleaned_data ...
[ "def", "clean_subject_location", "(", "self", ")", ":", "cleaned_data", "=", "super", "(", "ImageAdminForm", ",", "self", ")", ".", "clean", "(", ")", "subject_location", "=", "cleaned_data", "[", "'subject_location'", "]", "if", "not", "subject_location", ":", ...
Validate subject_location preserving last saved value. Last valid value of the subject_location field is shown to the user for subject location widget to receive valid coordinates on field validation errors.
[ "Validate", "subject_location", "preserving", "last", "saved", "value", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/imageadmin.py#L42-L80
train
divio/django-filer
filer/utils/loader.py
load_object
def load_object(import_path): """ Loads an object from an 'import_path', like in MIDDLEWARE_CLASSES and the likes. Import paths should be: "mypackage.mymodule.MyObject". It then imports the module up until the last dot and tries to get the attribute after that dot from the imported module. ...
python
def load_object(import_path): """ Loads an object from an 'import_path', like in MIDDLEWARE_CLASSES and the likes. Import paths should be: "mypackage.mymodule.MyObject". It then imports the module up until the last dot and tries to get the attribute after that dot from the imported module. ...
[ "def", "load_object", "(", "import_path", ")", ":", "if", "not", "isinstance", "(", "import_path", ",", "six", ".", "string_types", ")", ":", "return", "import_path", "if", "'.'", "not", "in", "import_path", ":", "raise", "TypeError", "(", "\"'import_path' arg...
Loads an object from an 'import_path', like in MIDDLEWARE_CLASSES and the likes. Import paths should be: "mypackage.mymodule.MyObject". It then imports the module up until the last dot and tries to get the attribute after that dot from the imported module. If the import path does not contain any d...
[ "Loads", "an", "object", "from", "an", "import_path", "like", "in", "MIDDLEWARE_CLASSES", "and", "the", "likes", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/loader.py#L18-L41
train
divio/django-filer
filer/management/commands/generate_thumbnails.py
Command.handle
def handle(self, *args, **options): """ Generates image thumbnails NOTE: To keep memory consumption stable avoid iteration over the Image queryset """ pks = Image.objects.all().values_list('id', flat=True) total = len(pks) for idx, pk in enumerate(pks): ...
python
def handle(self, *args, **options): """ Generates image thumbnails NOTE: To keep memory consumption stable avoid iteration over the Image queryset """ pks = Image.objects.all().values_list('id', flat=True) total = len(pks) for idx, pk in enumerate(pks): ...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "**", "options", ")", ":", "pks", "=", "Image", ".", "objects", ".", "all", "(", ")", ".", "values_list", "(", "'id'", ",", "flat", "=", "True", ")", "total", "=", "len", "(", "pks", ")", "fo...
Generates image thumbnails NOTE: To keep memory consumption stable avoid iteration over the Image queryset
[ "Generates", "image", "thumbnails" ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/management/commands/generate_thumbnails.py#L9-L29
train
divio/django-filer
filer/utils/compatibility.py
upath
def upath(path): """ Always return a unicode path. """ if six.PY2 and not isinstance(path, six.text_type): return path.decode(fs_encoding) return path
python
def upath(path): """ Always return a unicode path. """ if six.PY2 and not isinstance(path, six.text_type): return path.decode(fs_encoding) return path
[ "def", "upath", "(", "path", ")", ":", "if", "six", ".", "PY2", "and", "not", "isinstance", "(", "path", ",", "six", ".", "text_type", ")", ":", "return", "path", ".", "decode", "(", "fs_encoding", ")", "return", "path" ]
Always return a unicode path.
[ "Always", "return", "a", "unicode", "path", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/compatibility.py#L60-L66
train
divio/django-filer
filer/utils/model_label.py
get_model_label
def get_model_label(model): """ Take a model class or model label and return its model label. >>> get_model_label(MyModel) "myapp.MyModel" >>> get_model_label("myapp.MyModel") "myapp.MyModel" """ if isinstance(model, six.string_types): return model else: return "%s....
python
def get_model_label(model): """ Take a model class or model label and return its model label. >>> get_model_label(MyModel) "myapp.MyModel" >>> get_model_label("myapp.MyModel") "myapp.MyModel" """ if isinstance(model, six.string_types): return model else: return "%s....
[ "def", "get_model_label", "(", "model", ")", ":", "if", "isinstance", "(", "model", ",", "six", ".", "string_types", ")", ":", "return", "model", "else", ":", "return", "\"%s.%s\"", "%", "(", "model", ".", "_meta", ".", "app_label", ",", "model", ".", ...
Take a model class or model label and return its model label. >>> get_model_label(MyModel) "myapp.MyModel" >>> get_model_label("myapp.MyModel") "myapp.MyModel"
[ "Take", "a", "model", "class", "or", "model", "label", "and", "return", "its", "model", "label", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/utils/model_label.py#L8-L24
train
divio/django-filer
filer/admin/clipboardadmin.py
ajax_upload
def ajax_upload(request, folder_id=None): """ Receives an upload from the uploader. Receives only one file at a time. """ folder = None if folder_id: try: # Get folder folder = Folder.objects.get(pk=folder_id) except Folder.DoesNotExist: return Jso...
python
def ajax_upload(request, folder_id=None): """ Receives an upload from the uploader. Receives only one file at a time. """ folder = None if folder_id: try: # Get folder folder = Folder.objects.get(pk=folder_id) except Folder.DoesNotExist: return Jso...
[ "def", "ajax_upload", "(", "request", ",", "folder_id", "=", "None", ")", ":", "folder", "=", "None", "if", "folder_id", ":", "try", ":", "folder", "=", "Folder", ".", "objects", ".", "get", "(", "pk", "=", "folder_id", ")", "except", "Folder", ".", ...
Receives an upload from the uploader. Receives only one file at a time.
[ "Receives", "an", "upload", "from", "the", "uploader", ".", "Receives", "only", "one", "file", "at", "a", "time", "." ]
946629087943d41eff290f07bfdf240b8853dd88
https://github.com/divio/django-filer/blob/946629087943d41eff290f07bfdf240b8853dd88/filer/admin/clipboardadmin.py#L72-L174
train
pyeve/cerberus
cerberus/validator.py
BareValidator.__store_config
def __store_config(self, args, kwargs): """ Assign args to kwargs and store configuration. """ signature = ( 'schema', 'ignore_none_values', 'allow_unknown', 'require_all', 'purge_unknown', 'purge_readonly', ) for i,...
python
def __store_config(self, args, kwargs): """ Assign args to kwargs and store configuration. """ signature = ( 'schema', 'ignore_none_values', 'allow_unknown', 'require_all', 'purge_unknown', 'purge_readonly', ) for i,...
[ "def", "__store_config", "(", "self", ",", "args", ",", "kwargs", ")", ":", "signature", "=", "(", "'schema'", ",", "'ignore_none_values'", ",", "'allow_unknown'", ",", "'require_all'", ",", "'purge_unknown'", ",", "'purge_readonly'", ",", ")", "for", "i", ","...
Assign args to kwargs and store configuration.
[ "Assign", "args", "to", "kwargs", "and", "store", "configuration", "." ]
688a67a4069e88042ed424bda7be0f4fa5fc3910
https://github.com/pyeve/cerberus/blob/688a67a4069e88042ed424bda7be0f4fa5fc3910/cerberus/validator.py#L207-L225
train
pyeve/cerberus
cerberus/validator.py
BareValidator._error
def _error(self, *args): """ Creates and adds one or multiple errors. :param args: Accepts different argument's signatures. *1. Bulk addition of errors:* - :term:`iterable` of :class:`~cerberus.errors.ValidationError`-instances ...
python
def _error(self, *args): """ Creates and adds one or multiple errors. :param args: Accepts different argument's signatures. *1. Bulk addition of errors:* - :term:`iterable` of :class:`~cerberus.errors.ValidationError`-instances ...
[ "def", "_error", "(", "self", ",", "*", "args", ")", ":", "if", "len", "(", "args", ")", "==", "1", ":", "self", ".", "_errors", ".", "extend", "(", "args", "[", "0", "]", ")", "self", ".", "_errors", ".", "sort", "(", ")", "for", "error", "i...
Creates and adds one or multiple errors. :param args: Accepts different argument's signatures. *1. Bulk addition of errors:* - :term:`iterable` of :class:`~cerberus.errors.ValidationError`-instances The errors will be adde...
[ "Creates", "and", "adds", "one", "or", "multiple", "errors", "." ]
688a67a4069e88042ed424bda7be0f4fa5fc3910
https://github.com/pyeve/cerberus/blob/688a67a4069e88042ed424bda7be0f4fa5fc3910/cerberus/validator.py#L232-L308
train
pyeve/cerberus
cerberus/validator.py
BareValidator.__validate_definitions
def __validate_definitions(self, definitions, field): """ Validate a field's value against its defined rules. """ def validate_rule(rule): validator = self.__get_rule_handler('validate', rule) return validator(definitions.get(rule, None), field, value) definitions = sel...
python
def __validate_definitions(self, definitions, field): """ Validate a field's value against its defined rules. """ def validate_rule(rule): validator = self.__get_rule_handler('validate', rule) return validator(definitions.get(rule, None), field, value) definitions = sel...
[ "def", "__validate_definitions", "(", "self", ",", "definitions", ",", "field", ")", ":", "def", "validate_rule", "(", "rule", ")", ":", "validator", "=", "self", ".", "__get_rule_handler", "(", "'validate'", ",", "rule", ")", "return", "validator", "(", "de...
Validate a field's value against its defined rules.
[ "Validate", "a", "field", "s", "value", "against", "its", "defined", "rules", "." ]
688a67a4069e88042ed424bda7be0f4fa5fc3910
https://github.com/pyeve/cerberus/blob/688a67a4069e88042ed424bda7be0f4fa5fc3910/cerberus/validator.py#L1036-L1073
train
mobolic/facebook-sdk
facebook/__init__.py
get_user_from_cookie
def get_user_from_cookie(cookies, app_id, app_secret): """Parses the cookie set by the official Facebook JavaScript SDK. cookies should be a dictionary-like object mapping cookie names to cookie values. If the user is logged in via Facebook, we return a dictionary with the keys "uid" and "access_t...
python
def get_user_from_cookie(cookies, app_id, app_secret): """Parses the cookie set by the official Facebook JavaScript SDK. cookies should be a dictionary-like object mapping cookie names to cookie values. If the user is logged in via Facebook, we return a dictionary with the keys "uid" and "access_t...
[ "def", "get_user_from_cookie", "(", "cookies", ",", "app_id", ",", "app_secret", ")", ":", "cookie", "=", "cookies", ".", "get", "(", "\"fbsr_\"", "+", "app_id", ",", "\"\"", ")", "if", "not", "cookie", ":", "return", "None", "parsed_request", "=", "parse_...
Parses the cookie set by the official Facebook JavaScript SDK. cookies should be a dictionary-like object mapping cookie names to cookie values. If the user is logged in via Facebook, we return a dictionary with the keys "uid" and "access_token". The former is the user's Facebook ID, and the latte...
[ "Parses", "the", "cookie", "set", "by", "the", "official", "Facebook", "JavaScript", "SDK", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L443-L472
train
mobolic/facebook-sdk
facebook/__init__.py
parse_signed_request
def parse_signed_request(signed_request, app_secret): """ Return dictionary with signed request data. We return a dictionary containing the information in the signed_request. This includes a user_id if the user has authorised your application, as well as any information requested. If the signed_re...
python
def parse_signed_request(signed_request, app_secret): """ Return dictionary with signed request data. We return a dictionary containing the information in the signed_request. This includes a user_id if the user has authorised your application, as well as any information requested. If the signed_re...
[ "def", "parse_signed_request", "(", "signed_request", ",", "app_secret", ")", ":", "try", ":", "encoded_sig", ",", "payload", "=", "map", "(", "str", ",", "signed_request", ".", "split", "(", "\".\"", ",", "1", ")", ")", "sig", "=", "base64", ".", "urlsa...
Return dictionary with signed request data. We return a dictionary containing the information in the signed_request. This includes a user_id if the user has authorised your application, as well as any information requested. If the signed_request is malformed or corrupted, False is returned.
[ "Return", "dictionary", "with", "signed", "request", "data", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L475-L519
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.get_permissions
def get_permissions(self, user_id): """Fetches the permissions object from the graph.""" response = self.request( "{0}/{1}/permissions".format(self.version, user_id), {} )["data"] return {x["permission"] for x in response if x["status"] == "granted"}
python
def get_permissions(self, user_id): """Fetches the permissions object from the graph.""" response = self.request( "{0}/{1}/permissions".format(self.version, user_id), {} )["data"] return {x["permission"] for x in response if x["status"] == "granted"}
[ "def", "get_permissions", "(", "self", ",", "user_id", ")", ":", "response", "=", "self", ".", "request", "(", "\"{0}/{1}/permissions\"", ".", "format", "(", "self", ".", "version", ",", "user_id", ")", ",", "{", "}", ")", "[", "\"data\"", "]", "return",...
Fetches the permissions object from the graph.
[ "Fetches", "the", "permissions", "object", "from", "the", "graph", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L126-L131
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.get_object
def get_object(self, id, **args): """Fetches the given object from the graph.""" return self.request("{0}/{1}".format(self.version, id), args)
python
def get_object(self, id, **args): """Fetches the given object from the graph.""" return self.request("{0}/{1}".format(self.version, id), args)
[ "def", "get_object", "(", "self", ",", "id", ",", "**", "args", ")", ":", "return", "self", ".", "request", "(", "\"{0}/{1}\"", ".", "format", "(", "self", ".", "version", ",", "id", ")", ",", "args", ")" ]
Fetches the given object from the graph.
[ "Fetches", "the", "given", "object", "from", "the", "graph", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L133-L135
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.get_objects
def get_objects(self, ids, **args): """Fetches all of the given object from the graph. We return a map from ID to object. If any of the IDs are invalid, we raise an exception. """ args["ids"] = ",".join(ids) return self.request(self.version + "/", args)
python
def get_objects(self, ids, **args): """Fetches all of the given object from the graph. We return a map from ID to object. If any of the IDs are invalid, we raise an exception. """ args["ids"] = ",".join(ids) return self.request(self.version + "/", args)
[ "def", "get_objects", "(", "self", ",", "ids", ",", "**", "args", ")", ":", "args", "[", "\"ids\"", "]", "=", "\",\"", ".", "join", "(", "ids", ")", "return", "self", ".", "request", "(", "self", ".", "version", "+", "\"/\"", ",", "args", ")" ]
Fetches all of the given object from the graph. We return a map from ID to object. If any of the IDs are invalid, we raise an exception.
[ "Fetches", "all", "of", "the", "given", "object", "from", "the", "graph", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L137-L144
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.get_connections
def get_connections(self, id, connection_name, **args): """Fetches the connections for given object.""" return self.request( "{0}/{1}/{2}".format(self.version, id, connection_name), args )
python
def get_connections(self, id, connection_name, **args): """Fetches the connections for given object.""" return self.request( "{0}/{1}/{2}".format(self.version, id, connection_name), args )
[ "def", "get_connections", "(", "self", ",", "id", ",", "connection_name", ",", "**", "args", ")", ":", "return", "self", ".", "request", "(", "\"{0}/{1}/{2}\"", ".", "format", "(", "self", ".", "version", ",", "id", ",", "connection_name", ")", ",", "arg...
Fetches the connections for given object.
[ "Fetches", "the", "connections", "for", "given", "object", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L156-L160
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.get_all_connections
def get_all_connections(self, id, connection_name, **args): """Get all pages from a get_connections call This will iterate over all pages returned by a get_connections call and yield the individual items. """ while True: page = self.get_connections(id, connection_nam...
python
def get_all_connections(self, id, connection_name, **args): """Get all pages from a get_connections call This will iterate over all pages returned by a get_connections call and yield the individual items. """ while True: page = self.get_connections(id, connection_nam...
[ "def", "get_all_connections", "(", "self", ",", "id", ",", "connection_name", ",", "**", "args", ")", ":", "while", "True", ":", "page", "=", "self", ".", "get_connections", "(", "id", ",", "connection_name", ",", "**", "args", ")", "for", "post", "in", ...
Get all pages from a get_connections call This will iterate over all pages returned by a get_connections call and yield the individual items.
[ "Get", "all", "pages", "from", "a", "get_connections", "call" ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L162-L176
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.put_object
def put_object(self, parent_object, connection_name, **data): """Writes the given object to the graph, connected to the given parent. For example, graph.put_object("me", "feed", message="Hello, world") writes "Hello, world" to the active user's wall. Likewise, this will co...
python
def put_object(self, parent_object, connection_name, **data): """Writes the given object to the graph, connected to the given parent. For example, graph.put_object("me", "feed", message="Hello, world") writes "Hello, world" to the active user's wall. Likewise, this will co...
[ "def", "put_object", "(", "self", ",", "parent_object", ",", "connection_name", ",", "**", "data", ")", ":", "assert", "self", ".", "access_token", ",", "\"Write operations require an access token\"", "return", "self", ".", "request", "(", "\"{0}/{1}/{2}\"", ".", ...
Writes the given object to the graph, connected to the given parent. For example, graph.put_object("me", "feed", message="Hello, world") writes "Hello, world" to the active user's wall. Likewise, this will comment on the first post of the active user's feed: feed = gr...
[ "Writes", "the", "given", "object", "to", "the", "graph", "connected", "to", "the", "given", "parent", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L178-L202
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.delete_request
def delete_request(self, user_id, request_id): """Deletes the Request with the given ID for the given user.""" return self.request( "{0}_{1}".format(request_id, user_id), method="DELETE" )
python
def delete_request(self, user_id, request_id): """Deletes the Request with the given ID for the given user.""" return self.request( "{0}_{1}".format(request_id, user_id), method="DELETE" )
[ "def", "delete_request", "(", "self", ",", "user_id", ",", "request_id", ")", ":", "return", "self", ".", "request", "(", "\"{0}_{1}\"", ".", "format", "(", "request_id", ",", "user_id", ")", ",", "method", "=", "\"DELETE\"", ")" ]
Deletes the Request with the given ID for the given user.
[ "Deletes", "the", "Request", "with", "the", "given", "ID", "for", "the", "given", "user", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L218-L222
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.get_version
def get_version(self): """Fetches the current version number of the Graph API being used.""" args = {"access_token": self.access_token} try: response = self.session.request( "GET", FACEBOOK_GRAPH_URL + self.version + "/me", params=args,...
python
def get_version(self): """Fetches the current version number of the Graph API being used.""" args = {"access_token": self.access_token} try: response = self.session.request( "GET", FACEBOOK_GRAPH_URL + self.version + "/me", params=args,...
[ "def", "get_version", "(", "self", ")", ":", "args", "=", "{", "\"access_token\"", ":", "self", ".", "access_token", "}", "try", ":", "response", "=", "self", ".", "session", ".", "request", "(", "\"GET\"", ",", "FACEBOOK_GRAPH_URL", "+", "self", ".", "v...
Fetches the current version number of the Graph API being used.
[ "Fetches", "the", "current", "version", "number", "of", "the", "Graph", "API", "being", "used", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L239-L259
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.request
def request( self, path, args=None, post_args=None, files=None, method=None ): """Fetches the given path in the Graph API. We translate args to a valid query string. If post_args is given, we send a POST request to the given path with the given arguments. """ ...
python
def request( self, path, args=None, post_args=None, files=None, method=None ): """Fetches the given path in the Graph API. We translate args to a valid query string. If post_args is given, we send a POST request to the given path with the given arguments. """ ...
[ "def", "request", "(", "self", ",", "path", ",", "args", "=", "None", ",", "post_args", "=", "None", ",", "files", "=", "None", ",", "method", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "dict", "(", ")", "if", "post_args...
Fetches the given path in the Graph API. We translate args to a valid query string. If post_args is given, we send a POST request to the given path with the given arguments.
[ "Fetches", "the", "given", "path", "in", "the", "Graph", "API", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L261-L323
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.get_access_token_from_code
def get_access_token_from_code( self, code, redirect_uri, app_id, app_secret ): """Get an access token from the "code" returned from an OAuth dialog. Returns a dict containing the user-specific access token and its expiration date (if applicable). """ args = { ...
python
def get_access_token_from_code( self, code, redirect_uri, app_id, app_secret ): """Get an access token from the "code" returned from an OAuth dialog. Returns a dict containing the user-specific access token and its expiration date (if applicable). """ args = { ...
[ "def", "get_access_token_from_code", "(", "self", ",", "code", ",", "redirect_uri", ",", "app_id", ",", "app_secret", ")", ":", "args", "=", "{", "\"code\"", ":", "code", ",", "\"redirect_uri\"", ":", "redirect_uri", ",", "\"client_id\"", ":", "app_id", ",", ...
Get an access token from the "code" returned from an OAuth dialog. Returns a dict containing the user-specific access token and its expiration date (if applicable).
[ "Get", "an", "access", "token", "from", "the", "code", "returned", "from", "an", "OAuth", "dialog", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L346-L364
train
mobolic/facebook-sdk
facebook/__init__.py
GraphAPI.get_auth_url
def get_auth_url(self, app_id, canvas_url, perms=None, **kwargs): """Build a URL to create an OAuth dialog.""" url = "{0}{1}/{2}".format( FACEBOOK_WWW_URL, self.version, FACEBOOK_OAUTH_DIALOG_PATH ) args = {"client_id": app_id, "redirect_uri": canvas_url} if perms: ...
python
def get_auth_url(self, app_id, canvas_url, perms=None, **kwargs): """Build a URL to create an OAuth dialog.""" url = "{0}{1}/{2}".format( FACEBOOK_WWW_URL, self.version, FACEBOOK_OAUTH_DIALOG_PATH ) args = {"client_id": app_id, "redirect_uri": canvas_url} if perms: ...
[ "def", "get_auth_url", "(", "self", ",", "app_id", ",", "canvas_url", ",", "perms", "=", "None", ",", "**", "kwargs", ")", ":", "url", "=", "\"{0}{1}/{2}\"", ".", "format", "(", "FACEBOOK_WWW_URL", ",", "self", ".", "version", ",", "FACEBOOK_OAUTH_DIALOG_PAT...
Build a URL to create an OAuth dialog.
[ "Build", "a", "URL", "to", "create", "an", "OAuth", "dialog", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/facebook/__init__.py#L401-L411
train
mobolic/facebook-sdk
examples/flask/app/views.py
get_current_user
def get_current_user(): """Set g.user to the currently logged in user. Called before each request, get_current_user sets the global g.user variable to the currently logged in user. A currently logged in user is determined by seeing if it exists in Flask's session dictionary. If it is the first ti...
python
def get_current_user(): """Set g.user to the currently logged in user. Called before each request, get_current_user sets the global g.user variable to the currently logged in user. A currently logged in user is determined by seeing if it exists in Flask's session dictionary. If it is the first ti...
[ "def", "get_current_user", "(", ")", ":", "if", "session", ".", "get", "(", "\"user\"", ")", ":", "g", ".", "user", "=", "session", ".", "get", "(", "\"user\"", ")", "return", "result", "=", "get_user_from_cookie", "(", "cookies", "=", "request", ".", ...
Set g.user to the currently logged in user. Called before each request, get_current_user sets the global g.user variable to the currently logged in user. A currently logged in user is determined by seeing if it exists in Flask's session dictionary. If it is the first time the user is logging into thi...
[ "Set", "g", ".", "user", "to", "the", "currently", "logged", "in", "user", "." ]
65ff582e77f7ed68b6e9643a7490e5dee2a1031b
https://github.com/mobolic/facebook-sdk/blob/65ff582e77f7ed68b6e9643a7490e5dee2a1031b/examples/flask/app/views.py#L38-L95
train
NetEaseGame/ATX
atx/record/scene_detector.py
SceneDetector.build_tree
def build_tree(self, directory): '''build scene tree from images''' confile = os.path.join(directory, 'config.yml') conf = {} if os.path.exists(confile): conf = yaml.load(open(confile).read()) class node(defaultdict): name = '' parent...
python
def build_tree(self, directory): '''build scene tree from images''' confile = os.path.join(directory, 'config.yml') conf = {} if os.path.exists(confile): conf = yaml.load(open(confile).read()) class node(defaultdict): name = '' parent...
[ "def", "build_tree", "(", "self", ",", "directory", ")", ":", "confile", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "'config.yml'", ")", "conf", "=", "{", "}", "if", "os", ".", "path", ".", "exists", "(", "confile", ")", ":", "conf...
build scene tree from images
[ "build", "scene", "tree", "from", "images" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/scene_detector.py#L81-L126
train
NetEaseGame/ATX
atx/adbkit/openstf/service.py
pack
def pack(mtype, request, rid=None): '''pack request to delimited data''' envelope = wire.Envelope() if rid is not None: envelope.id = rid envelope.type = mtype envelope.message = request.SerializeToString() data = envelope.SerializeToString() data = encoder._VarintBytes(len(data)) +...
python
def pack(mtype, request, rid=None): '''pack request to delimited data''' envelope = wire.Envelope() if rid is not None: envelope.id = rid envelope.type = mtype envelope.message = request.SerializeToString() data = envelope.SerializeToString() data = encoder._VarintBytes(len(data)) +...
[ "def", "pack", "(", "mtype", ",", "request", ",", "rid", "=", "None", ")", ":", "envelope", "=", "wire", ".", "Envelope", "(", ")", "if", "rid", "is", "not", "None", ":", "envelope", ".", "id", "=", "rid", "envelope", ".", "type", "=", "mtype", "...
pack request to delimited data
[ "pack", "request", "to", "delimited", "data" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/openstf/service.py#L75-L84
train
NetEaseGame/ATX
atx/adbkit/openstf/service.py
unpack
def unpack(data): '''unpack from delimited data''' size, position = decoder._DecodeVarint(data, 0) envelope = wire.Envelope() envelope.ParseFromString(data[position:position+size]) return envelope
python
def unpack(data): '''unpack from delimited data''' size, position = decoder._DecodeVarint(data, 0) envelope = wire.Envelope() envelope.ParseFromString(data[position:position+size]) return envelope
[ "def", "unpack", "(", "data", ")", ":", "size", ",", "position", "=", "decoder", ".", "_DecodeVarint", "(", "data", ",", "0", ")", "envelope", "=", "wire", ".", "Envelope", "(", ")", "envelope", ".", "ParseFromString", "(", "data", "[", "position", ":"...
unpack from delimited data
[ "unpack", "from", "delimited", "data" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/openstf/service.py#L86-L91
train
NetEaseGame/ATX
atx/adbkit/openstf/service.py
check_stf_agent
def check_stf_agent(adbprefix=None, kill=False): '''return True if agent is alive.''' if adbprefix is None: adbprefix = ['adb'] command = adbprefix + ['shell', 'ps'] out = subprocess.check_output(command).strip() out = out.splitlines() if len(out) > 1: first, out = out[0], out[1...
python
def check_stf_agent(adbprefix=None, kill=False): '''return True if agent is alive.''' if adbprefix is None: adbprefix = ['adb'] command = adbprefix + ['shell', 'ps'] out = subprocess.check_output(command).strip() out = out.splitlines() if len(out) > 1: first, out = out[0], out[1...
[ "def", "check_stf_agent", "(", "adbprefix", "=", "None", ",", "kill", "=", "False", ")", ":", "if", "adbprefix", "is", "None", ":", "adbprefix", "=", "[", "'adb'", "]", "command", "=", "adbprefix", "+", "[", "'shell'", ",", "'ps'", "]", "out", "=", "...
return True if agent is alive.
[ "return", "True", "if", "agent", "is", "alive", "." ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/openstf/service.py#L182-L205
train
NetEaseGame/ATX
atx/cmds/tkgui.py
insert_code
def insert_code(filename, code, save=True, marker='# ATX CODE END'): """ Auto append code """ content = '' found = False for line in open(filename, 'rb'): if not found and line.strip() == marker: found = True cnt = line.find(marker) content += line[:cnt] + cod...
python
def insert_code(filename, code, save=True, marker='# ATX CODE END'): """ Auto append code """ content = '' found = False for line in open(filename, 'rb'): if not found and line.strip() == marker: found = True cnt = line.find(marker) content += line[:cnt] + cod...
[ "def", "insert_code", "(", "filename", ",", "code", ",", "save", "=", "True", ",", "marker", "=", "'# ATX CODE END'", ")", ":", "content", "=", "''", "found", "=", "False", "for", "line", "in", "open", "(", "filename", ",", "'rb'", ")", ":", "if", "n...
Auto append code
[ "Auto", "append", "code" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/cmds/tkgui.py#L41-L58
train
NetEaseGame/ATX
scripts/image.py
find_image_position
def find_image_position(origin='origin.png', query='query.png', outfile=None): ''' find all image positions @return None if not found else a tuple: (origin.shape, query.shape, postions) might raise Exception ''' img1 = cv2.imread(query, 0) # query image(small) img2 = cv2.imread(origin, 0) # ...
python
def find_image_position(origin='origin.png', query='query.png', outfile=None): ''' find all image positions @return None if not found else a tuple: (origin.shape, query.shape, postions) might raise Exception ''' img1 = cv2.imread(query, 0) # query image(small) img2 = cv2.imread(origin, 0) # ...
[ "def", "find_image_position", "(", "origin", "=", "'origin.png'", ",", "query", "=", "'query.png'", ",", "outfile", "=", "None", ")", ":", "img1", "=", "cv2", ".", "imread", "(", "query", ",", "0", ")", "img2", "=", "cv2", ".", "imread", "(", "origin",...
find all image positions @return None if not found else a tuple: (origin.shape, query.shape, postions) might raise Exception
[ "find", "all", "image", "positions" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/scripts/image.py#L46-L102
train
NetEaseGame/ATX
atx/taskqueue/__main__.py
TaskQueueHandler.get
def get(self, udid): ''' get new task ''' timeout = self.get_argument('timeout', 20.0) if timeout is not None: timeout = float(timeout) que = self.ques[udid] try: item = yield que.get(timeout=time.time()+timeout) # timeout is a timestamp, strange ...
python
def get(self, udid): ''' get new task ''' timeout = self.get_argument('timeout', 20.0) if timeout is not None: timeout = float(timeout) que = self.ques[udid] try: item = yield que.get(timeout=time.time()+timeout) # timeout is a timestamp, strange ...
[ "def", "get", "(", "self", ",", "udid", ")", ":", "timeout", "=", "self", ".", "get_argument", "(", "'timeout'", ",", "20.0", ")", "if", "timeout", "is", "not", "None", ":", "timeout", "=", "float", "(", "timeout", ")", "que", "=", "self", ".", "qu...
get new task
[ "get", "new", "task" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/taskqueue/__main__.py#L42-L57
train
NetEaseGame/ATX
atx/taskqueue/__main__.py
TaskQueueHandler.post
def post(self, udid): ''' add new task ''' que = self.ques[udid] timeout = self.get_argument('timeout', 10.0) if timeout is not None: timeout = float(timeout) data = tornado.escape.json_decode(self.request.body) data = {'id': str(uuid.uuid1()), 'data': data} ...
python
def post(self, udid): ''' add new task ''' que = self.ques[udid] timeout = self.get_argument('timeout', 10.0) if timeout is not None: timeout = float(timeout) data = tornado.escape.json_decode(self.request.body) data = {'id': str(uuid.uuid1()), 'data': data} ...
[ "def", "post", "(", "self", ",", "udid", ")", ":", "que", "=", "self", ".", "ques", "[", "udid", "]", "timeout", "=", "self", ".", "get_argument", "(", "'timeout'", ",", "10.0", ")", "if", "timeout", "is", "not", "None", ":", "timeout", "=", "float...
add new task
[ "add", "new", "task" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/taskqueue/__main__.py#L60-L71
train
NetEaseGame/ATX
atx/record/android_hooks.py
InputParser._process_touch_batch
def _process_touch_batch(self): '''a batch syncs in about 0.001 seconds.''' if not self._touch_batch: return _time = self._temp_status_time changed = False for (_time, _device, _type, _code, _value) in self._touch_batch: if _code == 'ABS_MT_TRAC...
python
def _process_touch_batch(self): '''a batch syncs in about 0.001 seconds.''' if not self._touch_batch: return _time = self._temp_status_time changed = False for (_time, _device, _type, _code, _value) in self._touch_batch: if _code == 'ABS_MT_TRAC...
[ "def", "_process_touch_batch", "(", "self", ")", ":", "if", "not", "self", ".", "_touch_batch", ":", "return", "_time", "=", "self", ".", "_temp_status_time", "changed", "=", "False", "for", "(", "_time", ",", "_device", ",", "_type", ",", "_code", ",", ...
a batch syncs in about 0.001 seconds.
[ "a", "batch", "syncs", "in", "about", "0", ".", "001", "seconds", "." ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/android_hooks.py#L218-L283
train
NetEaseGame/ATX
atx/record/android_hooks.py
GestureRecognizer.process
def process(self): '''handle events and trigger time-related events''' timediff = 0 while True: try: time.sleep(0.001) event = self.queue.get_nowait() self.handle_event(event) if event.msg & HC.KEY_ANY: ...
python
def process(self): '''handle events and trigger time-related events''' timediff = 0 while True: try: time.sleep(0.001) event = self.queue.get_nowait() self.handle_event(event) if event.msg & HC.KEY_ANY: ...
[ "def", "process", "(", "self", ")", ":", "timediff", "=", "0", "while", "True", ":", "try", ":", "time", ".", "sleep", "(", "0.001", ")", "event", "=", "self", ".", "queue", ".", "get_nowait", "(", ")", "self", ".", "handle_event", "(", "event", ")...
handle events and trigger time-related events
[ "handle", "events", "and", "trigger", "time", "-", "related", "events" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/android_hooks.py#L334-L367
train
NetEaseGame/ATX
atx/drivers/mixin.py
DeviceMixin.exists
def exists(self, pattern, **match_kwargs): """Check if image exists in screen Returns: If exists, return FindPoint, or return None if result.confidence < self.image_match_threshold """ ret = self.match(pattern, **match_kwargs) if ret is None: ...
python
def exists(self, pattern, **match_kwargs): """Check if image exists in screen Returns: If exists, return FindPoint, or return None if result.confidence < self.image_match_threshold """ ret = self.match(pattern, **match_kwargs) if ret is None: ...
[ "def", "exists", "(", "self", ",", "pattern", ",", "**", "match_kwargs", ")", ":", "ret", "=", "self", ".", "match", "(", "pattern", ",", "**", "match_kwargs", ")", "if", "ret", "is", "None", ":", "return", "None", "if", "not", "ret", ".", "matched",...
Check if image exists in screen Returns: If exists, return FindPoint, or return None if result.confidence < self.image_match_threshold
[ "Check", "if", "image", "exists", "in", "screen" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L143-L155
train
NetEaseGame/ATX
atx/drivers/mixin.py
DeviceMixin._match_auto
def _match_auto(self, screen, search_img, threshold): """Maybe not a good idea """ # 1. try template first ret = ac.find_template(screen, search_img) if ret and ret['confidence'] > threshold: return FindPoint(ret['result'], ret['confidence'], consts.IMAGE_MATCH_METHOD...
python
def _match_auto(self, screen, search_img, threshold): """Maybe not a good idea """ # 1. try template first ret = ac.find_template(screen, search_img) if ret and ret['confidence'] > threshold: return FindPoint(ret['result'], ret['confidence'], consts.IMAGE_MATCH_METHOD...
[ "def", "_match_auto", "(", "self", ",", "screen", ",", "search_img", ",", "threshold", ")", ":", "ret", "=", "ac", ".", "find_template", "(", "screen", ",", "search_img", ")", "if", "ret", "and", "ret", "[", "'confidence'", "]", ">", "threshold", ":", ...
Maybe not a good idea
[ "Maybe", "not", "a", "good", "idea" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L217-L233
train
NetEaseGame/ATX
atx/drivers/mixin.py
DeviceMixin.match_all
def match_all(self, pattern): """ Test method, not suggested to use """ pattern = self.pattern_open(pattern) search_img = pattern.image screen = self.region_screenshot() screen = imutils.from_pillow(screen) points = ac.find_all_template(screen, search_img,...
python
def match_all(self, pattern): """ Test method, not suggested to use """ pattern = self.pattern_open(pattern) search_img = pattern.image screen = self.region_screenshot() screen = imutils.from_pillow(screen) points = ac.find_all_template(screen, search_img,...
[ "def", "match_all", "(", "self", ",", "pattern", ")", ":", "pattern", "=", "self", ".", "pattern_open", "(", "pattern", ")", "search_img", "=", "pattern", ".", "image", "screen", "=", "self", ".", "region_screenshot", "(", ")", "screen", "=", "imutils", ...
Test method, not suggested to use
[ "Test", "method", "not", "suggested", "to", "use" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L235-L244
train
NetEaseGame/ATX
atx/drivers/mixin.py
DeviceMixin.region_screenshot
def region_screenshot(self, filename=None): """Deprecated Take part of the screenshot """ # warnings.warn("deprecated, use screenshot().crop(bounds) instead", DeprecationWarning) screen = self.__last_screen if self.__keep_screen else self.screenshot() if self.bounds: ...
python
def region_screenshot(self, filename=None): """Deprecated Take part of the screenshot """ # warnings.warn("deprecated, use screenshot().crop(bounds) instead", DeprecationWarning) screen = self.__last_screen if self.__keep_screen else self.screenshot() if self.bounds: ...
[ "def", "region_screenshot", "(", "self", ",", "filename", "=", "None", ")", ":", "screen", "=", "self", ".", "__last_screen", "if", "self", ".", "__keep_screen", "else", "self", ".", "screenshot", "(", ")", "if", "self", ".", "bounds", ":", "screen", "="...
Deprecated Take part of the screenshot
[ "Deprecated", "Take", "part", "of", "the", "screenshot" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L375-L385
train
NetEaseGame/ATX
atx/drivers/mixin.py
DeviceMixin.screenshot
def screenshot(self, filename=None): """ Take screen snapshot Args: - filename: filename where save to, optional Returns: PIL.Image object Raises: TypeError, IOError """ if self.__keep_screen: return self.__last_s...
python
def screenshot(self, filename=None): """ Take screen snapshot Args: - filename: filename where save to, optional Returns: PIL.Image object Raises: TypeError, IOError """ if self.__keep_screen: return self.__last_s...
[ "def", "screenshot", "(", "self", ",", "filename", "=", "None", ")", ":", "if", "self", ".", "__keep_screen", ":", "return", "self", ".", "__last_screen", "try", ":", "screen", "=", "self", ".", "_take_screenshot", "(", ")", "except", "IOError", ":", "lo...
Take screen snapshot Args: - filename: filename where save to, optional Returns: PIL.Image object Raises: TypeError, IOError
[ "Take", "screen", "snapshot" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L388-L415
train
NetEaseGame/ATX
atx/drivers/mixin.py
DeviceMixin.click_nowait
def click_nowait(self, pattern, action='click', desc=None, **match_kwargs): """ Return immediately if no image found Args: - pattern (str or Pattern): filename or an opencv image object. - action (str): click or long_click Returns: Click point or None ...
python
def click_nowait(self, pattern, action='click', desc=None, **match_kwargs): """ Return immediately if no image found Args: - pattern (str or Pattern): filename or an opencv image object. - action (str): click or long_click Returns: Click point or None ...
[ "def", "click_nowait", "(", "self", ",", "pattern", ",", "action", "=", "'click'", ",", "desc", "=", "None", ",", "**", "match_kwargs", ")", ":", "point", "=", "self", ".", "match", "(", "pattern", ",", "**", "match_kwargs", ")", "if", "not", "point", ...
Return immediately if no image found Args: - pattern (str or Pattern): filename or an opencv image object. - action (str): click or long_click Returns: Click point or None
[ "Return", "immediately", "if", "no", "image", "found" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L471-L487
train
NetEaseGame/ATX
atx/drivers/mixin.py
DeviceMixin.click_image
def click_image(self, pattern, timeout=20.0, action='click', safe=False, desc=None, delay=None, **match_kwargs): """Simulate click according image position Args: - pattern (str or Pattern): filename or an opencv image object. - timeout (float): if image not found during this tim...
python
def click_image(self, pattern, timeout=20.0, action='click', safe=False, desc=None, delay=None, **match_kwargs): """Simulate click according image position Args: - pattern (str or Pattern): filename or an opencv image object. - timeout (float): if image not found during this tim...
[ "def", "click_image", "(", "self", ",", "pattern", ",", "timeout", "=", "20.0", ",", "action", "=", "'click'", ",", "safe", "=", "False", ",", "desc", "=", "None", ",", "delay", "=", "None", ",", "**", "match_kwargs", ")", ":", "pattern", "=", "self"...
Simulate click according image position Args: - pattern (str or Pattern): filename or an opencv image object. - timeout (float): if image not found during this time, ImageNotFoundError will raise. - action (str): click or long_click - safe (bool): if safe is True...
[ "Simulate", "click", "according", "image", "position" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/mixin.py#L503-L555
train
NetEaseGame/ATX
atx/base.py
list_images
def list_images(path=['.']): """ Return list of image files """ for image_dir in set(path): if not os.path.isdir(image_dir): continue for filename in os.listdir(image_dir): bname, ext = os.path.splitext(filename) if ext.lower() not in VALID_IMAGE_EXTS: ...
python
def list_images(path=['.']): """ Return list of image files """ for image_dir in set(path): if not os.path.isdir(image_dir): continue for filename in os.listdir(image_dir): bname, ext = os.path.splitext(filename) if ext.lower() not in VALID_IMAGE_EXTS: ...
[ "def", "list_images", "(", "path", "=", "[", "'.'", "]", ")", ":", "for", "image_dir", "in", "set", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "image_dir", ")", ":", "continue", "for", "filename", "in", "os", ".", "...
Return list of image files
[ "Return", "list", "of", "image", "files" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/base.py#L94-L105
train
NetEaseGame/ATX
atx/base.py
list_all_image
def list_all_image(path, valid_exts=VALID_IMAGE_EXTS): """List all images under path @return unicode list """ for filename in os.listdir(path): bname, ext = os.path.splitext(filename) if ext.lower() not in VALID_IMAGE_EXTS: continue filepath = os.path.join(path, file...
python
def list_all_image(path, valid_exts=VALID_IMAGE_EXTS): """List all images under path @return unicode list """ for filename in os.listdir(path): bname, ext = os.path.splitext(filename) if ext.lower() not in VALID_IMAGE_EXTS: continue filepath = os.path.join(path, file...
[ "def", "list_all_image", "(", "path", ",", "valid_exts", "=", "VALID_IMAGE_EXTS", ")", ":", "for", "filename", "in", "os", ".", "listdir", "(", "path", ")", ":", "bname", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "if", ...
List all images under path @return unicode list
[ "List", "all", "images", "under", "path" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/base.py#L108-L118
train
NetEaseGame/ATX
atx/base.py
search_image
def search_image(name=None, path=['.']): """ look for the image real path, if name is None, then return all images under path. @return system encoded path string FIXME(ssx): this code is just looking wired. """ name = strutils.decode(name) for image_dir in path: if not os.path.isdir...
python
def search_image(name=None, path=['.']): """ look for the image real path, if name is None, then return all images under path. @return system encoded path string FIXME(ssx): this code is just looking wired. """ name = strutils.decode(name) for image_dir in path: if not os.path.isdir...
[ "def", "search_image", "(", "name", "=", "None", ",", "path", "=", "[", "'.'", "]", ")", ":", "name", "=", "strutils", ".", "decode", "(", "name", ")", "for", "image_dir", "in", "path", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "ima...
look for the image real path, if name is None, then return all images under path. @return system encoded path string FIXME(ssx): this code is just looking wired.
[ "look", "for", "the", "image", "real", "path", "if", "name", "is", "None", "then", "return", "all", "images", "under", "path", "." ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/base.py#L145-L165
train
NetEaseGame/ATX
atx/adbkit/device.py
Device.run_cmd
def run_cmd(self, *args, **kwargs): """ Unix style output, already replace \r\n to \n Args: - timeout (float): timeout for a command exec """ timeout = kwargs.pop('timeout', None) p = self.raw_cmd(*args, **kwargs) return p.communicate(timeout=timeout)...
python
def run_cmd(self, *args, **kwargs): """ Unix style output, already replace \r\n to \n Args: - timeout (float): timeout for a command exec """ timeout = kwargs.pop('timeout', None) p = self.raw_cmd(*args, **kwargs) return p.communicate(timeout=timeout)...
[ "def", "run_cmd", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "timeout", "=", "kwargs", ".", "pop", "(", "'timeout'", ",", "None", ")", "p", "=", "self", ".", "raw_cmd", "(", "*", "args", ",", "**", "kwargs", ")", "return", "p",...
Unix style output, already replace \r\n to \n Args: - timeout (float): timeout for a command exec
[ "Unix", "style", "output", "already", "replace", "\\", "r", "\\", "n", "to", "\\", "n" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L47-L56
train
NetEaseGame/ATX
atx/adbkit/device.py
Device.shell
def shell(self, *args, **kwargs): """ Run command `adb shell` """ args = ['shell'] + list(args) return self.run_cmd(*args, **kwargs)
python
def shell(self, *args, **kwargs): """ Run command `adb shell` """ args = ['shell'] + list(args) return self.run_cmd(*args, **kwargs)
[ "def", "shell", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "args", "=", "[", "'shell'", "]", "+", "list", "(", "args", ")", "return", "self", ".", "run_cmd", "(", "*", "args", ",", "**", "kwargs", ")" ]
Run command `adb shell`
[ "Run", "command", "adb", "shell" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L58-L63
train
NetEaseGame/ATX
atx/adbkit/device.py
Device.remove
def remove(self, filename): """ Remove file from device """ output = self.shell('rm', filename) # any output means rm failed. return False if output else True
python
def remove(self, filename): """ Remove file from device """ output = self.shell('rm', filename) # any output means rm failed. return False if output else True
[ "def", "remove", "(", "self", ",", "filename", ")", ":", "output", "=", "self", ".", "shell", "(", "'rm'", ",", "filename", ")", "return", "False", "if", "output", "else", "True" ]
Remove file from device
[ "Remove", "file", "from", "device" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L69-L75
train
NetEaseGame/ATX
atx/adbkit/device.py
Device.display
def display(self): ''' Return device width, height, rotation ''' w, h = (0, 0) for line in self.shell('dumpsys', 'display').splitlines(): m = _DISPLAY_RE.search(line, 0) if not m: continue w = int(m.group('width')) h...
python
def display(self): ''' Return device width, height, rotation ''' w, h = (0, 0) for line in self.shell('dumpsys', 'display').splitlines(): m = _DISPLAY_RE.search(line, 0) if not m: continue w = int(m.group('width')) h...
[ "def", "display", "(", "self", ")", ":", "w", ",", "h", "=", "(", "0", ",", "0", ")", "for", "line", "in", "self", ".", "shell", "(", "'dumpsys'", ",", "'display'", ")", ".", "splitlines", "(", ")", ":", "m", "=", "_DISPLAY_RE", ".", "search", ...
Return device width, height, rotation
[ "Return", "device", "width", "height", "rotation" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L105-L126
train
NetEaseGame/ATX
atx/adbkit/device.py
Device.packages
def packages(self): """ Show all packages """ pattern = re.compile(r'package:(/[^=]+\.apk)=([^\s]+)') packages = [] for line in self.shell('pm', 'list', 'packages', '-f').splitlines(): m = pattern.match(line) if not m: continue ...
python
def packages(self): """ Show all packages """ pattern = re.compile(r'package:(/[^=]+\.apk)=([^\s]+)') packages = [] for line in self.shell('pm', 'list', 'packages', '-f').splitlines(): m = pattern.match(line) if not m: continue ...
[ "def", "packages", "(", "self", ")", ":", "pattern", "=", "re", ".", "compile", "(", "r'package:(/[^=]+\\.apk)=([^\\s]+)'", ")", "packages", "=", "[", "]", "for", "line", "in", "self", ".", "shell", "(", "'pm'", ",", "'list'", ",", "'packages'", ",", "'-...
Show all packages
[ "Show", "all", "packages" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L153-L165
train
NetEaseGame/ATX
atx/adbkit/device.py
Device._adb_screencap
def _adb_screencap(self, scale=1.0): """ capture screen with adb shell screencap """ remote_file = tempfile.mktemp(dir='/data/local/tmp/', prefix='screencap-', suffix='.png') local_file = tempfile.mktemp(prefix='atx-screencap-', suffix='.png') self.shell('screencap', '-p'...
python
def _adb_screencap(self, scale=1.0): """ capture screen with adb shell screencap """ remote_file = tempfile.mktemp(dir='/data/local/tmp/', prefix='screencap-', suffix='.png') local_file = tempfile.mktemp(prefix='atx-screencap-', suffix='.png') self.shell('screencap', '-p'...
[ "def", "_adb_screencap", "(", "self", ",", "scale", "=", "1.0", ")", ":", "remote_file", "=", "tempfile", ".", "mktemp", "(", "dir", "=", "'/data/local/tmp/'", ",", "prefix", "=", "'screencap-'", ",", "suffix", "=", "'.png'", ")", "local_file", "=", "tempf...
capture screen with adb shell screencap
[ "capture", "screen", "with", "adb", "shell", "screencap" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L167-L186
train
NetEaseGame/ATX
atx/adbkit/device.py
Device._adb_minicap
def _adb_minicap(self, scale=1.0): """ capture screen with minicap https://github.com/openstf/minicap """ remote_file = tempfile.mktemp(dir='/data/local/tmp/', prefix='minicap-', suffix='.jpg') local_file = tempfile.mktemp(prefix='atx-minicap-', suffix='.jpg') (w...
python
def _adb_minicap(self, scale=1.0): """ capture screen with minicap https://github.com/openstf/minicap """ remote_file = tempfile.mktemp(dir='/data/local/tmp/', prefix='minicap-', suffix='.jpg') local_file = tempfile.mktemp(prefix='atx-minicap-', suffix='.jpg') (w...
[ "def", "_adb_minicap", "(", "self", ",", "scale", "=", "1.0", ")", ":", "remote_file", "=", "tempfile", ".", "mktemp", "(", "dir", "=", "'/data/local/tmp/'", ",", "prefix", "=", "'minicap-'", ",", "suffix", "=", "'.jpg'", ")", "local_file", "=", "tempfile"...
capture screen with minicap https://github.com/openstf/minicap
[ "capture", "screen", "with", "minicap" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L188-L205
train
NetEaseGame/ATX
atx/adbkit/device.py
Device.screenshot
def screenshot(self, filename=None, scale=1.0, method=None): """ Take device screenshot Args: - filename(string): optional, save int filename - scale(float): scale size - method(string): one of minicap,screencap Return: PIL.Image ...
python
def screenshot(self, filename=None, scale=1.0, method=None): """ Take device screenshot Args: - filename(string): optional, save int filename - scale(float): scale size - method(string): one of minicap,screencap Return: PIL.Image ...
[ "def", "screenshot", "(", "self", ",", "filename", "=", "None", ",", "scale", "=", "1.0", ",", "method", "=", "None", ")", ":", "image", "=", "None", "method", "=", "method", "or", "self", ".", "_screenshot_method", "if", "method", "==", "'minicap'", "...
Take device screenshot Args: - filename(string): optional, save int filename - scale(float): scale size - method(string): one of minicap,screencap Return: PIL.Image
[ "Take", "device", "screenshot" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L207-L235
train
NetEaseGame/ATX
atx/record/android_layout.py
AndroidLayout.get_index_node
def get_index_node(self, idx): '''get node with iterindex `idx`''' idx = self.node_index.index(idx) return self.nodes[idx]
python
def get_index_node(self, idx): '''get node with iterindex `idx`''' idx = self.node_index.index(idx) return self.nodes[idx]
[ "def", "get_index_node", "(", "self", ",", "idx", ")", ":", "idx", "=", "self", ".", "node_index", ".", "index", "(", "idx", ")", "return", "self", ".", "nodes", "[", "idx", "]" ]
get node with iterindex `idx`
[ "get", "node", "with", "iterindex", "idx" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/android_layout.py#L178-L181
train
NetEaseGame/ATX
atx/record/base.py
BaseRecorder.start
def start(self): '''start running in background.''' self.update_device_info() self.get_device_status(0) # start addons. self.hook() self.thread = threading.Thread(target=self._run) self.thread.start() self.running = True
python
def start(self): '''start running in background.''' self.update_device_info() self.get_device_status(0) # start addons. self.hook() self.thread = threading.Thread(target=self._run) self.thread.start() self.running = True
[ "def", "start", "(", "self", ")", ":", "self", ".", "update_device_info", "(", ")", "self", ".", "get_device_status", "(", "0", ")", "self", ".", "hook", "(", ")", "self", ".", "thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", "....
start running in background.
[ "start", "running", "in", "background", "." ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/base.py#L66-L73
train
NetEaseGame/ATX
atx/record/base.py
BaseRecorder.analyze_frames
def analyze_frames(cls, workdir): '''generate draft from recorded frames''' record = cls(None, workdir) obj = {} with open(os.path.join(workdir, 'frames', 'frames.json')) as f: obj = json.load(f) record.device_info = obj['device'] record.frames = obj['f...
python
def analyze_frames(cls, workdir): '''generate draft from recorded frames''' record = cls(None, workdir) obj = {} with open(os.path.join(workdir, 'frames', 'frames.json')) as f: obj = json.load(f) record.device_info = obj['device'] record.frames = obj['f...
[ "def", "analyze_frames", "(", "cls", ",", "workdir", ")", ":", "record", "=", "cls", "(", "None", ",", "workdir", ")", "obj", "=", "{", "}", "with", "open", "(", "os", ".", "path", ".", "join", "(", "workdir", ",", "'frames'", ",", "'frames.json'", ...
generate draft from recorded frames
[ "generate", "draft", "from", "recorded", "frames" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/base.py#L180-L189
train
NetEaseGame/ATX
atx/record/base.py
BaseRecorder.process_casefile
def process_casefile(cls, workdir): '''generate code from case.json''' record = cls(None, workdir) obj = {} with open(os.path.join(workdir, 'frames', 'frames.json')) as f: obj = json.load(f) record.device_info = obj['device'] record.frames = obj['frames...
python
def process_casefile(cls, workdir): '''generate code from case.json''' record = cls(None, workdir) obj = {} with open(os.path.join(workdir, 'frames', 'frames.json')) as f: obj = json.load(f) record.device_info = obj['device'] record.frames = obj['frames...
[ "def", "process_casefile", "(", "cls", ",", "workdir", ")", ":", "record", "=", "cls", "(", "None", ",", "workdir", ")", "obj", "=", "{", "}", "with", "open", "(", "os", ".", "path", ".", "join", "(", "workdir", ",", "'frames'", ",", "'frames.json'",...
generate code from case.json
[ "generate", "code", "from", "case", ".", "json" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/base.py#L192-L210
train
NetEaseGame/ATX
atx/adbkit/client.py
Client.adb_path
def adb_path(cls): """return adb binary full path""" if cls.__adb_cmd is None: if "ANDROID_HOME" in os.environ: filename = "adb.exe" if os.name == 'nt' else "adb" adb_dir = os.path.join(os.environ["ANDROID_HOME"], "platform-tools") adb_cmd = os...
python
def adb_path(cls): """return adb binary full path""" if cls.__adb_cmd is None: if "ANDROID_HOME" in os.environ: filename = "adb.exe" if os.name == 'nt' else "adb" adb_dir = os.path.join(os.environ["ANDROID_HOME"], "platform-tools") adb_cmd = os...
[ "def", "adb_path", "(", "cls", ")", ":", "if", "cls", ".", "__adb_cmd", "is", "None", ":", "if", "\"ANDROID_HOME\"", "in", "os", ".", "environ", ":", "filename", "=", "\"adb.exe\"", "if", "os", ".", "name", "==", "'nt'", "else", "\"adb\"", "adb_dir", "...
return adb binary full path
[ "return", "adb", "binary", "full", "path" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/client.py#L52-L72
train
NetEaseGame/ATX
atx/adbkit/client.py
Client.connect
def connect(self, addr): ''' Call adb connect Return true when connect success ''' if addr.find(':') == -1: addr += ':5555' output = self.run_cmd('connect', addr) return 'unable to connect' not in output
python
def connect(self, addr): ''' Call adb connect Return true when connect success ''' if addr.find(':') == -1: addr += ':5555' output = self.run_cmd('connect', addr) return 'unable to connect' not in output
[ "def", "connect", "(", "self", ",", "addr", ")", ":", "if", "addr", ".", "find", "(", "':'", ")", "==", "-", "1", ":", "addr", "+=", "':5555'", "output", "=", "self", ".", "run_cmd", "(", "'connect'", ",", "addr", ")", "return", "'unable to connect'"...
Call adb connect Return true when connect success
[ "Call", "adb", "connect", "Return", "true", "when", "connect", "success" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/client.py#L137-L145
train
NetEaseGame/ATX
atx/cmds/screencap.py
main
def main(host=None, port=None, serial=None, scale=1.0, out='screenshot.png', method='minicap'): """ If minicap not avaliable then use uiautomator instead Disable scale for now. Because -s scale is conflict of -s serial """ print('Started screencap') start = time.time() client...
python
def main(host=None, port=None, serial=None, scale=1.0, out='screenshot.png', method='minicap'): """ If minicap not avaliable then use uiautomator instead Disable scale for now. Because -s scale is conflict of -s serial """ print('Started screencap') start = time.time() client...
[ "def", "main", "(", "host", "=", "None", ",", "port", "=", "None", ",", "serial", "=", "None", ",", "scale", "=", "1.0", ",", "out", "=", "'screenshot.png'", ",", "method", "=", "'minicap'", ")", ":", "print", "(", "'Started screencap'", ")", "start", ...
If minicap not avaliable then use uiautomator instead Disable scale for now. Because -s scale is conflict of -s serial
[ "If", "minicap", "not", "avaliable", "then", "use", "uiautomator", "instead", "Disable", "scale", "for", "now", ".", "Because", "-", "s", "scale", "is", "conflict", "of", "-", "s", "serial" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/cmds/screencap.py#L14-L45
train
NetEaseGame/ATX
atx/drivers/android.py
AndroidDevice.rotation
def rotation(self): """ Rotaion of the phone 0: normal 1: home key on the right 2: home key on the top 3: home key on the left """ if self.screen_rotation in range(4): return self.screen_rotation return self.adb_device.rotation() or se...
python
def rotation(self): """ Rotaion of the phone 0: normal 1: home key on the right 2: home key on the top 3: home key on the left """ if self.screen_rotation in range(4): return self.screen_rotation return self.adb_device.rotation() or se...
[ "def", "rotation", "(", "self", ")", ":", "if", "self", ".", "screen_rotation", "in", "range", "(", "4", ")", ":", "return", "self", ".", "screen_rotation", "return", "self", ".", "adb_device", ".", "rotation", "(", ")", "or", "self", ".", "info", "[",...
Rotaion of the phone 0: normal 1: home key on the right 2: home key on the top 3: home key on the left
[ "Rotaion", "of", "the", "phone" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/android.py#L192-L203
train
NetEaseGame/ATX
atx/drivers/android.py
AndroidDevice.properties
def properties(self): ''' Android Properties, extracted from `adb shell getprop` Returns: dict of props, for example: {'ro.bluetooth.dun': 'true'} ''' props = {} for line in self.adb_shell(['getprop']).splitlines(): m ...
python
def properties(self): ''' Android Properties, extracted from `adb shell getprop` Returns: dict of props, for example: {'ro.bluetooth.dun': 'true'} ''' props = {} for line in self.adb_shell(['getprop']).splitlines(): m ...
[ "def", "properties", "(", "self", ")", ":", "props", "=", "{", "}", "for", "line", "in", "self", ".", "adb_shell", "(", "[", "'getprop'", "]", ")", ".", "splitlines", "(", ")", ":", "m", "=", "_PROP_PATTERN", ".", "match", "(", "line", ")", "if", ...
Android Properties, extracted from `adb shell getprop` Returns: dict of props, for example: {'ro.bluetooth.dun': 'true'}
[ "Android", "Properties", "extracted", "from", "adb", "shell", "getprop" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/android.py#L265-L280
train
NetEaseGame/ATX
atx/drivers/android.py
AndroidDevice.type
def type(self, s, enter=False, clear=False): """Input some text, this method has been tested not very stable on some device. "Hi world" maybe spell into "H iworld" Args: - s: string (text to input), better to be unicode - enter(bool): input enter at last - ne...
python
def type(self, s, enter=False, clear=False): """Input some text, this method has been tested not very stable on some device. "Hi world" maybe spell into "H iworld" Args: - s: string (text to input), better to be unicode - enter(bool): input enter at last - ne...
[ "def", "type", "(", "self", ",", "s", ",", "enter", "=", "False", ",", "clear", "=", "False", ")", ":", "if", "clear", ":", "self", ".", "clear_text", "(", ")", "self", ".", "_uiauto", ".", "send_keys", "(", "s", ")", "if", "enter", ":", "self", ...
Input some text, this method has been tested not very stable on some device. "Hi world" maybe spell into "H iworld" Args: - s: string (text to input), better to be unicode - enter(bool): input enter at last - next(bool): perform editor action Next - clear...
[ "Input", "some", "text", "this", "method", "has", "been", "tested", "not", "very", "stable", "on", "some", "device", ".", "Hi", "world", "maybe", "spell", "into", "H", "iworld" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/android.py#L436-L461
train
NetEaseGame/ATX
atx/drivers/android.py
AndroidDevice.input_methods
def input_methods(self): """ Get all input methods Return example: ['com.sohu.inputmethod.sogou/.SogouIME', 'android.unicode.ime/.Utf7ImeService'] """ imes = [] for line in self.adb_shell(['ime', 'list', '-s', '-a']).splitlines(): line = line.strip() ...
python
def input_methods(self): """ Get all input methods Return example: ['com.sohu.inputmethod.sogou/.SogouIME', 'android.unicode.ime/.Utf7ImeService'] """ imes = [] for line in self.adb_shell(['ime', 'list', '-s', '-a']).splitlines(): line = line.strip() ...
[ "def", "input_methods", "(", "self", ")", ":", "imes", "=", "[", "]", "for", "line", "in", "self", ".", "adb_shell", "(", "[", "'ime'", ",", "'list'", ",", "'-s'", ",", "'-a'", "]", ")", ".", "splitlines", "(", ")", ":", "line", "=", "line", ".",...
Get all input methods Return example: ['com.sohu.inputmethod.sogou/.SogouIME', 'android.unicode.ime/.Utf7ImeService']
[ "Get", "all", "input", "methods" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/android.py#L473-L484
train
NetEaseGame/ATX
atx/drivers/android.py
AndroidDevice.current_ime
def current_ime(self): ''' Get current input method ''' dumpout = self.adb_shell(['dumpsys', 'input_method']) m = _INPUT_METHOD_RE.search(dumpout) if m: return m.group(1)
python
def current_ime(self): ''' Get current input method ''' dumpout = self.adb_shell(['dumpsys', 'input_method']) m = _INPUT_METHOD_RE.search(dumpout) if m: return m.group(1)
[ "def", "current_ime", "(", "self", ")", ":", "dumpout", "=", "self", ".", "adb_shell", "(", "[", "'dumpsys'", ",", "'input_method'", "]", ")", "m", "=", "_INPUT_METHOD_RE", ".", "search", "(", "dumpout", ")", "if", "m", ":", "return", "m", ".", "group"...
Get current input method
[ "Get", "current", "input", "method" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/android.py#L486-L491
train
NetEaseGame/ATX
atx/imutils.py
open_as_pillow
def open_as_pillow(filename): """ This way can delete file immediately """ with __sys_open(filename, 'rb') as f: data = BytesIO(f.read()) return Image.open(data)
python
def open_as_pillow(filename): """ This way can delete file immediately """ with __sys_open(filename, 'rb') as f: data = BytesIO(f.read()) return Image.open(data)
[ "def", "open_as_pillow", "(", "filename", ")", ":", "with", "__sys_open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "data", "=", "BytesIO", "(", "f", ".", "read", "(", ")", ")", "return", "Image", ".", "open", "(", "data", ")" ]
This way can delete file immediately
[ "This", "way", "can", "delete", "file", "immediately" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/imutils.py#L71-L75
train
NetEaseGame/ATX
atx/imutils.py
from_pillow
def from_pillow(pil_image): """ Convert from pillow image to opencv """ # convert PIL to OpenCV pil_image = pil_image.convert('RGB') cv2_image = np.array(pil_image) # Convert RGB to BGR cv2_image = cv2_image[:, :, ::-1].copy() return cv2_image
python
def from_pillow(pil_image): """ Convert from pillow image to opencv """ # convert PIL to OpenCV pil_image = pil_image.convert('RGB') cv2_image = np.array(pil_image) # Convert RGB to BGR cv2_image = cv2_image[:, :, ::-1].copy() return cv2_image
[ "def", "from_pillow", "(", "pil_image", ")", ":", "pil_image", "=", "pil_image", ".", "convert", "(", "'RGB'", ")", "cv2_image", "=", "np", ".", "array", "(", "pil_image", ")", "cv2_image", "=", "cv2_image", "[", ":", ",", ":", ",", ":", ":", "-", "1...
Convert from pillow image to opencv
[ "Convert", "from", "pillow", "image", "to", "opencv" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/imutils.py#L81-L88
train
NetEaseGame/ATX
atx/imutils.py
url_to_image
def url_to_image(url, flag=cv2.IMREAD_COLOR): """ download the image, convert it to a NumPy array, and then read it into OpenCV format """ resp = urlopen(url) image = np.asarray(bytearray(resp.read()), dtype="uint8") image = cv2.imdecode(image, flag) return image
python
def url_to_image(url, flag=cv2.IMREAD_COLOR): """ download the image, convert it to a NumPy array, and then read it into OpenCV format """ resp = urlopen(url) image = np.asarray(bytearray(resp.read()), dtype="uint8") image = cv2.imdecode(image, flag) return image
[ "def", "url_to_image", "(", "url", ",", "flag", "=", "cv2", ".", "IMREAD_COLOR", ")", ":", "resp", "=", "urlopen", "(", "url", ")", "image", "=", "np", ".", "asarray", "(", "bytearray", "(", "resp", ".", "read", "(", ")", ")", ",", "dtype", "=", ...
download the image, convert it to a NumPy array, and then read it into OpenCV format
[ "download", "the", "image", "convert", "it", "to", "a", "NumPy", "array", "and", "then", "read", "it", "into", "OpenCV", "format" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/imutils.py#L97-L103
train
NetEaseGame/ATX
atx/imutils.py
mark_point
def mark_point(img, x, y): """ Mark a point Args: - img(numpy): the source image - x, y(int): position """ overlay = img.copy() output = img.copy() alpha = 0.5 radius = max(5, min(img.shape[:2])//15) center = int(x), int(y) color = (0, 0, 255) cv2.circle(ov...
python
def mark_point(img, x, y): """ Mark a point Args: - img(numpy): the source image - x, y(int): position """ overlay = img.copy() output = img.copy() alpha = 0.5 radius = max(5, min(img.shape[:2])//15) center = int(x), int(y) color = (0, 0, 255) cv2.circle(ov...
[ "def", "mark_point", "(", "img", ",", "x", ",", "y", ")", ":", "overlay", "=", "img", ".", "copy", "(", ")", "output", "=", "img", ".", "copy", "(", ")", "alpha", "=", "0.5", "radius", "=", "max", "(", "5", ",", "min", "(", "img", ".", "shape...
Mark a point Args: - img(numpy): the source image - x, y(int): position
[ "Mark", "a", "point" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/imutils.py#L139-L157
train
NetEaseGame/ATX
atx/drivers/ios_webdriveragent.py
IOSDevice.display
def display(self): """ Get screen width and height """ w, h = self.session.window_size() return Display(w*self.scale, h*self.scale)
python
def display(self): """ Get screen width and height """ w, h = self.session.window_size() return Display(w*self.scale, h*self.scale)
[ "def", "display", "(", "self", ")", ":", "w", ",", "h", "=", "self", ".", "session", ".", "window_size", "(", ")", "return", "Display", "(", "w", "*", "self", ".", "scale", ",", "h", "*", "self", ".", "scale", ")" ]
Get screen width and height
[ "Get", "screen", "width", "and", "height" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/drivers/ios_webdriveragent.py#L99-L102
train
NetEaseGame/ATX
scripts/adb_old.py
Adb.forward
def forward(self, device_port, local_port=None): '''adb port forward. return local_port''' if local_port is None: for s, lp, rp in self.forward_list(): if s == self.device_serial() and rp == 'tcp:%d' % device_port: return int(lp[4:]) return sel...
python
def forward(self, device_port, local_port=None): '''adb port forward. return local_port''' if local_port is None: for s, lp, rp in self.forward_list(): if s == self.device_serial() and rp == 'tcp:%d' % device_port: return int(lp[4:]) return sel...
[ "def", "forward", "(", "self", ",", "device_port", ",", "local_port", "=", "None", ")", ":", "if", "local_port", "is", "None", ":", "for", "s", ",", "lp", ",", "rp", "in", "self", ".", "forward_list", "(", ")", ":", "if", "s", "==", "self", ".", ...
adb port forward. return local_port
[ "adb", "port", "forward", ".", "return", "local_port" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/scripts/adb_old.py#L178-L187
train
NetEaseGame/ATX
atx/record/android.py
touch2screen
def touch2screen(w, h, o, x, y): '''convert touch position''' if o == 0: return x, y elif o == 1: # landscape-right return y, w-x elif o == 2: # upsidedown return w-x, h-y elif o == 3: # landscape-left return h-y, x return x, y
python
def touch2screen(w, h, o, x, y): '''convert touch position''' if o == 0: return x, y elif o == 1: # landscape-right return y, w-x elif o == 2: # upsidedown return w-x, h-y elif o == 3: # landscape-left return h-y, x return x, y
[ "def", "touch2screen", "(", "w", ",", "h", ",", "o", ",", "x", ",", "y", ")", ":", "if", "o", "==", "0", ":", "return", "x", ",", "y", "elif", "o", "==", "1", ":", "return", "y", ",", "w", "-", "x", "elif", "o", "==", "2", ":", "return", ...
convert touch position
[ "convert", "touch", "position" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/record/android.py#L342-L352
train
NetEaseGame/ATX
atx/ext/report/__init__.py
Report.patch_wda
def patch_wda(self): """ Record steps of WebDriverAgent """ import wda def _click(that): rawx, rawy = that.bounds.center x, y = self.d.scale*rawx, self.d.scale*rawy screen_before = self._save_screenshot() orig_click = pt.get_origin...
python
def patch_wda(self): """ Record steps of WebDriverAgent """ import wda def _click(that): rawx, rawy = that.bounds.center x, y = self.d.scale*rawx, self.d.scale*rawy screen_before = self._save_screenshot() orig_click = pt.get_origin...
[ "def", "patch_wda", "(", "self", ")", ":", "import", "wda", "def", "_click", "(", "that", ")", ":", "rawx", ",", "rawy", "=", "that", ".", "bounds", ".", "center", "x", ",", "y", "=", "self", ".", "d", ".", "scale", "*", "rawx", ",", "self", "....
Record steps of WebDriverAgent
[ "Record", "steps", "of", "WebDriverAgent" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/ext/report/__init__.py#L109-L127
train
NetEaseGame/ATX
atx/ext/report/__init__.py
Report._take_screenshot
def _take_screenshot(self, screenshot=False, name_prefix='unknown'): """ This is different from _save_screenshot. The return value maybe None or the screenshot path Args: screenshot: bool or PIL image """ if isinstance(screenshot, bool): if not sc...
python
def _take_screenshot(self, screenshot=False, name_prefix='unknown'): """ This is different from _save_screenshot. The return value maybe None or the screenshot path Args: screenshot: bool or PIL image """ if isinstance(screenshot, bool): if not sc...
[ "def", "_take_screenshot", "(", "self", ",", "screenshot", "=", "False", ",", "name_prefix", "=", "'unknown'", ")", ":", "if", "isinstance", "(", "screenshot", ",", "bool", ")", ":", "if", "not", "screenshot", ":", "return", "return", "self", ".", "_save_s...
This is different from _save_screenshot. The return value maybe None or the screenshot path Args: screenshot: bool or PIL image
[ "This", "is", "different", "from", "_save_screenshot", ".", "The", "return", "value", "maybe", "None", "or", "the", "screenshot", "path" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/ext/report/__init__.py#L223-L238
train
NetEaseGame/ATX
atx/ext/report/__init__.py
Report._add_assert
def _add_assert(self, **kwargs): """ if screenshot is None, only failed case will take screenshot """ # convert screenshot to relative path from <None|True|False|PIL.Image> screenshot = kwargs.get('screenshot') is_success = kwargs.get('success') screenshot = (not ...
python
def _add_assert(self, **kwargs): """ if screenshot is None, only failed case will take screenshot """ # convert screenshot to relative path from <None|True|False|PIL.Image> screenshot = kwargs.get('screenshot') is_success = kwargs.get('success') screenshot = (not ...
[ "def", "_add_assert", "(", "self", ",", "**", "kwargs", ")", ":", "screenshot", "=", "kwargs", ".", "get", "(", "'screenshot'", ")", "is_success", "=", "kwargs", ".", "get", "(", "'success'", ")", "screenshot", "=", "(", "not", "is_success", ")", "if", ...
if screenshot is None, only failed case will take screenshot
[ "if", "screenshot", "is", "None", "only", "failed", "case", "will", "take", "screenshot" ]
f4415c57b45cb0730e08899cbc92a2af1c047ffb
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/ext/report/__init__.py#L251-L267
train
Phylliade/ikpy
src/ikpy/plot_utils.py
plot_chain
def plot_chain(chain, joints, ax, target=None, show=False): """Plots the chain""" # LIst of nodes and orientations nodes = [] axes = [] transformation_matrixes = chain.forward_kinematics(joints, full_kinematics=True) # Get the nodes and the orientation from the tranformation matrix for (in...
python
def plot_chain(chain, joints, ax, target=None, show=False): """Plots the chain""" # LIst of nodes and orientations nodes = [] axes = [] transformation_matrixes = chain.forward_kinematics(joints, full_kinematics=True) # Get the nodes and the orientation from the tranformation matrix for (in...
[ "def", "plot_chain", "(", "chain", ",", "joints", ",", "ax", ",", "target", "=", "None", ",", "show", "=", "False", ")", ":", "nodes", "=", "[", "]", "axes", "=", "[", "]", "transformation_matrixes", "=", "chain", ".", "forward_kinematics", "(", "joint...
Plots the chain
[ "Plots", "the", "chain" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/plot_utils.py#L29-L54
train
Phylliade/ikpy
src/ikpy/plot_utils.py
plot_target
def plot_target(target, ax): """Ajoute la target au plot""" ax.scatter(target[0], target[1], target[2], c="red", s=80)
python
def plot_target(target, ax): """Ajoute la target au plot""" ax.scatter(target[0], target[1], target[2], c="red", s=80)
[ "def", "plot_target", "(", "target", ",", "ax", ")", ":", "ax", ".", "scatter", "(", "target", "[", "0", "]", ",", "target", "[", "1", "]", ",", "target", "[", "2", "]", ",", "c", "=", "\"red\"", ",", "s", "=", "80", ")" ]
Ajoute la target au plot
[ "Ajoute", "la", "target", "au", "plot" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/plot_utils.py#L57-L59
train
Phylliade/ikpy
src/ikpy/geometry_utils.py
Rx_matrix
def Rx_matrix(theta): """Rotation matrix around the X axis""" return np.array([ [1, 0, 0], [0, np.cos(theta), -np.sin(theta)], [0, np.sin(theta), np.cos(theta)] ])
python
def Rx_matrix(theta): """Rotation matrix around the X axis""" return np.array([ [1, 0, 0], [0, np.cos(theta), -np.sin(theta)], [0, np.sin(theta), np.cos(theta)] ])
[ "def", "Rx_matrix", "(", "theta", ")", ":", "return", "np", ".", "array", "(", "[", "[", "1", ",", "0", ",", "0", "]", ",", "[", "0", ",", "np", ".", "cos", "(", "theta", ")", ",", "-", "np", ".", "sin", "(", "theta", ")", "]", ",", "[", ...
Rotation matrix around the X axis
[ "Rotation", "matrix", "around", "the", "X", "axis" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/geometry_utils.py#L10-L16
train
Phylliade/ikpy
src/ikpy/geometry_utils.py
Rz_matrix
def Rz_matrix(theta): """Rotation matrix around the Z axis""" return np.array([ [np.cos(theta), -np.sin(theta), 0], [np.sin(theta), np.cos(theta), 0], [0, 0, 1] ])
python
def Rz_matrix(theta): """Rotation matrix around the Z axis""" return np.array([ [np.cos(theta), -np.sin(theta), 0], [np.sin(theta), np.cos(theta), 0], [0, 0, 1] ])
[ "def", "Rz_matrix", "(", "theta", ")", ":", "return", "np", ".", "array", "(", "[", "[", "np", ".", "cos", "(", "theta", ")", ",", "-", "np", ".", "sin", "(", "theta", ")", ",", "0", "]", ",", "[", "np", ".", "sin", "(", "theta", ")", ",", ...
Rotation matrix around the Z axis
[ "Rotation", "matrix", "around", "the", "Z", "axis" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/geometry_utils.py#L19-L25
train
Phylliade/ikpy
src/ikpy/geometry_utils.py
symbolic_Rz_matrix
def symbolic_Rz_matrix(symbolic_theta): """Matrice symbolique de rotation autour de l'axe Z""" return sympy.Matrix([ [sympy.cos(symbolic_theta), -sympy.sin(symbolic_theta), 0], [sympy.sin(symbolic_theta), sympy.cos(symbolic_theta), 0], [0, 0, 1] ])
python
def symbolic_Rz_matrix(symbolic_theta): """Matrice symbolique de rotation autour de l'axe Z""" return sympy.Matrix([ [sympy.cos(symbolic_theta), -sympy.sin(symbolic_theta), 0], [sympy.sin(symbolic_theta), sympy.cos(symbolic_theta), 0], [0, 0, 1] ])
[ "def", "symbolic_Rz_matrix", "(", "symbolic_theta", ")", ":", "return", "sympy", ".", "Matrix", "(", "[", "[", "sympy", ".", "cos", "(", "symbolic_theta", ")", ",", "-", "sympy", ".", "sin", "(", "symbolic_theta", ")", ",", "0", "]", ",", "[", "sympy",...
Matrice symbolique de rotation autour de l'axe Z
[ "Matrice", "symbolique", "de", "rotation", "autour", "de", "l", "axe", "Z" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/geometry_utils.py#L28-L34
train
Phylliade/ikpy
src/ikpy/geometry_utils.py
Ry_matrix
def Ry_matrix(theta): """Rotation matrix around the Y axis""" return np.array([ [np.cos(theta), 0, np.sin(theta)], [0, 1, 0], [-np.sin(theta), 0, np.cos(theta)] ])
python
def Ry_matrix(theta): """Rotation matrix around the Y axis""" return np.array([ [np.cos(theta), 0, np.sin(theta)], [0, 1, 0], [-np.sin(theta), 0, np.cos(theta)] ])
[ "def", "Ry_matrix", "(", "theta", ")", ":", "return", "np", ".", "array", "(", "[", "[", "np", ".", "cos", "(", "theta", ")", ",", "0", ",", "np", ".", "sin", "(", "theta", ")", "]", ",", "[", "0", ",", "1", ",", "0", "]", ",", "[", "-", ...
Rotation matrix around the Y axis
[ "Rotation", "matrix", "around", "the", "Y", "axis" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/geometry_utils.py#L37-L43
train
Phylliade/ikpy
src/ikpy/geometry_utils.py
rpy_matrix
def rpy_matrix(roll, pitch, yaw): """Returns a rotation matrix described by the extrinsinc roll, pitch, yaw coordinates""" return np.dot(Rz_matrix(yaw), np.dot(Ry_matrix(pitch), Rx_matrix(roll)))
python
def rpy_matrix(roll, pitch, yaw): """Returns a rotation matrix described by the extrinsinc roll, pitch, yaw coordinates""" return np.dot(Rz_matrix(yaw), np.dot(Ry_matrix(pitch), Rx_matrix(roll)))
[ "def", "rpy_matrix", "(", "roll", ",", "pitch", ",", "yaw", ")", ":", "return", "np", ".", "dot", "(", "Rz_matrix", "(", "yaw", ")", ",", "np", ".", "dot", "(", "Ry_matrix", "(", "pitch", ")", ",", "Rx_matrix", "(", "roll", ")", ")", ")" ]
Returns a rotation matrix described by the extrinsinc roll, pitch, yaw coordinates
[ "Returns", "a", "rotation", "matrix", "described", "by", "the", "extrinsinc", "roll", "pitch", "yaw", "coordinates" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/geometry_utils.py#L56-L58
train
Phylliade/ikpy
src/ikpy/geometry_utils.py
cartesian_to_homogeneous
def cartesian_to_homogeneous(cartesian_matrix, matrix_type="numpy"): """Converts a cartesian matrix to an homogenous matrix""" dimension_x, dimension_y = cartesian_matrix.shape # Square matrix # Manage different types fo input matrixes if matrix_type == "numpy": homogeneous_matrix = np.eye(d...
python
def cartesian_to_homogeneous(cartesian_matrix, matrix_type="numpy"): """Converts a cartesian matrix to an homogenous matrix""" dimension_x, dimension_y = cartesian_matrix.shape # Square matrix # Manage different types fo input matrixes if matrix_type == "numpy": homogeneous_matrix = np.eye(d...
[ "def", "cartesian_to_homogeneous", "(", "cartesian_matrix", ",", "matrix_type", "=", "\"numpy\"", ")", ":", "dimension_x", ",", "dimension_y", "=", "cartesian_matrix", ".", "shape", "if", "matrix_type", "==", "\"numpy\"", ":", "homogeneous_matrix", "=", "np", ".", ...
Converts a cartesian matrix to an homogenous matrix
[ "Converts", "a", "cartesian", "matrix", "to", "an", "homogenous", "matrix" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/geometry_utils.py#L112-L124
train
Phylliade/ikpy
src/ikpy/geometry_utils.py
cartesian_to_homogeneous_vectors
def cartesian_to_homogeneous_vectors(cartesian_vector, matrix_type="numpy"): """Converts a cartesian vector to an homogenous vector""" dimension_x = cartesian_vector.shape[0] # Vector if matrix_type == "numpy": homogeneous_vector = np.zeros(dimension_x + 1) # Last item is a 1 hom...
python
def cartesian_to_homogeneous_vectors(cartesian_vector, matrix_type="numpy"): """Converts a cartesian vector to an homogenous vector""" dimension_x = cartesian_vector.shape[0] # Vector if matrix_type == "numpy": homogeneous_vector = np.zeros(dimension_x + 1) # Last item is a 1 hom...
[ "def", "cartesian_to_homogeneous_vectors", "(", "cartesian_vector", ",", "matrix_type", "=", "\"numpy\"", ")", ":", "dimension_x", "=", "cartesian_vector", ".", "shape", "[", "0", "]", "if", "matrix_type", "==", "\"numpy\"", ":", "homogeneous_vector", "=", "np", "...
Converts a cartesian vector to an homogenous vector
[ "Converts", "a", "cartesian", "vector", "to", "an", "homogenous", "vector" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/geometry_utils.py#L127-L136
train
Phylliade/ikpy
src/ikpy/URDF_utils.py
find_next_joint
def find_next_joint(root, current_link, next_joint_name): """ Find the next joint in the URDF tree Parameters ---------- root current_link: xml.etree.ElementTree The current URDF link next_joint_name: str Optional : The name of the next joint. If not provided, find it automa...
python
def find_next_joint(root, current_link, next_joint_name): """ Find the next joint in the URDF tree Parameters ---------- root current_link: xml.etree.ElementTree The current URDF link next_joint_name: str Optional : The name of the next joint. If not provided, find it automa...
[ "def", "find_next_joint", "(", "root", ",", "current_link", ",", "next_joint_name", ")", ":", "has_next", "=", "False", "next_joint", "=", "None", "search_by_name", "=", "True", "current_link_name", "=", "None", "if", "next_joint_name", "is", "None", ":", "searc...
Find the next joint in the URDF tree Parameters ---------- root current_link: xml.etree.ElementTree The current URDF link next_joint_name: str Optional : The name of the next joint. If not provided, find it automatically as the first child of the link.
[ "Find", "the", "next", "joint", "in", "the", "URDF", "tree" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/URDF_utils.py#L16-L55
train
Phylliade/ikpy
src/ikpy/URDF_utils.py
find_next_link
def find_next_link(root, current_joint, next_link_name): """ Find the next link in the URDF tree Parameters ---------- root current_joint: xml.etree.ElementTree The current URDF joint next_link_name: str Optional : The name of the next link. If not provided, find it automati...
python
def find_next_link(root, current_joint, next_link_name): """ Find the next link in the URDF tree Parameters ---------- root current_joint: xml.etree.ElementTree The current URDF joint next_link_name: str Optional : The name of the next link. If not provided, find it automati...
[ "def", "find_next_link", "(", "root", ",", "current_joint", ",", "next_link_name", ")", ":", "has_next", "=", "False", "next_link", "=", "None", "if", "next_link_name", "is", "None", ":", "next_link_name", "=", "current_joint", ".", "find", "(", "\"child\"", "...
Find the next link in the URDF tree Parameters ---------- root current_joint: xml.etree.ElementTree The current URDF joint next_link_name: str Optional : The name of the next link. If not provided, find it automatically as the first child of the joint.
[ "Find", "the", "next", "link", "in", "the", "URDF", "tree" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/URDF_utils.py#L58-L82
train
Phylliade/ikpy
src/ikpy/URDF_utils.py
get_urdf_parameters
def get_urdf_parameters(urdf_file, base_elements=None, last_link_vector=None, base_element_type="link"): """ Returns translated parameters from the given URDF file Parameters ---------- urdf_file: str The path of the URDF file base_elements: list of strings List of the links beg...
python
def get_urdf_parameters(urdf_file, base_elements=None, last_link_vector=None, base_element_type="link"): """ Returns translated parameters from the given URDF file Parameters ---------- urdf_file: str The path of the URDF file base_elements: list of strings List of the links beg...
[ "def", "get_urdf_parameters", "(", "urdf_file", ",", "base_elements", "=", "None", ",", "last_link_vector", "=", "None", ",", "base_element_type", "=", "\"link\"", ")", ":", "tree", "=", "ET", ".", "parse", "(", "urdf_file", ")", "root", "=", "tree", ".", ...
Returns translated parameters from the given URDF file Parameters ---------- urdf_file: str The path of the URDF file base_elements: list of strings List of the links beginning the chain last_link_vector: numpy.array Optional : The translation vector of the tip. base_ele...
[ "Returns", "translated", "parameters", "from", "the", "given", "URDF", "file" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/URDF_utils.py#L103-L210
train
Phylliade/ikpy
src/ikpy/URDF_utils.py
_convert_angle_limit
def _convert_angle_limit(angle, joint, **kwargs): """Converts the limit angle of the PyPot JSON file to the internal format""" angle_pypot = angle # No need to take care of orientation if joint["orientation"] == "indirect": angle_pypot = 1 * angle_pypot # angle_pypot = angle_pypot + offset...
python
def _convert_angle_limit(angle, joint, **kwargs): """Converts the limit angle of the PyPot JSON file to the internal format""" angle_pypot = angle # No need to take care of orientation if joint["orientation"] == "indirect": angle_pypot = 1 * angle_pypot # angle_pypot = angle_pypot + offset...
[ "def", "_convert_angle_limit", "(", "angle", ",", "joint", ",", "**", "kwargs", ")", ":", "angle_pypot", "=", "angle", "if", "joint", "[", "\"orientation\"", "]", "==", "\"indirect\"", ":", "angle_pypot", "=", "1", "*", "angle_pypot", "return", "angle_pypot", ...
Converts the limit angle of the PyPot JSON file to the internal format
[ "Converts", "the", "limit", "angle", "of", "the", "PyPot", "JSON", "file", "to", "the", "internal", "format" ]
60e36d6163136942bf520d952db17123c658d0b6
https://github.com/Phylliade/ikpy/blob/60e36d6163136942bf520d952db17123c658d0b6/src/ikpy/URDF_utils.py#L261-L271
train