idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
57,700
def finalize_path ( self , path_num = None ) : for c in self . consumers : c . finalize_path ( path_num ) self . result = [ c . result for c in self . consumers ]
finalize path and populate result for ConsumerConsumer
57,701
def finalize ( self ) : for c in self . consumers : c . finalize ( ) self . result = [ c . result for c in self . consumers ]
finalize for ConsumerConsumer
57,702
def get ( self , queue_get ) : for ( c , cs ) in izip ( self . consumers , queue_get ) : c . get ( cs ) self . result = [ c . result for c in self . consumers ]
get to given consumer states . This function is used for merging of results of parallelized MC . The first state is used for merging in place . The states must be disjoint .
57,703
def finalize ( self ) : super ( TransposedConsumer , self ) . finalize ( ) self . result = map ( list , zip ( * self . result ) )
finalize for PathConsumer
57,704
def _get_attribute ( self , offset ) : attr_type = self . get_uint_le ( offset ) length = self . get_uint_le ( offset + 0x04 ) data = self . get_chunk ( offset , length ) return MftAttr . factory ( attr_type , data )
Determines attribute type at the offset and returns \ initialized attribute object .
57,705
def find_in_matrix_2d ( val , matrix ) : dim = len ( matrix [ 0 ] ) item_index = 0 for row in matrix : for i in row : if i == val : break item_index += 1 if i == val : break loc = ( int ( item_index / dim ) , item_index % dim ) return loc
Returns a tuple representing the index of an item in a 2D matrix .
57,706
def compute_distance ( a , b ) : if not a : return len ( b ) if not b : return len ( a ) if a == b or str . lower ( a ) == str . lower ( b ) : return 0 a = str . lower ( a ) b = str . lower ( b ) vector_1 = [ - 1 ] * ( len ( b ) + 1 ) vector_2 = [ - 1 ] * ( len ( b ) + 1 ) for i in range ( len ( vector_1 ) ) : vector_1 [ i ] = i for i in range ( len ( a ) ) : vector_2 [ 0 ] = i + 1 for j in range ( len ( b ) ) : penalty = 0 if a [ i ] == b [ j ] else compute_qwerty_distance ( a [ i ] , b [ j ] ) vector_2 [ j + 1 ] = min ( vector_2 [ j ] + 1 , vector_1 [ j + 1 ] + 1 , vector_1 [ j ] + penalty ) for j in range ( len ( vector_1 ) ) : vector_1 [ j ] = vector_2 [ j ] return vector_2 [ len ( b ) ]
Computes a modified Levenshtein distance between two strings comparing the lowercase versions of each string and accounting for QWERTY distance .
57,707
def get_defaults ( path ) : defaults = { } if os . path . isfile ( path ) : with open ( path ) as f : for line in f : line = line . strip ( ) if '=' not in line or line . startswith ( '#' ) : continue k , v = line . split ( '=' , 1 ) v = v . strip ( '"' ) . strip ( "'" ) defaults [ k ] = v return defaults else : return { }
Reads file for configuration defaults .
57,708
def get_license ( name ) : filenames = os . listdir ( cwd + licenses_loc ) licenses = dict ( zip ( filenames , [ - 1 ] * len ( filenames ) ) ) for l in licenses : licenses [ l ] = compute_distance ( name , l ) return min ( licenses , key = ( lambda k : licenses [ k ] ) )
Returns the closest match to the requested license .
57,709
def get_args ( path ) : defaults = get_defaults ( path ) licenses = ', ' . join ( os . listdir ( cwd + licenses_loc ) ) p = parser ( description = 'tool for adding open source licenses to your projects. available licenses: %s' % licenses ) _name = False if defaults . get ( 'name' ) else True _email = False if defaults . get ( 'email' ) else True _license = False if defaults . get ( 'license' ) else True p . add_argument ( '-n' , dest = 'name' , required = _name , help = 'name' ) p . add_argument ( '-e' , dest = 'email' , required = _email , help = 'email' ) p . add_argument ( '-l' , dest = 'license' , required = _license , help = 'license' ) p . add_argument ( '-p' , dest = 'project' , required = False , help = 'project' ) p . add_argument ( '-v' , '--version' , action = 'version' , version = '%(prog)s {version}' . format ( version = version ) ) p . add_argument ( '--txt' , action = 'store_true' , required = False , help = 'add .txt to filename' ) args = p . parse_args ( ) name = args . name if args . name else defaults . get ( 'name' ) email = args . email if args . email else defaults . get ( 'email' ) license = get_license ( args . license ) if args . license else defaults . get ( 'license' ) project = args . project if args . project else os . getcwd ( ) . split ( '/' ) [ - 1 ] ext = '.txt' if args . txt else '' year = str ( date . today ( ) . year ) return ( name , email , license , project , ext , year )
Parse command line args & override defaults .
57,710
def generate_license ( args ) : with open ( cwd + licenses_loc + args [ 2 ] ) as f : license = f . read ( ) license = license . format ( name = args [ 0 ] , email = args [ 1 ] , license = args [ 2 ] , project = args [ 3 ] , year = args [ 5 ] ) with open ( 'LICENSE' + args [ 4 ] , 'w' ) as f : f . write ( license ) print ( 'licenser: license file added to current directory' )
Creates a LICENSE or LICENSE . txt file in the current directory . Reads from the assets folder and looks for placeholders enclosed in curly braces .
57,711
def parse ( self ) : data = json . loads ( sys . argv [ 1 ] ) self . config_path = self . decode ( data [ 'config_path' ] ) self . subject = self . decode ( data [ 'subject' ] ) self . text = self . decode ( data [ 'text' ] ) self . html = self . decode ( data [ 'html' ] ) self . send_as_one = data [ 'send_as_one' ] if 'files' in data : self . parse_files ( data [ 'files' ] ) self . ccs = data [ 'ccs' ] self . addresses = data [ 'addresses' ] if not self . addresses : raise ValueError ( 'Atleast one email address is required to send an email' )
parses args json
57,712
def construct_message ( self , email = None ) : self . multipart [ 'Subject' ] = self . subject self . multipart [ 'From' ] = self . config [ 'EMAIL' ] self . multipart [ 'Date' ] = formatdate ( localtime = True ) if email is None and self . send_as_one : self . multipart [ 'To' ] = ", " . join ( self . addresses ) elif email is not None and self . send_as_one is False : self . multipart [ 'To' ] = email if self . ccs is not None and self . ccs : self . multipart [ 'Cc' ] = ", " . join ( self . ccs ) html = MIMEText ( self . html , 'html' ) alt_text = MIMEText ( self . text , 'plain' ) self . multipart . attach ( html ) self . multipart . attach ( alt_text ) for file in self . files : self . multipart . attach ( file )
construct the email message
57,713
def send ( self , email = None ) : if email is None and self . send_as_one : self . smtp . send_message ( self . multipart , self . config [ 'EMAIL' ] , self . addresses ) elif email is not None and self . send_as_one is False : self . smtp . send_message ( self . multipart , self . config [ 'EMAIL' ] , email ) self . multipart = MIMEMultipart ( 'alternative' )
send email message
57,714
def create_email ( self ) : self . connect ( ) if self . send_as_one : self . construct_message ( ) self . send ( ) elif self . send_as_one is False : for email in self . addresses : self . construct_message ( email ) self . send ( email ) self . disconnect ( )
main function to construct and send email
57,715
def get_definition ( query ) : try : return get_definition_api ( query ) except : raise import json payload = { 'q' : query , 'limit' : 200 , 'includeRelated' : 'true' , 'sourceDictionaries' : 'all' , 'useCanonical' : 'false' , 'includeTags' : 'false' , 'api_key' : 'a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5' } url = 'http://api.wordnik.com:80/v4/word.json/%s/definitions' % query r = requests . get ( url , params = payload ) result = json . loads ( r . text ) return result
Returns dictionary of id first names of people who posted on my wall between start and end time
57,716
def intversion ( text = None ) : try : s = text if not s : s = version ( ) s = s . split ( 'ubuntu' ) [ 0 ] s = s . split ( ':' ) [ - 1 ] s = s . split ( '+' ) [ 0 ] if s . startswith ( '00' ) : i = int ( s [ 0 : 4 ] ) elif '.' in s : ls = s . split ( '.' ) ls += [ 0 , 0 , 0 ] i = int ( ls [ 0 ] ) * 100 + int ( ls [ 1 ] ) * 10 + int ( ls [ 2 ] ) except ValueError : print ( 'Can not parse version: %s' % text ) raise return i
return version as int .
57,717
def set_current_session ( session_id ) -> bool : try : g . session_id = session_id return True except ( Exception , BaseException ) as error : if current_app . config [ 'DEBUG' ] : print ( error ) return False
Add session_id to flask globals for current request
57,718
def visit_member ( self , attribute_key , attribute , member_node , member_data , is_link_node , parent_data , index = None ) : raise NotImplementedError ( 'Abstract method.' )
Visits a member node in a resource data tree .
57,719
def get_relationship ( self , attribute ) : rel = self . __relationships . get ( attribute . entity_attr ) if rel is None : rel = LazyDomainRelationship ( self , attribute , direction = self . relationship_direction ) self . __relationships [ attribute . entity_attr ] = rel return rel
Returns the domain relationship object for the given resource attribute .
57,720
def simple_notification ( connection , queue_name , exchange_name , routing_key , text_body ) : channel = connection . channel ( ) try : channel . queue_declare ( queue_name , durable = True , exclusive = False , auto_delete = False ) except PreconditionFailed : pass try : channel . exchange_declare ( exchange_name , type = "fanout" , durable = True , auto_delete = False ) except PreconditionFailed : pass channel . queue_bind ( queue_name , exchange_name , routing_key = routing_key ) message = Message ( text_body ) channel . basic_publish ( message , exchange_name , routing_key )
Publishes a simple notification .
57,721
def get_url ( self , url_or_dict ) : if isinstance ( url_or_dict , basestring ) : url_or_dict = { 'viewname' : url_or_dict } try : return reverse ( ** url_or_dict ) except NoReverseMatch : if MENU_DEBUG : print >> stderr , 'Unable to reverse URL with kwargs %s' % url_or_dict
Returns the reversed url given a string or dict and prints errors if MENU_DEBUG is enabled
57,722
def get_time ( self ) : if isinstance ( self . path , pathlib . Path ) : thetime = self . path . stat ( ) . st_mtime else : thetime = np . nan return thetime
Time of the TIFF file
57,723
def verify ( path ) : valid = False try : tf = SingleTifHolo . _get_tif ( path ) except ( ValueError , IsADirectoryError ) : pass else : if len ( tf ) == 1 : valid = True return valid
Verify that path is a valid TIFF file
57,724
def add ( entry_point , all_entry_points , auto_write , scripts_path ) : click . echo ( ) if not entry_point and not all_entry_points : raise click . UsageError ( 'Missing required option: --entry_point or --all_entry_points' ) if not os . path . exists ( 'setup.py' ) : raise click . UsageError ( 'No setup.py found.' ) setup_data = parse_setup ( 'setup.py' ) console_scripts = get_console_scripts ( setup_data ) scripts = [ ] if all_entry_points and console_scripts : for entry in console_scripts : if not entry . startswith ( 'py' ) : click . echo ( 'Your python entry_points must start with py.' ) click . echo ( 'Found: ' + entry ) raise click . Abort ( ) for entry in console_scripts : click . echo ( 'Found entry_point: ' + entry ) py_entry_point = entry entry_point = entry [ 2 : ] more_scripts = copy_templates ( entry_point , py_entry_point , auto_write , scripts_path ) for script in more_scripts : click . echo ( ' Created ' + script ) scripts . extend ( more_scripts ) elif entry_point : if not entry_point . startswith ( 'py' ) : click . echo ( 'Your python entry_points must start with py.' ) raise click . Abort ( ) if entry_point not in console_scripts : click . echo ( entry_point + ' not found in your setups entry_points' ) click . echo ( 'You will need to add it afterward if you continue...' ) click . echo ( '' ) click . confirm ( 'Do you want to continue?' , abort = True ) click . echo ( '\nCreating scripts for: ' + entry_point ) py_entry_point = entry_point entry_point = entry_point [ 2 : ] more_scripts = copy_templates ( entry_point , py_entry_point , auto_write , scripts_path ) for script in more_scripts : click . echo ( ' Created ' + script ) scripts . extend ( more_scripts ) click . echo ( '\n\nAdd the following section to your package setup:\n' ) click . echo ( 'scripts=[' ) for script in scripts : click . echo ( " '{}'," . format ( script ) ) click . echo ( '],' )
Add Scrim scripts for a python project
57,725
async def songs ( self ) : items = [ ] for i in await self . items : if i . type == 'Audio' : items . append ( i ) elif hasattr ( i , 'songs' ) : items . extend ( await i . songs ) return items
list of songs in the playlist
57,726
async def add_items ( self , * items ) : items = [ item . id for item in await self . process ( items ) ] if not items : return await self . connector . post ( 'Playlists/{Id}/Items' . format ( Id = self . id ) , data = { 'Ids' : ',' . join ( items ) } , remote = False )
append items to the playlist
57,727
async def remove_items ( self , * items ) : items = [ i . id for i in ( await self . process ( items ) ) if i in self . items ] if not items : return await self . connector . delete ( 'Playlists/{Id}/Items' . format ( Id = self . id ) , EntryIds = ',' . join ( items ) , remote = False )
remove items from the playlist
57,728
async def movies ( self ) : items = [ ] for i in await self . items : if i . type == 'Movie' : items . append ( i ) elif hasattr ( i , 'movies' ) : items . extend ( await i . movies ) return items
list of movies in the collection
57,729
async def series ( self ) : items = [ ] for i in await self . items : if i . type == 'Series' : items . append ( i ) elif hasattr ( i , 'series' ) : items . extend ( await i . series ) return items
list of series in the collection
57,730
def save ( self , * args , ** kwargs ) : if not self . target : self . target = str ( self . content_object ) if not self . actor_name : self . actor_name = str ( self . actor ) super ( Activity , self ) . save ( )
Store a string representation of content_object as target and actor name for fast retrieval and sorting .
57,731
def version_from_frame ( frame ) : module = getmodule ( frame ) if module is None : s = "<unknown from {0}:{1}>" return s . format ( frame . f_code . co_filename , frame . f_lineno ) module_name = module . __name__ variable = "AUTOVERSION_{}" . format ( module_name . upper ( ) ) override = os . environ . get ( variable , None ) if override is not None : return override while True : try : get_distribution ( module_name ) except DistributionNotFound : module_name , dot , _ = module_name . partition ( "." ) if dot == "" : break else : return getversion ( module_name ) return None
Given a frame obtain the version number of the module running there .
57,732
def try_fix_num ( n ) : if not n . isdigit ( ) : return n if n . startswith ( "0" ) : n = n . lstrip ( "0" ) if not n : n = "0" return int ( n )
Return n as an integer if it is numeric otherwise return the input
57,733
def tupleize_version ( version ) : if version is None : return ( ( "unknown" , ) , ) if version . startswith ( "<unknown" ) : return ( ( "unknown" , ) , ) split = re . split ( "(?:\.|(-))" , version ) parsed = tuple ( try_fix_num ( x ) for x in split if x ) def is_dash ( s ) : return s == "-" grouped = groupby ( parsed , is_dash ) return tuple ( tuple ( group ) for dash , group in grouped if not dash )
Split version into a lexicographically comparable tuple .
57,734
def get_version ( cls , path , memo = { } ) : if path not in memo : memo [ path ] = subprocess . check_output ( "git describe --tags --dirty 2> /dev/null" , shell = True , cwd = path ) . strip ( ) . decode ( "utf-8" ) v = re . search ( "-[0-9]+-" , memo [ path ] ) if v is not None : branch = r"-{0}-\1-" . format ( cls . get_branch ( path ) ) ( memo [ path ] , _ ) = re . subn ( "-([0-9]+)-" , branch , memo [ path ] , 1 ) return memo [ path ]
Return a string describing the version of the repository at path if possible otherwise throws subprocess . CalledProcessError .
57,735
def is_repo_instance ( cls , path ) : try : cls . get_version ( path ) return True except subprocess . CalledProcessError : return False except OSError : return False
Return True if path is a source controlled repository .
57,736
def _sort_modules ( mods ) : def compare ( x , y ) : x = x [ 1 ] y = y [ 1 ] if x == y : return 0 if y . stem == "__init__.py" : return 1 if x . stem == "__init__.py" or x < y : return - 1 return 1 return sorted ( mods , key = cmp_to_key ( compare ) )
Always sort index or README as first filename in list .
57,737
def refs_section ( doc ) : lines = [ ] if "References" in doc and len ( doc [ "References" ] ) > 0 : for ref in doc [ "References" ] : ref_num = re . findall ( "\[([0-9]+)\]" , ref ) [ 0 ] ref_body = " " . join ( ref . split ( " " ) [ 2 : ] ) lines . append ( f"[^{ref_num}]: {ref_body}" + "\n\n" ) return lines
Generate a References section .
57,738
def examples_section ( doc , header_level ) : lines = [ ] if "Examples" in doc and len ( doc [ "Examples" ] ) > 0 : lines . append ( f"{'#'*(header_level+1)} Examples \n" ) egs = "\n" . join ( doc [ "Examples" ] ) lines += mangle_examples ( doc [ "Examples" ] ) return lines
Generate markdown for Examples section .
57,739
def returns_section ( thing , doc , header_level ) : lines = [ ] return_type = None try : return_type = thing . __annotations__ [ "return" ] except AttributeError : try : return_type = thing . fget . __annotations__ [ "return" ] except : pass except KeyError : pass if return_type is None : return_type = "" else : try : return_type = ( f"{return_type.__name__}" if return_type . __module__ == "builtins" else f"{return_type.__module__}.{return_type.__name__}" ) except AttributeError : return_type = str ( return_type ) try : if "Returns" in doc and len ( doc [ "Returns" ] ) > 0 or return_type != "" : lines . append ( f"{'#'*(header_level+1)} Returns\n" ) if return_type != "" and len ( doc [ "Returns" ] ) == 1 : name , typ , desc = doc [ "Returns" ] [ 0 ] if typ != "" : lines . append ( f"- `{name}`: ``{return_type}``" ) else : lines . append ( f"- ``{return_type}``" ) lines . append ( "\n\n" ) if desc != "" : lines . append ( f" {' '.join(desc)}\n\n" ) elif return_type != "" : lines . append ( f"- ``{return_type}``" ) lines . append ( "\n\n" ) else : for name , typ , desc in doc [ "Returns" ] : if ":" in name : name , typ = name . split ( ":" ) if typ != "" : line = f"- `{name}`: {mangle_types(typ)}" else : line = f"- {mangle_types(name)}" line += "\n\n" lines . append ( line ) lines . append ( f" {' '.join(desc)}\n\n" ) except Exception as e : pass return lines
Generate markdown for Returns section .
57,740
def summary ( doc ) : lines = [ ] if "Summary" in doc and len ( doc [ "Summary" ] ) > 0 : lines . append ( fix_footnotes ( " " . join ( doc [ "Summary" ] ) ) ) lines . append ( "\n" ) if "Extended Summary" in doc and len ( doc [ "Extended Summary" ] ) > 0 : lines . append ( fix_footnotes ( " " . join ( doc [ "Extended Summary" ] ) ) ) lines . append ( "\n" ) return lines
Generate markdown for summary section .
57,741
def params_section ( thing , doc , header_level ) : lines = [ ] class_doc = doc [ "Parameters" ] return type_list ( inspect . signature ( thing ) , class_doc , "#" * ( header_level + 1 ) + " Parameters\n\n" , )
Generate markdown for Parameters section .
57,742
def string_annotation ( typ , default ) : try : type_string = ( f"`{typ.__name__}`" if typ . __module__ == "builtins" else f"`{typ.__module__}.{typ.__name__}`" ) except AttributeError : type_string = f"`{str(typ)}`" if default is None : type_string = f"{type_string}, default ``None``" elif default == inspect . _empty : pass else : type_string = f"{type_string}, default ``{default}``" return type_string
Construct a string representation of a type annotation .
57,743
def type_list ( signature , doc , header ) : lines = [ ] docced = set ( ) lines . append ( header ) try : for names , types , description in doc : names , types = _get_names ( names , types ) unannotated = [ ] for name in names : docced . add ( name ) try : typ = signature . parameters [ name ] . annotation if typ == inspect . _empty : raise AttributeError default = signature . parameters [ name ] . default type_string = string_annotation ( typ , default ) lines . append ( f"- `{name}`: {type_string}" ) lines . append ( "\n\n" ) except ( AttributeError , KeyError ) : unannotated . append ( name ) if len ( unannotated ) > 0 : lines . append ( "- " ) lines . append ( ", " . join ( f"`{name}`" for name in unannotated ) ) if types != "" and len ( unannotated ) > 0 : lines . append ( f": {mangle_types(types)}" ) lines . append ( "\n\n" ) lines . append ( f" {' '.join(description)}\n\n" ) for names , types , description in doc : names , types = _get_names ( names , types ) for name in names : if name not in docced : try : typ = signature . parameters [ name ] . annotation default = signature . parameters [ name ] . default type_string = string_annotation ( typ , default ) lines . append ( f"- `{name}`: {type_string}" ) lines . append ( "\n\n" ) except ( AttributeError , KeyError ) : lines . append ( f"- `{name}`" ) lines . append ( "\n\n" ) except Exception as e : print ( e ) return lines if len ( lines ) > 1 else [ ]
Construct a list of types preferring type annotations to docstrings if they are available .
57,744
def attributes_section ( thing , doc , header_level ) : if not inspect . isclass ( thing ) : return [ ] props , class_doc = _split_props ( thing , doc [ "Attributes" ] ) tl = type_list ( inspect . signature ( thing ) , class_doc , "\n### Attributes\n\n" ) if len ( tl ) == 0 and len ( props ) > 0 : tl . append ( "\n### Attributes\n\n" ) for prop in props : tl . append ( f"- [`{prop}`](#{prop})\n\n" ) return tl
Generate an attributes section for classes .
57,745
def enum_doc ( name , enum , header_level , source_location ) : lines = [ f"{'#'*header_level} Enum **{name}**\n\n" ] lines . append ( f"```python\n{name}\n```\n" ) lines . append ( get_source_link ( enum , source_location ) ) try : doc = NumpyDocString ( inspect . getdoc ( thing ) ) . _parsed_data lines += summary ( doc ) except : pass lines . append ( f"{'#'*(header_level + 1)} Members\n\n" ) lines += [ f"- `{str(v).split('.').pop()}`: `{v.value}` \n\n" for v in enum ] return lines
Generate markdown for an enum
57,746
def to_doc ( name , thing , header_level , source_location ) : if type ( thing ) is enum . EnumMeta : return enum_doc ( name , thing , header_level , source_location ) if inspect . isclass ( thing ) : header = f"{'#'*header_level} Class **{name}**\n\n" else : header = f"{'#'*header_level} {name}\n\n" lines = [ header , get_signature ( name , thing ) , get_source_link ( thing , source_location ) , ] try : doc = NumpyDocString ( inspect . getdoc ( thing ) ) . _parsed_data lines += summary ( doc ) lines += attributes_section ( thing , doc , header_level ) lines += params_section ( thing , doc , header_level ) lines += returns_section ( thing , doc , header_level ) lines += examples_section ( doc , header_level ) lines += notes_section ( doc ) lines += refs_section ( doc ) except Exception as e : pass return lines
Generate markdown for a class or function
57,747
def doc_module ( module_name , module , output_dir , source_location , leaf ) : path = pathlib . Path ( output_dir ) . joinpath ( * module . __name__ . split ( "." ) ) available_classes = get_available_classes ( module ) deffed_classes = get_classes ( module ) deffed_funcs = get_funcs ( module ) deffed_enums = get_enums ( module ) alias_funcs = available_classes - deffed_classes if leaf : doc_path = path . with_suffix ( ".md" ) else : doc_path = path / "index.md" doc_path . parent . mkdir ( parents = True , exist_ok = True ) module_path = "/" . join ( module . __name__ . split ( "." ) ) doc = [ f"title: {module_name.split('.')[-1]}" + "\n" ] module_doc = module . __doc__ if module_doc is not None : doc += to_doc ( module . __name__ , module , 1 , source_location ) else : doc . append ( f"# {module.__name__}\n\n" ) doc . append ( "\n\n" ) for cls_name , cls in sorted ( deffed_enums ) + sorted ( deffed_classes ) : doc += to_doc ( cls_name , cls , 2 , source_location ) class_methods = [ x for x in inspect . getmembers ( cls , inspect . isfunction ) if ( not x [ 0 ] . startswith ( "_" ) ) and deffed_here ( x [ 1 ] , cls ) ] class_methods += inspect . getmembers ( cls , lambda o : isinstance ( o , property ) ) if len ( class_methods ) > 0 : doc . append ( "### Methods \n\n" ) for method_name , method in class_methods : doc += to_doc ( method_name , method , 4 , source_location ) for fname , func in sorted ( deffed_funcs ) : doc += to_doc ( fname , func , 2 , source_location ) return doc_path . absolute ( ) , "" . join ( doc )
Document a module
57,748
def set_color ( fg = None , bg = None ) : if fg or bg : _color_manager . set_color ( fg , bg ) else : _color_manager . set_defaults ( )
Set the current colors .
57,749
def cprint ( string , fg = None , bg = None , end = '\n' , target = sys . stdout ) : _color_manager . set_color ( fg , bg ) target . write ( string + end ) target . flush ( ) _color_manager . set_defaults ( )
Print a colored string to the target handle .
57,750
def fprint ( fmt , * args , ** kwargs ) : if not fmt : return hascolor = False target = kwargs . get ( "target" , sys . stdout ) fmt = fmt . format ( * args , ** kwargs ) for txt , markups in _color_format_parser . parse ( fmt ) : if markups != ( None , None ) : _color_manager . set_color ( * markups ) hascolor = True else : if hascolor : _color_manager . set_defaults ( ) hascolor = False target . write ( txt ) target . flush ( ) _color_manager . set_defaults ( ) target . write ( kwargs . get ( 'end' , '\n' ) ) _color_manager . set_defaults ( )
Parse and print a colored and perhaps formatted string .
57,751
def formatcolor ( string , fg = None , bg = None ) : if fg is bg is None : return string temp = ( [ 'fg=' + fg ] if fg else [ ] ) + ( [ 'bg=' + bg ] if bg else [ ] ) fmt = _color_format_parser . _COLOR_DELIM . join ( temp ) return _color_format_parser . _START_TOKEN + fmt + _color_format_parser . _FMT_TOKEN + string + _color_format_parser . _STOP_TOKEN
Wrap color syntax around a string and return it .
57,752
def formatbyindex ( string , fg = None , bg = None , indices = [ ] ) : if not string or not indices or ( fg is bg is None ) : return string result , p = '' , 0 for k , g in itertools . groupby ( enumerate ( sorted ( indices ) ) , lambda x : x [ 0 ] - x [ 1 ] ) : tmp = list ( map ( operator . itemgetter ( 1 ) , g ) ) s , e = tmp [ 0 ] , tmp [ - 1 ] + 1 if s < len ( string ) : result += string [ p : s ] result += formatcolor ( string [ s : e ] , fg , bg ) p = e if p < len ( string ) : result += string [ p : ] return result
Wrap color syntax around characters using indices and return it .
57,753
def highlight ( string , fg = None , bg = None , indices = [ ] , end = '\n' , target = sys . stdout ) : if not string or not indices or ( fg is bg is None ) : return p = 0 for k , g in itertools . groupby ( enumerate ( sorted ( indices ) ) , lambda x : x [ 0 ] - x [ 1 ] ) : tmp = list ( map ( operator . itemgetter ( 1 ) , g ) ) s , e = tmp [ 0 ] , tmp [ - 1 ] + 1 target . write ( string [ p : s ] ) target . flush ( ) _color_manager . set_color ( fg , bg ) target . write ( string [ s : e ] ) target . flush ( ) _color_manager . set_defaults ( ) p = e if p < len ( string ) : target . write ( string [ p : ] ) target . write ( end )
Highlight characters using indices and print it to the target handle .
57,754
def create_param_info ( task_params , parameter_map ) : gp_params = [ ] gp_param_list = [ ] gp_param_idx_list = [ ] gp_param_idx = 0 for task_param in task_params : gp_param = { } data_type = task_param [ 'type' ] . upper ( ) if 'dimensions' in task_param : if len ( task_param [ 'dimensions' ] . split ( ',' ) ) > 1 : raise UnknownDataTypeError ( 'Only one-dimensional arrays are supported.' ) data_type += 'ARRAY' if data_type in parameter_map : gp_param [ 'dataType' ] = parameter_map [ data_type ] . data_type else : raise UnknownDataTypeError ( 'Unable to map task datatype: ' + data_type + '. A template must be created.' ) gp_param [ 'name' ] = task_param [ 'name' ] gp_param [ 'displayName' ] = task_param [ 'display_name' ] gp_param [ 'direction' ] = _DIRECTION_MAP [ task_param [ 'direction' ] ] gp_param [ 'paramType' ] = 'Required' if task_param [ 'required' ] else 'Optional' if gp_param [ 'direction' ] is 'Output' : gp_param [ 'paramType' ] = 'Derived' gp_param [ 'multiValue' ] = True if 'dimensions' in task_param else False gp_params . append ( parameter_map [ data_type ] . get_parameter ( task_param ) . substitute ( gp_param ) ) if 'default_value' in task_param : gp_param [ 'defaultValue' ] = task_param [ 'default_value' ] gp_params . append ( parameter_map [ data_type ] . default_value ( ) . substitute ( gp_param ) ) if 'choice_list' in task_param : gp_param [ 'choiceList' ] = task_param [ 'choice_list' ] gp_params . append ( _CHOICELIST_TEMPLATE . substitute ( gp_param ) ) for param_name in parameter_map [ data_type ] . parameter_names ( task_param ) : gp_param_list . append ( param_name . substitute ( gp_param ) ) gp_param_idx_list . append ( _PARAM_INDEX_TEMPLATE . substitute ( { 'name' : param_name . substitute ( gp_param ) , 'idx' : gp_param_idx } ) ) gp_param_idx += 1 gp_params . append ( _PARAM_RETURN_TEMPLATE . substitute ( { 'paramList' : convert_list ( gp_param_list ) } ) ) return '' . join ( ( '' . join ( gp_params ) , '' . join ( gp_param_idx_list ) ) )
Builds the code block for the GPTool GetParameterInfo method based on the input task_params .
57,755
def create_update_parameter ( task_params , parameter_map ) : gp_params = [ ] for param in task_params : if param [ 'direction' ] . upper ( ) == 'OUTPUT' : continue data_type = param [ 'type' ] . upper ( ) if 'dimensions' in param : data_type += 'ARRAY' if data_type in parameter_map : gp_params . append ( parameter_map [ data_type ] . update_parameter ( ) . substitute ( param ) ) return '' . join ( gp_params )
Builds the code block for the GPTool UpdateParameter method based on the input task_params .
57,756
def create_pre_execute ( task_params , parameter_map ) : gp_params = [ _PRE_EXECUTE_INIT_TEMPLATE ] for task_param in task_params : if task_param [ 'direction' ] . upper ( ) == 'OUTPUT' : continue data_type = task_param [ 'type' ] . upper ( ) if 'dimensions' in task_param : data_type += 'ARRAY' if data_type in parameter_map : gp_params . append ( parameter_map [ data_type ] . pre_execute ( ) . substitute ( task_param ) ) gp_params . append ( _PRE_EXECUTE_CLEANUP_TEMPLATE ) return '' . join ( gp_params )
Builds the code block for the GPTool Execute method before the job is submitted based on the input task_params .
57,757
def create_post_execute ( task_params , parameter_map ) : gp_params = [ ] for task_param in task_params : if task_param [ 'direction' ] . upper ( ) == 'INPUT' : continue data_type = task_param [ 'type' ] . upper ( ) if 'dimensions' in task_param : data_type += 'ARRAY' if data_type in parameter_map : gp_params . append ( parameter_map [ data_type ] . post_execute ( ) . substitute ( task_param ) ) return '' . join ( gp_params )
Builds the code block for the GPTool Execute method after the job is submitted based on the input task_params .
57,758
def load_default_templates ( self ) : for importer , modname , is_pkg in pkgutil . iter_modules ( templates . __path__ ) : self . register_template ( '.' . join ( ( templates . __name__ , modname ) ) )
Load the default templates
57,759
def remove_hwpack ( name ) : targ_dlib = hwpack_dir ( ) / name log . debug ( 'remove %s' , targ_dlib ) targ_dlib . rmtree ( )
remove hardware package .
57,760
def finalize ( self ) : super ( StatisticsConsumer , self ) . finalize ( ) self . result = zip ( self . grid , map ( self . statistics , self . result ) )
finalize for StatisticsConsumer
57,761
def finalize ( self ) : super ( StochasticProcessStatisticsConsumer , self ) . finalize ( ) class StochasticProcessStatistics ( self . statistics ) : def __str__ ( self ) : s = [ k . rjust ( 12 ) + str ( getattr ( self , k ) ) for k in dir ( self ) if not k . startswith ( '_' ) ] return '\n' . join ( s ) sps = StochasticProcessStatistics ( [ 0 , 0 ] ) keys = list ( ) for k in dir ( sps ) : if not k . startswith ( '_' ) : a = getattr ( sps , k ) if isinstance ( a , ( int , float , str ) ) : keys . append ( k ) else : delattr ( sps , k ) for k in keys : setattr ( sps , k , list ( ) ) grid = list ( ) for g , r in self . result : grid . append ( g ) for k in keys : a = getattr ( sps , k ) a . append ( getattr ( r , k ) ) self . result = grid , sps
finalize for StochasticProcessStatisticsConsumer
57,762
def setup_keyword ( dist , _ , value ) : if value is not True : return dist . entry_points = _ensure_entry_points_is_dict ( dist . entry_points ) for command , subcommands in six . iteritems ( _get_commands ( dist ) ) : entry_point = '{command} = rcli.dispatcher:main' . format ( command = command ) entry_points = dist . entry_points . setdefault ( 'console_scripts' , [ ] ) if entry_point not in entry_points : entry_points . append ( entry_point ) dist . entry_points . setdefault ( 'rcli' , [ ] ) . extend ( subcommands )
Add autodetected commands as entry points .
57,763
def egg_info_writer ( cmd , basename , filename ) : setupcfg = next ( ( f for f in setuptools . findall ( ) if os . path . basename ( f ) == 'setup.cfg' ) , None ) if not setupcfg : return parser = six . moves . configparser . ConfigParser ( ) parser . read ( setupcfg ) if not parser . has_section ( 'rcli' ) or not parser . items ( 'rcli' ) : return config = dict ( parser . items ( 'rcli' ) ) for k , v in six . iteritems ( config ) : if v . lower ( ) in ( 'y' , 'yes' , 'true' ) : config [ k ] = True elif v . lower ( ) in ( 'n' , 'no' , 'false' ) : config [ k ] = False else : try : config [ k ] = json . loads ( v ) except ValueError : pass cmd . write_file ( basename , filename , json . dumps ( config ) )
Read rcli configuration and write it out to the egg info .
57,764
def _get_commands ( dist ) : py_files = ( f for f in setuptools . findall ( ) if os . path . splitext ( f ) [ 1 ] . lower ( ) == '.py' ) pkg_files = ( f for f in py_files if _get_package_name ( f ) in dist . packages ) commands = { } for file_name in pkg_files : with open ( file_name ) as py_file : module = typing . cast ( ast . Module , ast . parse ( py_file . read ( ) ) ) module_name = _get_module_name ( file_name ) _append_commands ( commands , module_name , _get_module_commands ( module ) ) _append_commands ( commands , module_name , _get_class_commands ( module ) ) _append_commands ( commands , module_name , _get_function_commands ( module ) ) return commands
Find all commands belonging to the given distribution .
57,765
def _append_commands ( dct , module_name , commands ) : for command in commands : entry_point = '{command}{subcommand} = {module}{callable}' . format ( command = command . command , subcommand = ( ':{}' . format ( command . subcommand ) if command . subcommand else '' ) , module = module_name , callable = ( ':{}' . format ( command . callable ) if command . callable else '' ) , ) dct . setdefault ( command . command , set ( ) ) . add ( entry_point )
Append entry point strings representing the given Command objects .
57,766
def _get_module_commands ( module ) : cls = next ( ( n for n in module . body if isinstance ( n , ast . ClassDef ) and n . name == 'Command' ) , None ) if not cls : return methods = ( n . name for n in cls . body if isinstance ( n , ast . FunctionDef ) ) if '__call__' not in methods : return docstring = ast . get_docstring ( module ) for commands , _ in usage . parse_commands ( docstring ) : yield _EntryPoint ( commands [ 0 ] , next ( iter ( commands [ 1 : ] ) , None ) , None )
Yield all Command objects represented by the python module .
57,767
def _get_function_commands ( module ) : nodes = ( n for n in module . body if isinstance ( n , ast . FunctionDef ) ) for func in nodes : docstring = ast . get_docstring ( func ) for commands , _ in usage . parse_commands ( docstring ) : yield _EntryPoint ( commands [ 0 ] , next ( iter ( commands [ 1 : ] ) , None ) , func . name )
Yield all Command objects represented by python functions in the module .
57,768
def convert ( b ) : if b > 1024 ** 3 : hr = round ( b / 1024 ** 3 ) unit = "GB" elif b > 1024 ** 2 : hr = round ( b / 1024 ** 2 ) unit = "MB" else : hr = round ( b / 1024 ) unit = "KB" return hr , unit
takes a number of bytes as an argument and returns the most suitable human readable unit conversion .
57,769
def calc ( path ) : total = 0 err = None if os . path . isdir ( path ) : try : for entry in os . scandir ( path ) : try : is_dir = entry . is_dir ( follow_symlinks = False ) except ( PermissionError , FileNotFoundError ) : err = "!" return total , err if is_dir : result = calc ( entry . path ) total += result [ 0 ] err = result [ 1 ] if err : return total , err else : try : total += entry . stat ( follow_symlinks = False ) . st_size except ( PermissionError , FileNotFoundError ) : err = "!" return total , err except ( PermissionError , FileNotFoundError ) : err = "!" return total , err else : total += os . path . getsize ( path ) return total , err
Takes a path as an argument and returns the total size in bytes of the file or directory . If the path is a directory the size will be calculated recursively .
57,770
def du ( path ) : size , err = calc ( path ) if err : return err else : hr , unit = convert ( size ) hr = str ( hr ) result = hr + " " + unit return result
Put it all together!
57,771
def handle ( self , ** kwargs ) : for item in settings . ACTIVITY_MONITOR_MODELS : app_label , model = item [ 'model' ] . split ( '.' , 1 ) content_type = ContentType . objects . get ( app_label = app_label , model = model ) model = content_type . model_class ( ) objects = model . objects . all ( ) for object in objects : try : object . save ( ) except Exception as e : print ( "Error saving: {}" . format ( e ) )
Simply re - saves all objects from models listed in settings . TIMELINE_MODELS . Since the timeline app is now following these models it will register each item as it is re - saved . The purpose of this script is to register content in your database that existed prior to installing the timeline app .
57,772
def album_primary_image_url ( self ) : path = '/Items/{}/Images/Primary' . format ( self . album_id ) return self . connector . get_url ( path , attach_api_key = False )
The image of the album
57,773
def stream_url ( self ) : path = '/Audio/{}/universal' . format ( self . id ) return self . connector . get_url ( path , userId = self . connector . userid , MaxStreamingBitrate = 140000000 , Container = 'opus' , TranscodingContainer = 'opus' , AudioCodec = 'opus' , MaxSampleRate = 48000 , PlaySessionId = 1496213367201 )
stream for this song - not re - encoded
57,774
def data ( self ) : if self . _data is None : request = urllib . Request ( self . _url , headers = { 'User-Agent' : USER_AGENT } ) with contextlib . closing ( self . _connection . urlopen ( request ) ) as response : self . _data = response . read ( ) return self . _data
raw image data
57,775
def make_filter_string ( cls , filter_specification ) : registry = get_current_registry ( ) visitor_cls = registry . getUtility ( IFilterSpecificationVisitor , name = EXPRESSION_KINDS . CQL ) visitor = visitor_cls ( ) filter_specification . accept ( visitor ) return str ( visitor . expression )
Converts the given filter specification to a CQL filter expression .
57,776
def make_order_string ( cls , order_specification ) : registry = get_current_registry ( ) visitor_cls = registry . getUtility ( IOrderSpecificationVisitor , name = EXPRESSION_KINDS . CQL ) visitor = visitor_cls ( ) order_specification . accept ( visitor ) return str ( visitor . expression )
Converts the given order specification to a CQL order expression .
57,777
def make_slice_key ( cls , start_string , size_string ) : try : start = int ( start_string ) except ValueError : raise ValueError ( 'Query parameter "start" must be a number.' ) if start < 0 : raise ValueError ( 'Query parameter "start" must be zero or ' 'a positive number.' ) try : size = int ( size_string ) except ValueError : raise ValueError ( 'Query parameter "size" must be a number.' ) if size < 1 : raise ValueError ( 'Query parameter "size" must be a positive ' 'number.' ) return slice ( start , start + size )
Converts the given start and size query parts to a slice key .
57,778
def make_slice_strings ( cls , slice_key ) : start = slice_key . start size = slice_key . stop - start return ( str ( start ) , str ( size ) )
Converts the given slice key to start and size query parts .
57,779
def match ( self , expression = None , xpath = None , namespaces = None ) : class MatchObject ( Dict ) : pass def _match ( function ) : self . matches . append ( MatchObject ( expression = expression , xpath = xpath , function = function , namespaces = namespaces ) ) def wrapper ( self , * args , ** params ) : return function ( self , * args , ** params ) return wrapper return _match
decorator that allows us to match by expression or by xpath for each transformation method
57,780
def get_match ( self , elem ) : for m in self . matches : if ( m . expression is not None and eval ( m . expression ) == True ) or ( m . xpath is not None and len ( elem . xpath ( m . xpath , namespaces = m . namespaces ) ) > 0 ) : LOG . debug ( "=> match: %r" % m . expression ) return m
for the given elem return the
57,781
def Element ( self , elem , ** params ) : res = self . __call__ ( deepcopy ( elem ) , ** params ) if len ( res ) > 0 : return res [ 0 ] else : return None
Ensure that the input element is immutable by the transformation . Returns a single element .
57,782
def read_properties ( filename ) : s = path ( filename ) . text ( ) dummy_section = 'xxx' cfgparser = configparser . RawConfigParser ( ) cfgparser . optionxform = str cfgparser . readfp ( StringIO ( '[%s]\n' % dummy_section + s ) ) bunch = AutoBunch ( ) for x in cfgparser . options ( dummy_section ) : setattr ( bunch , x , cfgparser . get ( dummy_section , str ( x ) ) ) return bunch
read properties file into bunch .
57,783
def create_request_url ( self , interface , method , version , parameters ) : if 'format' in parameters : parameters [ 'key' ] = self . apikey else : parameters . update ( { 'key' : self . apikey , 'format' : self . format } ) version = "v%04d" % ( version ) url = "http://api.steampowered.com/%s/%s/%s/?%s" % ( interface , method , version , urlencode ( parameters ) ) return url
Create the URL to submit to the Steam Web API
57,784
def retrieve_request ( self , url ) : try : data = urlopen ( url ) except : print ( "Error Retrieving Data from Steam" ) sys . exit ( 2 ) return data . read ( ) . decode ( 'utf-8' )
Open the given url and decode and return the response
57,785
def return_data ( self , data , format = None ) : if format is None : format = self . format if format == "json" : formatted_data = json . loads ( data ) else : formatted_data = data return formatted_data
Format and return data appropriate to the requested API format .
57,786
def get_friends_list ( self , steamID , relationship = 'all' , format = None ) : parameters = { 'steamid' : steamID , 'relationship' : relationship } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetFriendsList' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request the friends list of a given steam ID filtered by role .
57,787
def get_player_bans ( self , steamIDS , format = None ) : parameters = { 'steamids' : steamIDS } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetPlayerBans' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request the communities a steam id is banned in .
57,788
def get_user_group_list ( self , steamID , format = None ) : parameters = { 'steamid' : steamID } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetUserGroupList' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request a list of groups a user is subscribed to .
57,789
def resolve_vanity_url ( self , vanityURL , url_type = 1 , format = None ) : parameters = { 'vanityurl' : vanityURL , "url_type" : url_type } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'ResolveVanityUrl' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request the steam id associated with a vanity url .
57,790
def get_global_achievement_percentages_for_app ( self , gameID , format = None ) : parameters = { 'gameid' : gameID } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetGlobalAchievementPercentagesForApp' , 2 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request statistics showing global achievements that have been unlocked .
57,791
def get_global_stats_for_game ( self , appID , count , names , startdate , enddate , format = None ) : parameters = { 'appid' : appID , 'count' : count , 'startdate' : startdate , 'enddate' : enddate } count = 0 for name in names : param = "name[" + str ( count ) + "]" parameters [ param ] = name count += 1 if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetGlobalStatsForGame' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request global stats for a give game .
57,792
def get_number_of_current_players ( self , appID , format = None ) : parameters = { 'appid' : appID } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetNumberOfCurrentPlayers' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request the current number of players for a given app .
57,793
def get_player_achievements ( self , steamID , appID , language = None , format = None ) : parameters = { 'steamid' : steamID , 'appid' : appID } if format is not None : parameters [ 'format' ] = format if language is not None : parameters [ 'l' ] = language else : parameters [ 'l' ] = self . language url = self . create_request_url ( self . interface , 'GetPlayerAchievements' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request the achievements for a given app and steam id .
57,794
def get_schema_for_game ( self , appID , language = None , format = None ) : parameters = { 'appid' : appID } if format is not None : parameters [ 'format' ] = format if language is not None : parameters [ 'l' ] = language else : parameters [ 'l' ] = self . language url = self . create_request_url ( self . interface , 'GetSchemaForGame' , 2 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request the available achievements and stats for a game .
57,795
def get_user_stats_for_game ( self , steamID , appID , format = None ) : parameters = { 'steamid' : steamID , 'appid' : appID } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetUserStatsForGame' , 2 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request the user stats for a given game .
57,796
def get_recently_played_games ( self , steamID , count = 0 , format = None ) : parameters = { 'steamid' : steamID , 'count' : count } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetRecentlyPlayedGames' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request a list of recently played games by a given steam id .
57,797
def get_owned_games ( self , steamID , include_appinfo = 1 , include_played_free_games = 0 , appids_filter = None , format = None ) : parameters = { 'steamid' : steamID , 'include_appinfo' : include_appinfo , 'include_played_free_games' : include_played_free_games } if format is not None : parameters [ 'format' ] = format if appids_filter is not None : parameters [ 'appids_filter' ] = appids_filter url = self . create_request_url ( self . interface , 'GetOwnedGames' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Request a list of games owned by a given steam id .
57,798
def get_community_badge_progress ( self , steamID , badgeID , format = None ) : parameters = { 'steamid' : steamID , 'badgeid' : badgeID } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'GetCommunityBadgeProgress' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Gets all the quests needed to get the specified badge and which are completed .
57,799
def is_playing_shared_game ( self , steamID , appid_playing , format = None ) : parameters = { 'steamid' : steamID , 'appid_playing' : appid_playing } if format is not None : parameters [ 'format' ] = format url = self . create_request_url ( self . interface , 'IsPlayingSharedGame' , 1 , parameters ) data = self . retrieve_request ( url ) return self . return_data ( data , format = format )
Returns valid lender SteamID if game currently played is borrowed .