id
int64
0
843k
repository_name
stringlengths
7
55
file_path
stringlengths
9
332
class_name
stringlengths
3
290
human_written_code
stringlengths
12
4.36M
class_skeleton
stringlengths
19
2.2M
total_program_units
int64
1
9.57k
total_doc_str
int64
0
4.2k
AvgCountLine
float64
0
7.89k
AvgCountLineBlank
float64
0
300
AvgCountLineCode
float64
0
7.89k
AvgCountLineComment
float64
0
7.89k
AvgCyclomatic
float64
0
130
CommentToCodeRatio
float64
0
176
CountClassBase
float64
0
48
CountClassCoupled
float64
0
589
CountClassCoupledModified
float64
0
581
CountClassDerived
float64
0
5.37k
CountDeclInstanceMethod
float64
0
4.2k
CountDeclInstanceVariable
float64
0
299
CountDeclMethod
float64
0
4.2k
CountDeclMethodAll
float64
0
4.2k
CountLine
float64
1
115k
CountLineBlank
float64
0
9.01k
CountLineCode
float64
0
94.4k
CountLineCodeDecl
float64
0
46.1k
CountLineCodeExe
float64
0
91.3k
CountLineComment
float64
0
27k
CountStmt
float64
1
93.2k
CountStmtDecl
float64
0
46.1k
CountStmtExe
float64
0
90.2k
MaxCyclomatic
float64
0
759
MaxInheritanceTree
float64
0
16
MaxNesting
float64
0
34
SumCyclomatic
float64
0
6k
144,848
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/exceptions.py
labkey.exceptions.UnexpectedRedirectError
class UnexpectedRedirectError(RequestError): default_msg = "Unexpected redirect occurred" def __init__(self, server_response, **kwargs): super().__init__(server_response, **kwargs) location = server_response.headers.get("Location", "") # If the server is redirecting from http to https the user probably has a misconfigured ServerContext with use_ssl=False if server_response.url.startswith("http://") and location.startswith("https://"): self.message = "Redirected from http to https, set use_ssl=True in your APIWrapper or ServerContext" elif location != "": self.message = f"Unexpected redirect to: {location}"
class UnexpectedRedirectError(RequestError): def __init__(self, server_response, **kwargs): pass
2
0
10
2
7
1
3
0.11
1
1
0
0
1
1
1
4
13
3
9
5
7
1
8
5
6
3
3
1
3
144,849
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/experiment.py
labkey.experiment.Batch
class Batch(ExpObject): def __init__(self, **kwargs): super().__init__(**kwargs) self.batch_protocol_id = kwargs.pop("batch_protocol_id", self.id) self.hidden = kwargs.pop("hidden", False) runs = kwargs.pop("runs", []) self.runs = [Run(**run) for run in runs] def to_json(self): data = super().to_json() data["batchProtocolId"] = self.batch_protocol_id # The JavaScript API doesn't appear to send these? # data['batchProtocolId'] = self.batch_protocol_id # data['hidden'] = self.hidden data["runs"] = [run.to_json() for run in self.runs] return data
class Batch(ExpObject): def __init__(self, **kwargs): pass def to_json(self): pass
3
0
8
1
6
2
1
0.25
1
2
1
0
2
3
2
4
18
3
12
8
9
3
12
8
9
1
1
0
2
144,850
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/experiment.py
labkey.experiment.Data
class Data(RunItem): def __init__(self, **kwargs): super().__init__(**kwargs) self.data_type = kwargs.pop("data_type", kwargs.pop("dataType", None)) self.data_file_url = kwargs.pop("data_file_url", kwargs.pop("dataFileURL", None)) self.pipeline_path = kwargs.pop("pipeline_path", kwargs.pop("pipelinePath", None)) self.role = kwargs.pop("role", None) def to_json(self): data = super().to_json() data["dataFileURL"] = self.data_file_url data["dataType"] = self.data_type data["pipelinePath"] = self.pipeline_path data["role"] = self.role return data
class Data(RunItem): def __init__(self, **kwargs): pass def to_json(self): pass
3
0
7
1
7
0
1
0
1
1
0
0
2
4
2
6
16
2
14
8
11
0
14
8
11
1
2
0
2
144,851
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/experiment.py
labkey.experiment.ExpObject
class ExpObject: def __init__(self, **kwargs): self.lsid = kwargs.pop("lsid", None) # Life Science identifier self.name = kwargs.pop("name", None) self.id = kwargs.pop("id", None) self.row_id = self.id self.comment = kwargs.pop("comment", None) self.created = kwargs.pop("created", None) self.modified = kwargs.pop("modified", None) self.created_by = kwargs.pop("created_by", kwargs.pop("createdBy", None)) self.modified_by = kwargs.pop("modified_by", kwargs.pop("modifiedBy", None)) self.properties = kwargs.pop("properties", {}) def to_json(self): data = { # 'id': self.id, "comment": self.comment, "name": self.name, "created": self.created, "createdBy": self.created_by, "modified": self.modified, "modifiedBy": self.modified_by, "properties": self.properties, } if self.id is not None: data.update({"id": self.id}) if self.lsid is not None: data.update({"lsid": self.lsid}) return data
class ExpObject: def __init__(self, **kwargs): pass def to_json(self): pass
3
0
15
2
13
1
2
0.07
0
0
0
3
2
10
2
2
32
4
27
14
24
2
19
14
16
3
0
1
4
144,852
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/experiment.py
labkey.experiment.Run
class Run(ExpObject): def __init__(self, **kwargs): super().__init__(**kwargs) self.experiments = kwargs.pop("experiments", []) self.file_path_root = kwargs.pop("file_path_root", kwargs.pop("filePathRoot", None)) self.protocol = kwargs.pop("protocol", None) self.data_outputs = kwargs.pop("data_outputs", kwargs.pop("dataOutputs", [])) self.data_rows = kwargs.pop("data_rows", kwargs.pop("dataRows", [])) self.material_inputs = kwargs.pop("material_inputs", kwargs.pop("materialInputs", [])) self.material_outputs = kwargs.pop("material_outputs", kwargs.pop("materialOutputs", [])) self.object_properties = kwargs.pop("object_properties", kwargs.pop("objectProperties", [])) self.plate_metadata = kwargs.pop("plate_metadata", None) # TODO: initialize protocol # self._protocol = None data_inputs = kwargs.pop("data_inputs", kwargs.pop("dataInputs", [])) self.data_inputs = [Data(**input_) for input_ in data_inputs] def to_json(self): data = super().to_json() data["dataInputs"] = [data_input.to_json() for data_input in self.data_inputs] data["dataRows"] = self.data_rows data["experiments"] = self.experiments data["filePathRoot"] = self.file_path_root data["materialInputs"] = self.material_inputs data["materialOutputs"] = self.material_outputs data["plateMetadata"] = self.plate_metadata # Issue 2489: Drop empty values. Server supplies default values for missing keys, # and will throw exception if a null value is supplied data = {k: v for k, v in data.items() if v} return data
class Run(ExpObject): def __init__(self, **kwargs): pass def to_json(self): pass
3
0
16
2
12
2
1
0.16
1
2
1
0
2
10
2
4
33
4
25
15
22
4
25
15
22
1
1
0
2
144,853
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/experiment.py
labkey.experiment.RunItem
class RunItem(ExpObject): def __init__(self, **kwargs): super().__init__(**kwargs) self.source_protocol = kwargs.pop("source_protocol", kwargs.pop("sourceProtocol", None)) self.run = kwargs.pop("run", None) # TODO Check if this should be a Run instance self.target_applications = kwargs.pop( "target_applications", kwargs.pop("targetApplications", None) ) self.successor_runs = kwargs.pop( "successor_runs", kwargs.pop("successorRuns", kwargs.pop("sucessorRuns", None)), ) # sic self.cpas_type = kwargs.pop("cpas_type", kwargs.pop("cpasType", None)) def to_json(self): data = super().to_json() data["sourceProtocol"] = self.source_protocol data["run"] = self.run data["targetApplications"] = self.target_applications data["sucessorRuns"] = self.successor_runs data["cpasType"] = self.cpas_type return data
class RunItem(ExpObject): def __init__(self, **kwargs): pass def to_json(self): pass
3
0
11
1
10
1
1
0.1
1
1
0
1
2
5
2
4
23
2
21
9
18
2
16
9
13
1
1
0
2
144,854
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/query.py
labkey.query.AuditBehavior
class AuditBehavior: """ Enum of different auditing levels """ DETAILED = "DETAILED" NONE = "NONE" SUMMARY = "SUMMARY"
class AuditBehavior: ''' Enum of different auditing levels ''' pass
1
1
0
0
0
0
0
0.75
0
0
0
0
0
0
0
0
8
1
4
4
3
3
4
4
3
0
0
0
0
144,855
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/query.py
labkey.query.Pagination
class Pagination: """ Enum of paging styles """ PAGINATED = "paginated" SELECTED = "selected" UNSELECTED = "unselected" ALL = "all" NONE = "none"
class Pagination: ''' Enum of paging styles ''' pass
1
1
0
0
0
0
0
0.5
0
0
0
0
0
0
0
0
10
1
6
6
5
3
6
6
5
0
0
0
0
144,856
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/query.py
labkey.query.QueryFilter
class QueryFilter: """ Filter object to simplify generation of query filters """ class Types: """ Enumeration of acceptable filter types """ # These operators require a data value EQUAL = "eq" DATE_EQUAL = "dateeq" NEQ = "neq" NOT_EQUAL = "neq" DATE_NOT_EQUAL = "dateneq" NEQ_OR_NULL = "neqornull" NOT_EQUAL_OR_MISSING = "neqornull" GT = "gt" GREATER_THAN = "gt" DATE_GREATER_THAN = "dategt" LT = "lt" LESS_THAN = "lt" DATE_LESS_THAN = "datelt" GTE = "gte" GREATER_THAN_OR_EQUAL = "gte" DATE_GREATER_THAN_OR_EQUAL = "dategte" LTE = "lte" LESS_THAN_OR_EQUAL = "lte" DATE_LESS_THAN_OR_EQUAL = "datelte" STARTS_WITH = "startswith" DOES_NOT_START_WITH = "doesnotstartwith" CONTAINS = "contains" DOES_NOT_CONTAIN = "doesnotcontain" CONTAINS_ONE_OF = "containsoneof" CONTAINS_NONE_OF = "containsnoneof" IN = "in" EQUALS_ONE_OF = "in" NOT_IN = "notin" EQUALS_NONE_OF = "notin" BETWEEN = "between" NOT_BETWEEN = "notbetween" MEMBER_OF = "memberof" # These are the "no data value" operators HAS_ANY_VALUE = "" IS_BLANK = "isblank" IS_NOT_BLANK = "isnonblank" HAS_MISSING_VALUE = "hasmvvalue" DOES_NOT_HAVE_MISSING_VALUE = "nomvvalue" # Table/Query-wise operators Q = "q" # Ontology operators ONTOLOGY_IN_SUBTREE = "concept:insubtree" ONTOLOGY_NOT_IN_SUBTREE = "concept:notinsubtree" # Lineage operators EXP_CHILD_OF = "exp:childof" EXP_PARENT_OF = "exp:parentof" EXP_LINEAGE_OF = "exp:lineageof" def __init__(self, column, value, filter_type=Types.EQUAL): self.column_name = column self.value = value self.filter_type = filter_type def get_url_parameter_name(self): return "query." + self.column_name + "~" + self.filter_type def get_url_parameter_value(self): return self.value def get_column_name(self): return self.column_name def __repr__(self): return "<QueryFilter [{} {} {}]>".format(self.column_name, self.filter_type, self.value)
class QueryFilter: ''' Filter object to simplify generation of query filters ''' class Types: ''' Enumeration of acceptable filter types ''' def __init__(self, column, value, filter_type=Types.EQUAL): pass def get_url_parameter_name(self): pass def get_url_parameter_value(self): pass def get_column_name(self): pass def __repr__(self): pass
7
2
2
0
2
0
1
0.19
0
1
1
0
5
3
5
5
95
27
57
53
50
11
57
53
50
1
0
0
5
144,857
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/server_context.py
labkey.server_context.ServerContext
class ServerContext: """ ServerContext is used to encapsulate properties about the LabKey server that is being requested against. This includes, but is not limited to, the domain, container_path, if the server is using SSL, and CSRF token request. """ def __init__( self, domain, container_path, context_path=None, use_ssl=True, verify_ssl=True, api_key=None, disable_csrf=False, allow_redirects=False, ): self._container_path = container_path self._context_path = context_path self._domain = domain self._use_ssl = use_ssl self._verify_ssl = verify_ssl self._api_key = api_key self._disable_csrf = disable_csrf self.allow_redirects = allow_redirects self._session = requests.Session() self._session.headers.update({"User-Agent": f"LabKey Python API/{__version__}"}) if self._use_ssl: self._scheme = "https://" if not self._verify_ssl: self._session.verify = False else: self._scheme = "http://" def __repr__(self): return f"<ServerContext [ {self._domain} | {self._context_path} | {self._container_path} ]>" @property def hostname(self) -> str: return self._scheme + self._domain @property def base_url(self) -> str: base_url = self.hostname if self._context_path is not None: base_url += "/" + self._context_path return base_url def build_url(self, controller: str, action: str, container_path: str = None) -> str: url = self.base_url if container_path is not None: url += "/" + container_path elif self._container_path is not None: url += "/" + self._container_path url += "/" + controller + "-" + action return url def webdav_path(self, container_path: str = None, file_name: str = None): path = "/_webdav" container_path = container_path or self._container_path if container_path is not None: if container_path.endswith("/"): # trim the slash container_path = container_path[0:-1] if not container_path.startswith("/"): path += "/" path += container_path path += "/@files" if file_name is not None: if not file_name.startswith("/"): path += "/" path += file_name return path def webdav_client(self, webdav_options: dict = None): # We localize the import of webdav3 here so it is an optional dependency. Only users who want to use webdav will # need to pip install webdavclient3 from webdav3.client import Client options = { "webdav_hostname": self.base_url, } if self._api_key is not None: options["webdav_login"] = "apikey" options["webdav_password"] = f"{self._api_key}" if webdav_options is not None: options = { **options, **webdav_options, } client = Client(options) if self._verify_ssl is False: client.verify = False # Set verify to false if using localhost without HTTPS return client def handle_request_exception(self, exception): if type(exception) in [RequestAuthorizationError, QueryNotFoundError, ServerNotFoundError]: raise exception raise ServerContextError(self, exception) def make_request( self, url: str, payload: any = None, headers: dict = None, timeout: int = 300, method: str = "POST", non_json_response: bool = False, file_payload: Dict[str, TextIO] = None, json: dict = None, allow_redirects=False, ) -> any: allow_redirects_ = allow_redirects or self.allow_redirects if self._api_key is not None: if self._session.headers.get(API_KEY_TOKEN) is not self._api_key: self._session.headers.update({API_KEY_TOKEN: self._api_key}) if not self._disable_csrf and CSRF_TOKEN not in self._session.headers.keys(): try: csrf_url = self.build_url("login", "whoami.api") response = handle_response(self._session.get(csrf_url)) self._session.headers.update({CSRF_TOKEN: response["CSRF"]}) except RequestException as e: self.handle_request_exception(e) try: if method == "GET": response = self._session.get( url, params=payload, headers=headers, timeout=timeout, allow_redirects=allow_redirects_, ) else: if file_payload is not None: response = self._session.post( url, data=payload, files=file_payload, headers=headers, timeout=timeout, allow_redirects=allow_redirects_, ) elif json is not None: if headers is None: headers = {} headers_ = {**headers, "Content-Type": "application/json"} # sort_keys is a hack to make unit tests work data = json_dumps(json, sort_keys=True) response = self._session.post( url, data=data, headers=headers_, timeout=timeout, allow_redirects=allow_redirects_, ) else: response = self._session.post( url, data=payload, headers=headers, timeout=timeout, allow_redirects=allow_redirects_, ) return handle_response(response, non_json_response) except RequestException as e: self.handle_request_exception(e)
class ServerContext: ''' ServerContext is used to encapsulate properties about the LabKey server that is being requested against. This includes, but is not limited to, the domain, container_path, if the server is using SSL, and CSRF token request. ''' def __init__( self, domain, container_path, context_path=None, use_ssl=True, verify_ssl=True, api_key=None, disable_csrf=False, allow_redirects=False, ): pass def __repr__(self): pass @property def hostname(self) -> str: pass @property def base_url(self) -> str: pass def build_url(self, controller: str, action: str, container_path: str = None) -> str: pass def webdav_path(self, container_path: str = None, file_name: str = None): pass def webdav_client(self, webdav_options: dict = None): pass def handle_request_exception(self, exception): pass def make_request( self, url: str, payload: any = None, headers: dict = None, timeout: int = 300, method: str = "POST", non_json_response: bool = False, file_payload: Dict[str, TextIO] = None, json: dict = None, allow_redirects=False, ) -> any: pass
12
1
19
3
16
1
4
0.07
0
12
4
0
9
10
9
9
189
32
148
55
114
10
90
31
79
10
0
4
32
144,858
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/utils.py
labkey.utils.DateTimeEncoder
class DateTimeEncoder(json.JSONEncoder): def default(self, o): if isinstance(o, (datetime, date)): return o.isoformat() return super().default(o)
class DateTimeEncoder(json.JSONEncoder): def default(self, o): pass
2
0
5
1
4
0
2
0
1
3
0
0
1
0
1
5
6
1
5
2
3
0
5
2
3
2
2
1
2
144,859
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestCreate
class TestCreate(unittest.TestCase): def setUp(self): domain_definition = { "kind": "IntList", "domainDesign": { "name": "TheTestList", "fields": [{"name": "theKey", "rangeURI": "int"}], }, "options": {"keyName": "theKey"}, } class MockCreate(MockLabKey): api = "createDomain.api" default_action = domain_controller default_success_body = domain_definition self.service = MockCreate() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": json.dumps(domain_definition, sort_keys=True), "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), domain_definition] def test_success(self): test = self success_test( test, self.service.get_successful_response(), create, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), create, *self.args, **self.expected_kwargs )
class TestCreate(unittest.TestCase): def setUp(self): pass class MockCreate(MockLabKey): def test_success(self): pass def test_unauthorized(self): pass
5
0
16
2
14
0
1
0
1
2
2
0
3
3
3
75
50
7
43
14
38
0
16
14
11
1
2
0
3
144,860
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/security.py
labkey.security.WhoAmI
class WhoAmI: id: int email: str display_name: str impersonated: str CSRF: str
class WhoAmI: pass
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
6
0
6
1
5
0
6
1
5
0
0
0
0
144,861
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.TestSelectRows
class TestSelectRows(unittest.TestCase): def setUp(self): self.service = MockSelectRows() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"schemaName": schema, "query.queryName": query, "query.maxRows": -1}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), schema, query] def test_success(self): test = self success_test( test, self.service.get_successful_response(), select_rows, True, *self.args, **self.expected_kwargs ) def test_query_filter(self): test = self view_name = None filter_array = [ QueryFilter("Field1", "value", "eq"), QueryFilter("Field2", "value1", "contains"), QueryFilter("Field2", "value2", "contains"), ] args = list(self.args) + [view_name, filter_array] # Expected query field values in post request body query_field = { "query.Field1~eq": ["value"], "query.Field2~contains": ["value1", "value2"], } # Update post request body with expected query field values self.expected_kwargs["data"].update(query_field) success_test( test, self.service.get_successful_response(), select_rows, True, *args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), select_rows, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), select_rows, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), select_rows, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), select_rows, *self.args, **self.expected_kwargs )
class TestSelectRows(unittest.TestCase): def setUp(self): pass def test_success(self): pass def test_query_filter(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
12
0
12
0
1
0.02
1
7
6
0
7
3
7
79
93
8
83
21
75
2
28
21
20
1
2
0
7
144,862
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.TestInsertRows
class TestInsertRows(unittest.TestCase): def setUp(self): self.service = MockInsertRows() rows = "{id:1234}" self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": '{"queryName": "' + query + '", "rows": "' + rows + '", "schemaName": "' + schema + '"}', "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), schema, query, rows] def test_success(self): test = self success_test( test, self.service.get_successful_response(), insert_rows, True, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), insert_rows, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), insert_rows, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), insert_rows, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), insert_rows, *self.args, **self.expected_kwargs )
class TestInsertRows(unittest.TestCase): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
7
0
12
1
11
0
1
0
1
5
5
0
6
3
6
78
76
8
68
16
61
0
21
16
14
1
2
0
6
144,863
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/labkey/storage.py
labkey.storage.StorageWrapper
class StorageWrapper: """ Wrapper for all of the API methods exposed in the storage module. Used by the APIWrapper class. """ def __init__(self, server_context: ServerContext): self.server_context = server_context @functools.wraps(create_storage_item) def create_storage_item(self, type: str, props: dict, container_path: str = None): return create_storage_item(self.server_context, type, props, container_path) @functools.wraps(update_storage_item) def update_storage_item(self, type: str, props: dict, container_path: str = None): return update_storage_item(self.server_context, type, props, container_path) @functools.wraps(delete_storage_item) def delete_storage_item(self, type: str, row_id: int, container_path: str = None): return delete_storage_item(self.server_context, type, row_id, container_path)
class StorageWrapper: ''' Wrapper for all of the API methods exposed in the storage module. Used by the APIWrapper class. ''' def __init__(self, server_context: ServerContext): pass @functools.wraps(create_storage_item) def create_storage_item(self, type: str, props: dict, container_path: str = None): pass @functools.wraps(update_storage_item) def update_storage_item(self, type: str, props: dict, container_path: str = None): pass @functools.wraps(delete_storage_item) def delete_storage_item(self, type: str, row_id: int, container_path: str = None): pass
8
1
2
0
2
0
1
0.25
0
4
1
0
4
1
4
4
19
4
12
9
4
3
9
6
4
1
0
0
4
144,864
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestCreate.setUp.MockCreate
class MockCreate(MockLabKey): api = "createDomain.api" default_action = domain_controller default_success_body = self.domain_definition
class MockCreate(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
4
0
4
4
3
0
4
4
3
0
1
0
0
144,865
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestDrop.setUp.MockDrop
class MockDrop(MockLabKey): api = "deleteDomain.api" default_action = domain_controller default_success_body = {}
class MockDrop(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
4
0
4
4
3
0
4
4
3
0
1
0
0
144,866
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestGet.setUp.MockGet
class MockGet(MockLabKey): api = "getDomain.api" default_action = domain_controller default_success_body = {}
class MockGet(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
4
0
4
4
3
0
4
4
3
0
1
0
0
144,867
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestInferFields.setUp.MockInferFields
class MockInferFields(MockLabKey): api = "inferDomain.api" default_action = domain_controller default_success_body = {}
class MockInferFields(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
4
0
4
4
3
0
4
4
3
0
1
0
0
144,868
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_domain.py
unit.test_domain.TestSave.setUp.MockSave
class MockSave(MockLabKey): api = "saveDomain.api" default_action = domain_controller default_success_body = {}
class MockSave(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
4
0
4
4
3
0
4
4
3
0
1
0
0
144,869
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestActivateUsers.MockActivateUser
class MockActivateUser(MockUserController): api = "activateUsers.api"
class MockActivateUser(MockUserController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,870
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestAddToGroup.MockAddGroupMember
class MockAddGroupMember(MockSecurityController): api = "addGroupMember.api"
class MockAddGroupMember(MockSecurityController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,871
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestAddToRole.MockAddRole
class MockAddRole(MockSecurityController): api = "addAssignment.api"
class MockAddRole(MockSecurityController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,872
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestCreateUser.MockCreateUser
class MockCreateUser(MockSecurityController): api = "createNewUser.api"
class MockCreateUser(MockSecurityController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,873
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestDeactivateUsers.MockDeactivateUser
class MockDeactivateUser(MockUserController): api = "deactivateUsers.view"
class MockDeactivateUser(MockUserController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,874
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestDeleteUsers.MockDeleteUser
class MockDeleteUser(MockUserController): api = "deleteUsers.view"
class MockDeleteUser(MockUserController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,875
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestGetRoles.MockGetRoles
class MockGetRoles(MockSecurityController): api = "getRoles.api"
class MockGetRoles(MockSecurityController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,876
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestListGroups.MockListGroups
class MockListGroups(MockSecurityController): api = "listProjectGroups.api"
class MockListGroups(MockSecurityController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,877
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestRemoveFromGroup.MockRemoveGroupMember
class MockRemoveGroupMember(MockSecurityController): api = "removeGroupMember.api"
class MockRemoveGroupMember(MockSecurityController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,878
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestRemoveFromRole.MockRemoveRole
class MockRemoveRole(MockSecurityController): api = "removeAssignment.api"
class MockRemoveRole(MockSecurityController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,879
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestResetPassword.MockResetPassword
class MockResetPassword(MockSecurityController): api = "adminRotatePassword.api"
class MockResetPassword(MockSecurityController): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
9
2
0
2
2
1
0
2
2
1
0
2
0
0
144,880
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/labkey/security.py
labkey.security.SecurityWrapper
class SecurityWrapper: """ Wrapper for all of the API methods exposed in the security module. Used by the APIWrapper class. """ def __init__(self, server_context: ServerContext): self.server_context = server_context @functools.wraps(activate_users) def activate_users(self, target_ids: List[int], container_path: str = None): return activate_users(self.server_context, target_ids, container_path) @functools.wraps(add_to_group) def add_to_group( self, user_ids: Union[int, List[int]], group_id: int, container_path: str = None ): return add_to_group(self.server_context, user_ids, group_id, container_path) @functools.wraps(add_to_role) def add_to_role( self, role: dict, user_id: int = None, email: str = None, container_path: str = None ): return add_to_role(self.server_context, role, user_id, email, container_path) @functools.wraps(create_user) def create_user(self, email: str, container_path: str = None, send_email=False): return create_user(self.server_context, email, container_path, send_email) @functools.wraps(deactivate_users) def deactivate_users(self, target_ids: List[int], container_path: str = None): return deactivate_users(self.server_context, target_ids, container_path) @functools.wraps(delete_users) def delete_users(self, target_ids: List[int], container_path: str = None): return delete_users(self.server_context, target_ids, container_path) @functools.wraps(get_roles) def get_roles(self, container_path: str = None): return get_roles(self.server_context, container_path) @functools.wraps(get_user_by_email) def get_user_by_email(self, email: str): return get_user_by_email(self.server_context, email) @functools.wraps(list_groups) def list_groups(self, include_site_groups: bool = False, container_path: str = None): return list_groups(self.server_context, include_site_groups, container_path) @functools.wraps(remove_from_group) def remove_from_group( self, user_ids: Union[int, List[int]], group_id, container_path: str = None ): return remove_from_group(self.server_context, user_ids, group_id, container_path) @functools.wraps(remove_from_role) def remove_from_role( self, role: dict, user_id: int = None, email: str = None, container_path: str = None ): return remove_from_role(self.server_context, role, user_id, email, container_path) @functools.wraps(reset_password) def reset_password(self, email: str, container_path: str = None): return reset_password(self.server_context, email, container_path) @functools.wraps(impersonate_user) def impersonate_user(self, user_id: int = None, email: str = None, container_path: str = None): return impersonate_user(self.server_context, user_id, email, container_path) @functools.wraps(stop_impersonating) def stop_impersonating(self): return stop_impersonating(self.server_context) @functools.wraps(who_am_i) def who_am_i(self): return who_am_i(self.server_context)
class SecurityWrapper: ''' Wrapper for all of the API methods exposed in the security module. Used by the APIWrapper class. ''' def __init__(self, server_context: ServerContext): pass @functools.wraps(activate_users) def activate_users(self, target_ids: List[int], container_path: str = None): pass @functools.wraps(add_to_group) def add_to_group( self, user_ids: Union[int, List[int]], group_id: int, container_path: str = None ): pass @functools.wraps(add_to_role) def add_to_role( self, role: dict, user_id: int = None, email: str = None, container_path: str = None ): pass @functools.wraps(create_user) def create_user(self, email: str, container_path: str = None, send_email=False): pass @functools.wraps(deactivate_users) def deactivate_users(self, target_ids: List[int], container_path: str = None): pass @functools.wraps(delete_users) def delete_users(self, target_ids: List[int], container_path: str = None): pass @functools.wraps(get_roles) def get_roles(self, container_path: str = None): pass @functools.wraps(get_user_by_email) def get_user_by_email(self, email: str): pass @functools.wraps(list_groups) def list_groups(self, include_site_groups: bool = False, container_path: str = None): pass @functools.wraps(remove_from_group) def remove_from_group( self, user_ids: Union[int, List[int]], group_id, container_path: str = None ): pass @functools.wraps(remove_from_role) def remove_from_role( self, role: dict, user_id: int = None, email: str = None, container_path: str = None ): pass @functools.wraps(reset_password) def reset_password(self, email: str, container_path: str = None): pass @functools.wraps(impersonate_user) def impersonate_user(self, user_id: int = None, email: str = None, container_path: str = None): pass @functools.wraps(stop_impersonating) def stop_impersonating(self): pass @functools.wraps(who_am_i) def who_am_i(self): pass
32
1
3
0
3
0
1
0.05
0
5
1
0
16
1
16
16
75
16
56
41
16
3
33
18
16
1
0
0
16
144,881
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.TestExecuteSQL
class TestExecuteSQL(unittest.TestCase): def setUp(self): self.service = MockExecuteSQL() sql = "select * from " + schema + "." + query self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"sql": waf_encode(sql), "schemaName": schema}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), schema, sql] def test_success(self): test = self success_test( test, self.service.get_successful_response(), execute_sql, True, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), execute_sql, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), execute_sql, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), execute_sql, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), execute_sql, *self.args, **self.expected_kwargs )
class TestExecuteSQL(unittest.TestCase): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
7
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
68
6
62
16
55
0
21
16
14
1
2
0
6
144,882
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/labkey/query.py
labkey.query.QueryWrapper
class QueryWrapper: """ Wrapper for all of the API methods exposed in the query module. Used by the APIWrapper class. """ def __init__(self, server_context: ServerContext): self.server_context = server_context @functools.wraps(delete_rows) def delete_rows( self, schema_name: str, query_name: str, rows: any, container_path: str = None, transacted: bool = True, audit_behavior: AuditBehavior = None, audit_user_comment: str = None, timeout: int = _default_timeout, ): return delete_rows( self.server_context, schema_name, query_name, rows, container_path, transacted, audit_behavior, audit_user_comment, timeout, ) @functools.wraps(truncate_table) def truncate_table( self, schema_name, query_name, container_path=None, timeout=_default_timeout ): return truncate_table(self.server_context, schema_name, query_name, container_path, timeout) @functools.wraps(execute_sql) def execute_sql( self, schema_name: str, sql: str, container_path: str = None, max_rows: int = None, sort: str = None, offset: int = None, container_filter: str = None, save_in_session: bool = None, parameters: dict = None, required_version: float = None, timeout: int = _default_timeout, waf_encode_sql: bool = True, ): return execute_sql( self.server_context, schema_name, sql, container_path, max_rows, sort, offset, container_filter, save_in_session, parameters, required_version, timeout, waf_encode_sql, ) @functools.wraps(insert_rows) def insert_rows( self, schema_name: str, query_name: str, rows: List[any], container_path: str = None, skip_reselect_rows: bool = False, transacted: bool = True, audit_behavior: AuditBehavior = None, audit_user_comment: str = None, timeout: int = _default_timeout, ): return insert_rows( self.server_context, schema_name, query_name, rows, container_path, skip_reselect_rows, transacted, audit_behavior, audit_user_comment, timeout, ) @functools.wraps(import_rows) def import_rows( self, schema_name: str, query_name: str, data_file, container_path: str = None, insert_option: str = None, audit_behavior: str = None, import_lookup_by_alternate_key: bool = False, ): return import_rows( self.server_context, schema_name, query_name, data_file, container_path, insert_option, audit_behavior, import_lookup_by_alternate_key, ) @functools.wraps(select_rows) def select_rows( self, schema_name: str, query_name: str, view_name: str = None, filter_array: List[QueryFilter] = None, container_path: str = None, columns=None, max_rows: int = -1, sort: str = None, offset: int = None, container_filter: str = None, parameters: dict = None, show_rows: bool = None, include_total_count: bool = None, include_details_column: bool = None, include_update_column: bool = None, selection_key: str = None, required_version: float = None, timeout: int = _default_timeout, ignore_filter: bool = None, ): return select_rows( self.server_context, schema_name, query_name, view_name, filter_array, container_path, columns, max_rows, sort, offset, container_filter, parameters, show_rows, include_total_count, include_details_column, include_update_column, selection_key, required_version, timeout, ignore_filter, ) @functools.wraps(update_rows) def update_rows( self, schema_name: str, query_name: str, rows: List[any], container_path: str = None, transacted: bool = True, audit_behavior: AuditBehavior = None, audit_user_comment: str = None, timeout: int = _default_timeout, ): return update_rows( self.server_context, schema_name, query_name, rows, container_path, transacted, audit_behavior, audit_user_comment, timeout, ) @functools.wraps(move_rows) def move_rows( self, target_container_path: str, schema_name: str, query_name: str, rows: any, container_path: str = None, transacted: bool = True, audit_behavior: AuditBehavior = None, audit_user_comment: str = None, timeout: int = _default_timeout, ): return move_rows( self.server_context, target_container_path, schema_name, query_name, rows, container_path, transacted, audit_behavior, audit_user_comment, timeout, )
class QueryWrapper: ''' Wrapper for all of the API methods exposed in the query module. Used by the APIWrapper class. ''' def __init__(self, server_context: ServerContext): pass @functools.wraps(delete_rows) def delete_rows( self, schema_name: str, query_name: str, rows: any, container_path: str = None, transacted: bool = True, audit_behavior: AuditBehavior = None, audit_user_comment: str = None, timeout: int = _default_timeout, ): pass @functools.wraps(truncate_table) def truncate_table( self, schema_name, query_name, container_path=None, timeout=_default_timeout ): pass @functools.wraps(execute_sql) def execute_sql( self, schema_name: str, sql: str, container_path: str = None, max_rows: int = None, sort: str = None, offset: int = None, container_filter: str = None, save_in_session: bool = None, parameters: dict = None, required_version: float = None, timeout: int = _default_timeout, waf_encode_sql: bool = True, ): pass @functools.wraps(insert_rows) def insert_rows( self, schema_name: str, query_name: str, rows: List[any], container_path: str = None, skip_reselect_rows: bool = False, transacted: bool = True, audit_behavior: AuditBehavior = None, audit_user_comment: str = None, timeout: int = _default_timeout, ): pass @functools.wraps(import_rows) def import_rows( self, schema_name: str, query_name: str, data_file, container_path: str = None, insert_option: str = None, audit_behavior: str = None, import_lookup_by_alternate_key: bool = False, ): pass @functools.wraps(select_rows) def select_rows( self, schema_name: str, query_name: str, view_name: str = None, filter_array: List[QueryFilter] = None, container_path: str = None, columns=None, max_rows: int = -1, sort: str = None, offset: int = None, container_filter: str = None, parameters: dict = None, show_rows: bool = None, include_total_count: bool = None, include_details_column: bool = None, include_update_column: bool = None, selection_key: str = None, required_version: float = None, timeout: int = _default_timeout, ignore_filter: bool = None, ): pass @functools.wraps(update_rows) def update_rows( self, schema_name: str, query_name: str, rows: List[any], container_path: str = None, transacted: bool = True, audit_behavior: AuditBehavior = None, audit_user_comment: str = None, timeout: int = _default_timeout, ): pass @functools.wraps(move_rows) def move_rows( self, target_container_path: str, schema_name: str, query_name: str, rows: any, container_path: str = None, transacted: bool = True, audit_behavior: AuditBehavior = None, audit_user_comment: str = None, timeout: int = _default_timeout, ): pass
18
1
21
0
21
0
1
0.01
0
8
3
0
9
1
9
9
213
9
201
107
95
3
19
11
9
1
0
0
9
144,883
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/labkey/experiment.py
labkey.experiment.ExperimentWrapper
class ExperimentWrapper: """ Wrapper for all of the API methods exposed in the experiment module. Used by the APIWrapper class. """ def __init__(self, server_context: ServerContext): self.server_context = server_context @functools.wraps(load_batch) def load_batch(self, assay_id: int, batch_id: int) -> Optional[Batch]: return load_batch(self.server_context, assay_id, batch_id) @functools.wraps(save_batch) def save_batch(self, assay_id: int, batch: Batch) -> Optional[Batch]: return save_batch(self.server_context, assay_id, batch) @functools.wraps(save_batches) def save_batches(self, assay_id: int, batches: List[Batch]) -> Optional[List[Batch]]: return save_batches(self.server_context, assay_id, batches) @functools.wraps(lineage) def lineage( self, lsids: List[str], children: bool = None, container_path: str = None, cpas_type: str = None, exp_type: str = None, depth: int = None, include_properties: bool = None, include_inputs_and_outputs: bool = None, include_run_steps: bool = None, parents: bool = None, run_protocol_lsid: str = None, ): return lineage( self.server_context, lsids, children, container_path, cpas_type, depth, exp_type, parents, include_inputs_and_outputs, include_properties, include_run_steps, run_protocol_lsid, )
class ExperimentWrapper: ''' Wrapper for all of the API methods exposed in the experiment module. Used by the APIWrapper class. ''' def __init__(self, server_context: ServerContext): pass @functools.wraps(load_batch) def load_batch(self, assay_id: int, batch_id: int) -> Optional[Batch]: pass @functools.wraps(save_batch) def save_batch(self, assay_id: int, batch: Batch) -> Optional[Batch]: pass @functools.wraps(save_batches) def save_batches(self, assay_id: int, batches: List[Batch]) -> Optional[List[Batch]]: pass @functools.wraps(lineage) def lineage( self, lsids: List[str], children: bool = None, container_path: str = None, cpas_type: str = None, exp_type: str = None, depth: int = None, include_properties: bool = None, include_inputs_and_outputs: bool = None, include_run_steps: bool = None, parents: bool = None, run_protocol_lsid: str = None, ): pass
10
1
7
0
7
0
1
0.07
0
5
2
0
5
1
5
5
49
5
41
24
18
3
11
7
5
1
0
0
5
144,884
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/domain.py
labkey.domain.FieldIndex
class FieldIndex: def __init__(self, **kwargs): self.column_names = kwargs.pop("column_names", kwargs.pop("columnNames", None)) self.unique = kwargs.pop("unique", None) def to_json(self, strip_none=True): data = {"columnNames": self.column_names, "unique": self.unique} return strip_none_values(data, strip_none)
class FieldIndex: def __init__(self, **kwargs): pass def to_json(self, strip_none=True): pass
3
0
4
1
3
0
1
0
0
0
0
0
2
2
2
2
9
2
7
6
4
0
7
6
4
1
0
0
2
144,885
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_query_api.py
unit.test_query_api.TestUpdateRows
class TestUpdateRows(unittest.TestCase): def setUp(self): self.service = MockUpdateRows() rows = "{id:1234}" self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": '{"queryName": "' + query + '", "rows": "' + rows + '", "schemaName": "' + schema + '"}', "headers": {"Content-Type": "application/json"}, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), schema, query, rows] def test_success(self): test = self success_test( test, self.service.get_successful_response(), update_rows, True, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), update_rows, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), update_rows, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), update_rows, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), update_rows, *self.args, **self.expected_kwargs )
class TestUpdateRows(unittest.TestCase): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
7
0
12
1
11
0
1
0
1
5
5
0
6
3
6
78
76
8
68
16
61
0
21
16
14
1
2
0
6
144,886
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.MockSecurityController
class MockSecurityController(MockLabKey): default_action = "security" default_success_body = {"success": True} use_ssl = False
class MockSecurityController(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
8
0
0
0
9
4
0
4
4
3
0
4
4
3
0
1
0
0
144,887
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.MockUserController
class MockUserController(MockLabKey): default_action = "user" default_success_body = {"success": True, "status_code": 200} use_ssl = False
class MockUserController(MockLabKey): pass
1
0
0
0
0
0
0
0
1
0
0
3
0
0
0
9
4
0
4
4
3
0
4
4
3
0
1
0
0
144,888
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestActivateUsers
class TestActivateUsers(unittest.TestCase): __user_id = [123] class MockActivateUser(MockUserController): api = "activateUsers.api" def setUp(self): self.service = self.MockActivateUser() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"userId": [123]}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.__user_id] def test_success(self): test = self success_test( test, self.service.get_successful_response(), activate_users, True, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), activate_users, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), activate_users, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), activate_users, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), activate_users, *self.args, **self.expected_kwargs )
class TestActivateUsers(unittest.TestCase): class MockActivateUser(MockUserController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
72
8
64
18
56
0
23
18
15
1
2
0
6
144,889
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestAddToGroup
class TestAddToGroup(unittest.TestCase): __user_id = 321 __group_id = 123 class MockAddGroupMember(MockSecurityController): api = "addGroupMember.api" def setUp(self): self.service = self.MockAddGroupMember() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"groupId": 123, "principalIds": [321]}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.__user_id, self.__group_id] def test_success(self): test = self success_test( test, self.service.get_successful_response(), add_to_group, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), add_to_group, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), add_to_group, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), add_to_group, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), add_to_group, *self.args, **self.expected_kwargs )
class TestAddToGroup(unittest.TestCase): class MockAddGroupMember(MockSecurityController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
73
8
65
19
57
0
24
19
16
1
2
0
6
144,890
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestAddToRole
class TestAddToRole(unittest.TestCase): __user_id = 321 __email = "pyTest@labkey.com" __role = {"uniqueName": "TestRole"} class MockAddRole(MockSecurityController): api = "addAssignment.api" def setUp(self): self.service = self.MockAddRole() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": { "roleClassName": "TestRole", "principalId": 321, "email": "pyTest@labkey.com", }, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [ mock_server_context(self.service), self.__role, self.__user_id, self.__email, ] def test_success(self): test = self success_test( test, self.service.get_successful_response(), add_to_role, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), add_to_role, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), add_to_role, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), add_to_role, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), add_to_role, *self.args, **self.expected_kwargs )
class TestAddToRole(unittest.TestCase): class MockAddRole(MockSecurityController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
12
0
12
0
1
0
1
5
5
0
6
3
6
78
83
8
75
20
67
0
25
20
17
1
2
0
6
144,891
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestCreateUser
class TestCreateUser(unittest.TestCase): __email = "pyTest@labkey.com" class MockCreateUser(MockSecurityController): api = "createNewUser.api" def setUp(self): self.service = self.MockCreateUser() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"email": TestCreateUser.__email, "sendEmail": False}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.__email] def test_success(self): test = self success_test( test, self.service.get_successful_response(), create_user, True, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), create_user, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), create_user, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), create_user, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), create_user, *self.args, **self.expected_kwargs )
class TestCreateUser(unittest.TestCase): class MockCreateUser(MockSecurityController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
72
8
64
18
56
0
23
18
15
1
2
0
6
144,892
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestDeactivateUsers
class TestDeactivateUsers(unittest.TestCase): __user_id = [123] class MockDeactivateUser(MockUserController): api = "deactivateUsers.view" def setUp(self): self.service = self.MockDeactivateUser() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"userId": [123]}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.__user_id] def test_success(self): test = self success_test( test, self.service.get_successful_response(), deactivate_users, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), deactivate_users, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), deactivate_users, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), deactivate_users, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), deactivate_users, *self.args, **self.expected_kwargs )
class TestDeactivateUsers(unittest.TestCase): class MockDeactivateUser(MockUserController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
72
8
64
18
56
0
23
18
15
1
2
0
6
144,893
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestDeleteUsers
class TestDeleteUsers(unittest.TestCase): __user_id = [123] class MockDeleteUser(MockUserController): api = "deleteUsers.view" def setUp(self): self.service = self.MockDeleteUser() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"userId": [123]}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.__user_id] def test_success(self): test = self success_test( test, self.service.get_successful_response(), delete_users, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), delete_users, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), delete_users, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), delete_users, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), delete_users, *self.args, **self.expected_kwargs )
class TestDeleteUsers(unittest.TestCase): class MockDeleteUser(MockUserController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
72
8
64
18
56
0
23
18
15
1
2
0
6
144,894
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestGetRoles
class TestGetRoles(unittest.TestCase): class MockGetRoles(MockSecurityController): api = "getRoles.api" def setUp(self): self.service = self.MockGetRoles() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": None, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service)] def test_success(self): test = self success_test( test, self.service.get_successful_response(), get_roles, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), get_roles, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), get_roles, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), get_roles, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), get_roles, *self.args, **self.expected_kwargs )
class TestGetRoles(unittest.TestCase): class MockGetRoles(MockSecurityController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
70
7
63
17
55
0
22
17
14
1
2
0
6
144,895
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestListGroups
class TestListGroups(unittest.TestCase): class MockListGroups(MockSecurityController): api = "listProjectGroups.api" def setUp(self): self.service = self.MockListGroups() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"includeSiteGroups": True}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), True] def test_success(self): test = self success_test( test, self.service.get_successful_response(), list_groups, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), list_groups, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), list_groups, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), list_groups, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), list_groups, *self.args, **self.expected_kwargs )
class TestListGroups(unittest.TestCase): class MockListGroups(MockSecurityController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
70
7
63
17
55
0
22
17
14
1
2
0
6
144,896
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestRemoveFromGroup
class TestRemoveFromGroup(unittest.TestCase): __user_id = 321 __group_id = 123 class MockRemoveGroupMember(MockSecurityController): api = "removeGroupMember.api" def setUp(self): self.service = self.MockRemoveGroupMember() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"groupId": 123, "principalIds": [321]}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.__user_id, self.__group_id] def test_success(self): test = self success_test( test, self.service.get_successful_response(), remove_from_group, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), remove_from_group, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), remove_from_group, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), remove_from_group, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), remove_from_group, *self.args, **self.expected_kwargs )
class TestRemoveFromGroup(unittest.TestCase): class MockRemoveGroupMember(MockSecurityController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
73
8
65
19
57
0
24
19
16
1
2
0
6
144,897
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestRemoveFromRole
class TestRemoveFromRole(unittest.TestCase): __user_id = 321 __email = "pyTest@labkey.com" __role = {"uniqueName": "TestRole"} class MockRemoveRole(MockSecurityController): api = "removeAssignment.api" def setUp(self): self.service = self.MockRemoveRole() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": { "roleClassName": "TestRole", "principalId": 321, "email": "pyTest@labkey.com", }, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [ mock_server_context(self.service), self.__role, self.__user_id, self.__email, ] def test_success(self): test = self success_test( test, self.service.get_successful_response(), remove_from_role, False, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), remove_from_role, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), remove_from_role, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), remove_from_role, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), remove_from_role, *self.args, **self.expected_kwargs )
class TestRemoveFromRole(unittest.TestCase): class MockRemoveRole(MockSecurityController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
12
0
12
0
1
0
1
5
5
0
6
3
6
78
83
8
75
20
67
0
25
20
17
1
2
0
6
144,898
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/test_security.py
unit.test_security.TestResetPassword
class TestResetPassword(unittest.TestCase): __email = "pyTest@labkey.com" class MockResetPassword(MockSecurityController): api = "adminRotatePassword.api" def setUp(self): self.service = self.MockResetPassword() self.expected_kwargs = { "expected_args": [self.service.get_server_url()], "data": {"email": TestResetPassword.__email}, "headers": None, "timeout": 300, "allow_redirects": False, } self.args = [mock_server_context(self.service), self.__email] def test_success(self): test = self success_test( test, self.service.get_successful_response(), reset_password, True, *self.args, **self.expected_kwargs ) def test_unauthorized(self): test = self throws_error_test( test, RequestAuthorizationError, self.service.get_unauthorized_response(), reset_password, *self.args, **self.expected_kwargs ) def test_query_not_found(self): test = self throws_error_test( test, QueryNotFoundError, self.service.get_query_not_found_response(), reset_password, *self.args, **self.expected_kwargs ) def test_server_not_found(self): test = self throws_error_test( test, ServerNotFoundError, self.service.get_server_not_found_response(), reset_password, *self.args, **self.expected_kwargs ) def test_general_error(self): test = self throws_error_test( test, RequestError, self.service.get_general_error_response(), reset_password, *self.args, **self.expected_kwargs )
class TestResetPassword(unittest.TestCase): class MockResetPassword(MockSecurityController): def setUp(self): pass def test_success(self): pass def test_unauthorized(self): pass def test_query_not_found(self): pass def test_server_not_found(self): pass def test_general_error(self): pass
8
0
10
0
10
0
1
0
1
5
5
0
6
3
6
78
72
8
64
18
56
0
23
18
15
1
2
0
6
144,899
LabKey/labkey-api-python
LabKey_labkey-api-python/test/unit/utilities.py
unit.utilities.MockLabKey
class MockLabKey: api = "" default_protocol = "https://" default_server = "my_testServer:8080" default_context_path = "testPath" default_project_path = "testProject/subfolder" default_action = "query" default_success_body = "" default_unauthorized_body = "" default_server_not_found_body = "" default_query_not_found_body = "" default_general_server_error_body = "" default_api_key = None def __init__(self, **kwargs): self.protocol = kwargs.pop("protocol", self.default_protocol) self.server_name = kwargs.pop("server_name", self.default_server) self.context_path = kwargs.pop("context_path", self.default_context_path) self.project_path = kwargs.pop("project_path", self.default_project_path) self.action = kwargs.pop("action", self.default_action) self.success_body = kwargs.pop("success_body", self.default_success_body) self.unauthorized_body = kwargs.pop("unauthorized_body", self.default_unauthorized_body) self.server_not_found_body = kwargs.pop( "server_not_found_body", self.default_server_not_found_body ) self.query_not_found_body = kwargs.pop( "query_not_found_body", self.default_query_not_found_body ) self.general_server_error_body = kwargs.pop( "general_server_error_body", self.default_general_server_error_body ) self.api_key = kwargs.pop("api_key", self.default_api_key) def _get_mock_response(self, code, url, body): mock_response = mock.Mock(requests.Response) mock_response.status_code = code mock_response.url = url mock_response.text = body mock_response.json.return_value = mock_response.text return mock_response def get_server_url(self): return "{protocol}{server}/{context}/{container}/{action}-{api}".format( protocol=self.protocol, server=self.server_name, context=self.context_path, container=self.project_path, action=self.action, api=self.api, ) def get_successful_response(self, code=200): return self._get_mock_response(code, self.get_server_url(), self.success_body) def get_unauthorized_response(self, code=401): return self._get_mock_response(code, self.get_server_url(), self.unauthorized_body) def get_server_not_found_response(self, code=404): response = self._get_mock_response(code, self.get_server_url(), self.server_not_found_body) # calling json() on empty response body causes a ValueError response.json.side_effect = ValueError() return response def get_query_not_found_response(self, code=404): return self._get_mock_response(code, self.get_server_url(), self.query_not_found_body) def get_general_error_response(self, code=500): return self._get_mock_response(code, self.get_server_url(), self.general_server_error_body) def get_csrf_response(self, code=200): return self._get_mock_response(code, self.get_server_url(), {"CSRF": "MockCSRF"})
class MockLabKey: def __init__(self, **kwargs): pass def _get_mock_response(self, code, url, body): pass def get_server_url(self): pass def get_successful_response(self, code=200): pass def get_unauthorized_response(self, code=401): pass def get_server_not_found_response(self, code=404): pass def get_query_not_found_response(self, code=404): pass def get_general_error_response(self, code=500): pass def get_csrf_response(self, code=200): pass
10
0
5
0
5
0
1
0.02
0
3
0
16
9
11
9
9
71
9
61
35
51
1
48
35
38
1
0
0
9
144,900
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/labkey/domain.py
labkey.domain.DomainWrapper
class DomainWrapper: """ Wrapper for all of the API methods exposed in the domain module. Used by the APIWrapper class. """ def __init__(self, server_context: ServerContext): self.server_context = server_context @functools.wraps(create) def create(self, domain_definition: dict, container_path: str = None): return create(self.server_context, domain_definition, container_path) @functools.wraps(drop) def drop(self, schema_name: str, query_name: str, container_path: str = None): return drop(self.server_context, schema_name, query_name, container_path) @functools.wraps(get) def get(self, schema_name: str, query_name: str, container_path: str = None): return get(self.server_context, schema_name, query_name, container_path) @functools.wraps(get_domain_details) def get_domain_details( self, schema_name: str = None, query_name: str = None, domain_id: int = None, domain_kind: str = None, container_path: str = None, ): return get_domain_details( self.server_context, schema_name, query_name, domain_id, domain_kind, container_path ) @functools.wraps(infer_fields) def infer_fields(self, data_file: any, container_path: str = None): return infer_fields(self.server_context, data_file, container_path) @functools.wraps(save) def save( self, schema_name: str, query_name: str, domain: Domain, container_path: str = None, options: Dict = None, ): return save(self.server_context, schema_name, query_name, domain, container_path, options)
class DomainWrapper: ''' Wrapper for all of the API methods exposed in the domain module. Used by the APIWrapper class. ''' def __init__(self, server_context: ServerContext): pass @functools.wraps(create) def create(self, domain_definition: dict, container_path: str = None): pass @functools.wraps(drop) def drop(self, schema_name: str, query_name: str, container_path: str = None): pass @functools.wraps(get) def get(self, schema_name: str, query_name: str, container_path: str = None): pass @functools.wraps(get_domain_details) def get_domain_details( self, schema_name: str = None, query_name: str = None, domain_id: int = None, domain_kind: str = None, container_path: str = None, ): pass @functools.wraps(infer_fields) def infer_fields(self, data_file: any, container_path: str = None): pass @functools.wraps(save) def save( self, schema_name: str, query_name: str, domain: Domain, container_path: str = None, options: Dict = None, ): pass
14
1
4
0
4
0
1
0.08
0
5
2
0
7
1
7
7
47
7
37
29
9
3
15
9
7
1
0
0
7
144,901
LabKey/labkey-api-python
/Users/umroot/Documents/PhD_works/PhD-Core-Contents/Class-level-dataset-curation/data/git_repos_for_analysis/LabKey_labkey-api-python/labkey/query.py
labkey.query.QueryFilter.Types
class Types: """ Enumeration of acceptable filter types """ # These operators require a data value EQUAL = "eq" DATE_EQUAL = "dateeq" NEQ = "neq" NOT_EQUAL = "neq" DATE_NOT_EQUAL = "dateneq" NEQ_OR_NULL = "neqornull" NOT_EQUAL_OR_MISSING = "neqornull" GT = "gt" GREATER_THAN = "gt" DATE_GREATER_THAN = "dategt" LT = "lt" LESS_THAN = "lt" DATE_LESS_THAN = "datelt" GTE = "gte" GREATER_THAN_OR_EQUAL = "gte" DATE_GREATER_THAN_OR_EQUAL = "dategte" LTE = "lte" LESS_THAN_OR_EQUAL = "lte" DATE_LESS_THAN_OR_EQUAL = "datelte" STARTS_WITH = "startswith" DOES_NOT_START_WITH = "doesnotstartwith" CONTAINS = "contains" DOES_NOT_CONTAIN = "doesnotcontain" CONTAINS_ONE_OF = "containsoneof" CONTAINS_NONE_OF = "containsnoneof" IN = "in" EQUALS_ONE_OF = "in" NOT_IN = "notin" EQUALS_NONE_OF = "notin" BETWEEN = "between" NOT_BETWEEN = "notbetween" MEMBER_OF = "memberof" # These are the "no data value" operators HAS_ANY_VALUE = "" IS_BLANK = "isblank" IS_NOT_BLANK = "isnonblank" HAS_MISSING_VALUE = "hasmvvalue" DOES_NOT_HAVE_MISSING_VALUE = "nomvvalue" # Table/Query-wise operators Q = "q" # Ontology operators ONTOLOGY_IN_SUBTREE = "concept:insubtree" ONTOLOGY_NOT_IN_SUBTREE = "concept:notinsubtree" # Lineage operators EXP_CHILD_OF = "exp:childof" EXP_PARENT_OF = "exp:parentof" EXP_LINEAGE_OF = "exp:lineageof"
class Types: ''' Enumeration of acceptable filter types ''' pass
1
1
0
0
0
0
0
0.18
0
0
0
0
0
0
0
0
73
21
44
44
43
8
44
44
43
0
0
0
0
144,902
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/domain.py
labkey.domain.DomainDefinition
class DomainDefinition: def __init__(self, **kwargs): self.create_domain = kwargs.pop("create_domain", None) self.domain_design = kwargs.pop("domain_design", None) self.domain_group = kwargs.pop("domain_group", None) self.domain_template = kwargs.pop("domain_template", None) self.import_data = kwargs.pop("import_data", None) self.kind = kwargs.pop("kind", None) self.module = kwargs.pop("module", None) self.options = kwargs.pop("options", None)
class DomainDefinition: def __init__(self, **kwargs): pass
2
0
9
0
9
0
1
0
0
0
0
0
1
8
1
1
10
0
10
10
8
0
10
10
8
1
0
0
1
144,903
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/domain.py
labkey.domain.PropertyValidator
class PropertyValidator: def __init__(self, **kwargs): self.description = kwargs.pop("description", None) self.error_message = kwargs.pop("error_message", kwargs.pop("errorMessage", None)) self.expression = kwargs.pop("expression", None) self.name = kwargs.pop("name", None) self.new = kwargs.pop("new", None) self.properties = kwargs.pop("properties", None) self.row_id = kwargs.pop("row_id", kwargs.pop("rowId", None)) self.type = kwargs.pop("type", None) def to_json(self, strip_none=True): data = { "description": self.description, "errorMessage": self.error_message, "expression": self.expression, "name": self.name, "new": self.new, "properties": self.properties, "rowId": self.row_id, "type": self.type, } return strip_none_values(data, strip_none)
class PropertyValidator: def __init__(self, **kwargs): pass def to_json(self, strip_none=True): pass
3
0
11
1
11
0
1
0
0
0
0
0
2
8
2
2
24
2
22
12
19
0
13
12
10
1
0
0
2
144,904
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/domain.py
labkey.domain.ConditionalFormat
class ConditionalFormat: def __init__(self, **kwargs): self.background_color = kwargs.pop("background_color", kwargs.pop("backgroundColor", None)) self.bold = kwargs.pop("bold", None) self.filter = kwargs.pop("filter", None) self.italic = kwargs.pop("italic", None) self.strike_through = kwargs.pop("strike_through", kwargs.pop("strikethrough", None)) self.text_color = kwargs.pop("text_color", kwargs.pop("textColor", None)) def to_json(self): data = { "backgroundcolor": self.background_color, "bold": self.bold, "filter": self.filter, "italic": self.italic, "strikethrough": self.strike_through, "textcolor": self.text_color, } return data
class ConditionalFormat: def __init__(self, **kwargs): pass def to_json(self): pass
3
0
9
1
9
0
1
0
0
0
0
0
2
6
2
2
20
2
18
10
15
0
11
10
8
1
0
0
2
144,905
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/container.py
labkey.container.ContainerWrapper
class ContainerWrapper: """ Wrapper for all the API methods exposed in the container module. Used by the APIWrapper class. """ def __init__(self, server_context: ServerContext): self.server_context = server_context def create( self, name: str, container_path: str = None, description: str = None, folder_type: str = None, is_workbook: bool = None, title: str = None, ): return create( self.server_context, name, container_path, description, folder_type, is_workbook, title ) def delete(self, container_path: str = None): return delete(self.server_context, container_path) def rename( self, name: str = None, title: str = None, add_alias: bool = True, container_path: str = None, ): return rename(self.server_context, name, title, add_alias, container_path) def get_containers( self, container_path: str = None, include_effective_permissions: bool = True, include_subfolders: bool = True, depth: int = 50, include_standard_properties: bool = True, ): return get_containers( self.server_context, container_path, include_effective_permissions, include_subfolders, depth, include_standard_properties, )
class ContainerWrapper: ''' Wrapper for all the API methods exposed in the container module. Used by the APIWrapper class. ''' def __init__(self, server_context: ServerContext): pass def create( self, name: str, container_path: str = None, description: str = None, folder_type: str = None, is_workbook: bool = None, title: str = None, ): pass def delete(self, container_path: str = None): pass def rename( self, name: str = None, title: str = None, add_alias: bool = True, container_path: str = None, ): pass def get_containers( self, container_path: str = None, include_effective_permissions: bool = True, include_subfolders: bool = True, depth: int = 50, include_standard_properties: bool = True, ): pass
6
1
8
0
8
0
1
0.07
0
4
1
0
5
1
5
5
49
5
41
28
14
3
11
7
5
1
0
0
5
144,906
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/api_wrapper.py
labkey.api_wrapper.APIWrapper
class APIWrapper: """ Wrapper for all of the supported API methods in the Python Client API. Makes it easier to use the supported API methods without having to manually pass around a ServerContext object. """ def __init__( self, domain, container_path, context_path=None, use_ssl=True, verify_ssl=True, api_key=None, disable_csrf=False, allow_redirects=False, ): self.server_context = ServerContext( domain=domain, container_path=container_path, context_path=context_path, use_ssl=use_ssl, verify_ssl=verify_ssl, api_key=api_key, disable_csrf=disable_csrf, allow_redirects=allow_redirects, ) self.container = ContainerWrapper(self.server_context) self.domain = DomainWrapper(self.server_context) self.experiment = ExperimentWrapper(self.server_context) self.query = QueryWrapper(self.server_context) self.security = SecurityWrapper(self.server_context) self.storage = StorageWrapper(self.server_context)
class APIWrapper: ''' Wrapper for all of the supported API methods in the Python Client API. Makes it easier to use the supported API methods without having to manually pass around a ServerContext object. ''' def __init__( self, domain, container_path, context_path=None, use_ssl=True, verify_ssl=True, api_key=None, disable_csrf=False, allow_redirects=False, ): pass
2
1
27
0
27
0
1
0.14
0
7
7
0
1
7
1
1
33
1
28
19
16
4
9
9
7
1
0
0
1
144,907
LabKey/labkey-api-python
LabKey_labkey-api-python/labkey/domain.py
labkey.domain.Domain
class Domain: def __init__(self, **kwargs): self.container = kwargs.pop("container", None) self.description = kwargs.pop("description", None) self.domain_id = kwargs.pop("domain_id", kwargs.pop("domainId", None)) self.domain_uri = kwargs.pop("domain_uri", kwargs.pop("domainURI", None)) self.name = kwargs.pop("name", None) self.query_name = kwargs.pop("query_name", kwargs.pop("queryName", None)) self.schema_name = kwargs.pop("schema_name", kwargs.pop("schemaName", None)) self.template_description = kwargs.pop( "template_description", kwargs.pop("templateDescription", None) ) fields = kwargs.pop("fields", []) fields_instances = [] for field in fields: fields_instances.append(PropertyDescriptor(**field)) self.fields = fields_instances indices = kwargs.pop("indices", []) indices_instances = [] for index in indices: indices_instances.append(FieldIndex(**index)) self.indices = indices_instances def add_field(self, field: Union[dict, PropertyDescriptor]): if isinstance(field, PropertyDescriptor): _field = field else: _field = PropertyDescriptor(**field) if _field is not None: self.fields.append(_field) return self def to_json(self, strip_none=True): data = { "container": self.container, "description": self.description, "domainId": self.domain_id, "domainURI": self.domain_uri, "name": self.name, "queryName": self.query_name, "schemaName": self.schema_name, "templateDescription": self.template_description, } json_fields = [] for field in self.fields: json_fields.append(field.to_json()) data["fields"] = json_fields json_indices = [] for index in self.indices: json_indices.append(index.to_json()) data["indices"] = json_indices return strip_none_values(data, strip_none)
class Domain: def __init__(self, **kwargs): pass def add_field(self, field: Union[dict, PropertyDescriptor]): pass def to_json(self, strip_none=True): pass
4
0
20
4
16
0
3
0
0
3
2
0
3
10
3
3
63
13
50
26
46
0
38
26
34
3
0
1
9
144,908
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.asset_item
class asset_item: """ Stores a single item from a steam asset catalog """ def __init__(self, asset, catalog): self._catalog = catalog self._asset = asset def __str__(self): return self.name + " " + str(self.price) def _calculate_price(self, base=False): asset = self._asset pricemap = asset["prices"] if base: pricemap = asset.get("original_prices", pricemap) return dict([(currency, float(price) / 100) for currency, price in pricemap.items()]) @property def tags(self): """ Returns a dict containing tags and their localized labels as values """ return dict([(t, self._catalog.tags.get(t, t)) for t in self._asset.get("tags", [])]) @property def base_price(self): """ The price the item normally goes for, not including discounts. """ return self._calculate_price(base=True) @property def price(self): """ Returns the most current price available, which may include sales/discounts """ return self._calculate_price(base = False) @property def name(self): """ The asset "name" which is in fact a schema id of item. """ return self._asset.get("name")
class asset_item: ''' Stores a single item from a steam asset catalog ''' def __init__(self, asset, catalog): pass def __str__(self): pass def _calculate_price(self, base=False): pass @property def tags(self): ''' Returns a dict containing tags and their localized labels as values ''' pass @property def base_price(self): ''' The price the item normally goes for, not including discounts. ''' pass @property def price(self): ''' Returns the most current price available, which may include sales/discounts ''' pass @property def name(self): ''' The asset "name" which is in fact a schema id of item. ''' pass
12
5
4
0
3
1
1
0.21
0
3
0
0
7
2
7
7
38
9
24
17
12
5
20
12
12
2
0
1
8
144,909
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.assets
class assets(object): """ Class for building asset catalogs """ @property def _assets(self): if self._cache: return self._cache try: assets = dict([(asset["name"], asset) for asset in self._api["result"]["assets"]]) tags = self._api["result"].get("tags", {}) except KeyError: raise AssetError("Empty or corrupt asset catalog") self._cache = { "items": assets, "tags": tags } return self._cache @property def tags(self): """ Returns a dict that is a map of the internal tag names for this catalog to the localized labels. """ return self._assets["tags"] def __contains__(self, key): """ Returns a whether a given asset ID exists within this catalog or not. """ try: key = key.schema_id except AttributeError: pass return str(key) in self._assets["items"] def __getitem__(self, key): """ Returns an 'asset_item' for a given asset ID """ assets = self._assets["items"] try: key = key.schema_id except AttributeError: pass return asset_item(assets[str(key)], self) def __iter__(self): return next(self) def __next__(self): # This was previously sorted, but I don't think order matters here. # Does it? data = list(self._assets["items"].values()) iterindex = 0 while iterindex < len(data): ydata = asset_item(data[iterindex], self) iterindex += 1 yield ydata next = __next__ def __init__(self, app, lang=None, **kwargs): """ lang: Language of asset tags, defaults to english currency: The iso 4217 currency code, returns all currencies by default """ self._language = loc.language(lang).code self._app = app self._cache = {} self._api = api.interface("ISteamEconomy").GetAssetPrices(language=self._language, appid=self._app, **kwargs)
class assets(object): ''' Class for building asset catalogs ''' @property def _assets(self): pass @property def tags(self): ''' Returns a dict that is a map of the internal tag names for this catalog to the localized labels. ''' pass def __contains__(self, key): ''' Returns a whether a given asset ID exists within this catalog or not. ''' pass def __getitem__(self, key): ''' Returns an 'asset_item' for a given asset ID ''' pass def __iter__(self): pass def __next__(self): pass def __init__(self, app, lang=None, **kwargs): ''' lang: Language of asset tags, defaults to english currency: The iso 4217 currency code, returns all currencies by default ''' pass
10
5
9
1
6
1
2
0.22
1
9
4
0
7
4
7
7
73
17
46
20
36
10
41
18
33
3
1
1
12
144,910
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.inventory
class inventory(object): """ Wrapper around player inventory. """ @property def _inv(self): if self._cache: return self._cache status = None try: status = self._api["result"]["status"] items = self._api["result"]["items"] except KeyError: # Only try to check status code if items don't exist (why error out # when items are there) if status is not None: if status == 8: raise BadID64Error("Bad Steam ID64 given") elif status == 15: raise ProfilePrivateError("Profile is private") raise InventoryError("Backpack data incomplete or corrupt") self._cache = { "items": items, "cells": self._api["result"].get("num_backpack_slots", len(items)) } return self._cache @property def cells_total(self): """ The total number of cells in the inventory. This can be used to determine if the user has bought an expander. This is NOT the number of items in the inventory, but how many items CAN be stored in it. The actual current inventory size can be obtained by calling len on an inventory object """ return self._inv["cells"] def __getitem__(self, key): key = str(key) for item in self: if str(item.id) == key or str(item.original_id) == key: return item raise KeyError(key) def __iter__(self): return next(self) def __len__(self): return len(self._inv["items"]) def __next__(self): iterindex = 0 iterdata = self._inv["items"] while(iterindex < len(iterdata)): data = item(iterdata[iterindex], self._schema) iterindex += 1 yield data next = __next__ def __init__(self, profile, app, schema=None, **kwargs): """ 'profile': A user ID or profile object. 'app': Steam app to get the inventory for. 'schema': The schema to use for item lookup. """ self._app = app self._schema = schema self._cache = {} try: sid = profile.id64 except: sid = str(profile) self._api = api.interface("IEconItems_" + str(self._app)).GetPlayerItems(SteamID=sid, **kwargs)
class inventory(object): ''' Wrapper around player inventory. ''' @property def _inv(self): pass @property def cells_total(self): ''' The total number of cells in the inventory. This can be used to determine if the user has bought an expander. This is NOT the number of items in the inventory, but how many items CAN be stored in it. The actual current inventory size can be obtained by calling len on an inventory object ''' pass def __getitem__(self, key): pass def __iter__(self): pass def __len__(self): pass def __next__(self): pass def __init__(self, profile, app, schema=None, **kwargs): ''' 'profile': A user ID or profile object. 'app': Steam app to get the inventory for. 'schema': The schema to use for item lookup. ''' pass
10
3
10
1
7
2
2
0.25
1
7
5
0
7
4
7
7
79
15
51
21
41
13
45
19
37
6
1
3
16
144,911
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.item
class item(object): """ Stores a single inventory item. """ @property def attributes(self): """ Returns a list of attributes """ overridden_attrs = self._attributes sortmap = {"neutral": 1, "positive": 2, "negative": 3} sortedattrs = list(overridden_attrs.values()) sortedattrs.sort(key=operator.itemgetter("defindex")) sortedattrs.sort(key=lambda t: sortmap.get(t.get("effect_type", "neutral"), 99)) return [item_attribute(theattr) for theattr in sortedattrs] @property def quality(self): """ Returns a tuple containing ID, name, and localized name of the quality """ return self._quality @property def inventory_token(self): """ Returns the item's inventory token (a bitfield), deprecated. """ return self._item.get("inventory", 0) @property def position(self): """ Returns a position in the inventory or -1 if there's no position available (i.e. an item hasn't dropped yet or got displaced) """ inventory_token = self.inventory_token if inventory_token == 0: return -1 else: return inventory_token & 0xFFFF @property def equipped(self): """ Returns a dict of classes that have the item equipped and in what slot """ equipped = self._item.get("equipped", []) # WORKAROUND: 0 is probably an off-by-one error # WORKAROUND: 65535 actually serves a purpose (according to Valve) return dict([(eq["class"], eq["slot"]) for eq in equipped if eq["class"] != 0 and eq["slot"] != 65535]) @property def equipable_classes(self): """ Returns a list of classes that _can_ use the item. """ sitem = self._schema_item return [c for c in sitem.get("used_by_classes", self.equipped.keys()) if c] @property def schema_id(self): """ Returns the item's ID in the schema. """ return self._item["defindex"] @property def name(self): """ Returns the item's undecorated name """ return self._schema_item.get("item_name", str(self.id)) @property def type(self): """ Returns the item's type. e.g. "Kukri" for the Tribalman's Shiv. If Valve failed to provide a translation the type will be the token without the hash prefix. """ return self._schema_item.get("item_type_name", '') @property def icon(self): """ URL to a small thumbnail sized image of the item, suitable for display in groups """ return self._schema_item.get("image_url", '') @property def image(self): """ URL to a full sized image of the item, for displaying 'zoomed-in' previews """ return self._schema_item.get("image_url_large", '') @property def id(self): """ Returns the item's unique serial number if it has one """ return self._item.get("id") @property def original_id(self): """ Returns the item's original ID if it has one. This is the last "version" of the item before it was customized or otherwise changed """ return self._item.get("original_id") @property def level(self): """ Returns the item's level (e.g. 10 for The Axtinguisher) if it has one """ return self._item.get("level") @property def slot_name(self): """ Returns the item's slot as a string, this includes "primary", "secondary", "melee", and "head". Note that this is the slot of the item as it appears in the schema, and not necessarily the actual equipable slot. (see 'equipped')""" return self._schema_item.get("item_slot") @property def cvar_class(self): """ Returns the item's class (what you use in the game to equip it, not the craft class)""" return self._schema_item.get("item_class") @property def craft_class(self): """ Returns the item's class in the crafting system if it has one. This includes hat, craft_bar, or craft_token. """ return self._schema_item.get("craft_class") @property def craft_material_type(self): return self._schema_item.get("craft_material_type") @property def custom_name(self): """ Returns the item's custom name if it has one. """ return self._item.get("custom_name") @property def custom_description(self): """ Returns the item's custom description if it has one. """ return self._item.get("custom_desc") @property def quantity(self): """ Returns the number of uses the item has, for example, a dueling mini-game has 5 uses by default """ return self._item.get("quantity", 1) @property def description(self): """ Returns the item's default description if it has one """ return self._schema_item.get("item_description") @property def min_level(self): """ Returns the item's minimum level (non-random levels will have the same min and max level) """ return self._schema_item.get("min_ilevel") @property def max_level(self): """ Returns the item's maximum level (non-random levels will have the same min and max level) """ return self._schema_item.get("max_ilevel") @property def contents(self): """ Returns the item in the container, if there is one. This will be a standard item object. """ rawitem = self._item.get("contained_item") if rawitem: return self.__class__(rawitem, self._schema) @property def tradable(self): """ Somewhat of a WORKAROUND since this flag is there sometimes, "cannot trade" is there sometimes and then there's "always tradable". Opposed to only occasionally tradable when it feels like it. Attr 153 = cannot trade """ return not (self._item.get("flag_cannot_trade") or (153 in self)) @property def craftable(self): """ Returns not craftable if the cannot craft flag exists. True, otherwise. """ return not self._item.get("flag_cannot_craft") @property def full_name(self): """ The full name of the item, generated depending on things such as its quality, rank, the schema language, and so on. """ qid, quality_str, pretty_quality_str = self.quality custom_name = self.custom_name item_name = self.name english = (self._language == "en_US") rank = self.rank prefixed = self._schema_item.get("proper_name", False) prefix = '' suffix = '' pfinal = '' if item_name.startswith("The ") and prefixed: item_name = item_name[4:] if quality_str != "unique" and quality_str != "normal": pfinal = pretty_quality_str if english: if prefixed: if quality_str == "unique": pfinal = "The" elif quality_str == "unique": pfinal = '' if rank and quality_str == "strange": pfinal = rank["name"] if english: prefix = pfinal elif pfinal: suffix = '(' + pfinal + ') ' + suffix return (prefix + " " + item_name + " " + suffix).strip() @property def kill_eaters(self): """ Returns a list of tuples containing the proper localized kill eater type strings and their values according to set/type/value "order" """ eaters = {} ranktypes = self._kill_types for attr in self: aname = attr.name.strip() aid = attr.id if aname.startswith("kill eater"): try: # Get the name prefix (matches up type and score and # determines the primary type for ranking) eateri = list(filter(None, aname.split(' ')))[-1] if eateri.isdigit(): eateri = int(eateri) else: # Probably the primary type/score which has no number eateri = 0 except IndexError: # Fallback to attr ID (will completely fail to make # anything legible but better than nothing) eateri = aid if aname.find("user") != -1: # User score types have lower sorting priority eateri += 100 eaters.setdefault(eateri, [None, None]) if aname.find("score type") != -1 or aname.find("kill type") != -1: # Score type attribute if eaters[eateri][0] is None: eaters[eateri][0] = attr.value else: # Value attribute eaters[eateri][1] = attr.value eaterlist = [] defaultleveldata = "KillEaterRank" for key, eater in sorted(eaters.items()): etype, count = eater # Eater type can be null (it still is in some older items), null # count means we're looking at either an uninitialized item or # schema item if count is not None: rank = ranktypes.get(etype or 0, {"level_data": defaultleveldata, "type_name": "Count"}) eaterlist.append((rank.get("level_data", defaultleveldata), rank["type_name"], count)) return eaterlist @property def rank(self): """ Returns the item's rank (if it has one) as a dict that includes required score, name, and level. """ if self._rank != {}: # Don't bother doing attribute lookups again return self._rank try: # The eater determining the rank levelkey, typename, count = self.kill_eaters[0] except IndexError: # Apparently no eater available self._rank = None return None rankset = self._ranks.get(levelkey, [{"level": 0, "required_score": 0, "name": "Strange"}]) for rank in rankset: self._rank = rank if count < rank["required_score"]: break return self._rank @property def available_styles(self): """ Returns a list of all styles defined for the item """ styles = self._schema_item.get("styles", []) return list(map(operator.itemgetter("name"), styles)) @property def style(self): """ The current style the item is set to or None if the item has no styles """ try: return self.available_styles[self._item.get("style", 0)] except IndexError: return None @property def capabilities(self): """ Returns a list of capabilities, these are flags for what the item can do or be done with """ return list(self._schema_item.get("capabilities", {}).keys()) @property def tool_metadata(self): """ A dict containing item dependant metadata such as holiday restrictions, types, and properties used by the client. Do not assume a stable syntax. """ return self._schema_item.get("tool") @property def origin(self): """ Returns the item's localized origin name """ return self._origin def __iter__(self): return next(self) def __next__(self): iterindex = 0 attrs = self.attributes while(iterindex < len(attrs)): data = attrs[iterindex] iterindex += 1 yield data next = __next__ def __getitem__(self, key): for attr in self: if attr.id == key or attr.name == key: return attr raise KeyError(key) def __contains__(self, key): try: self.__getitem__(key) return True except KeyError: return False def __str__(self): cname = self.custom_name fullname = self.full_name if cname: return "{0} ({1})".format(cname, fullname) else: return fullname def __init__(self, item, schema=None): self._item = item self._schema_item = None self._schema = schema self._rank = {} self._ranks = {} self._kill_types = {} self._origin = None self._attributes = {} if schema: self._schema_item = schema._find_item_by_id(self._item["defindex"]) if not self._schema_item: self._schema_item = self._item qualityid = self._item.get("quality", self._schema_item.get("item_quality", 0)) if schema: self._quality = schema._quality_definition(qualityid) else: self._quality = (qualityid, "normal", "Normal") if schema: self._language = schema.language else: self._language = "en_US" originid = self._item.get("origin") if schema: self._origin = schema.origin_id_to_name(originid) elif originid: self._origin = str(originid) if schema: self._ranks = schema.kill_ranks self._kill_types = schema.kill_types for attr in self._schema_item.get("attributes", []): index = attr.get("defindex", attr.get("name")) attrdef = None if schema: attrdef = schema._attribute_definition(index) if attrdef: index = attrdef["defindex"] self._attributes.setdefault(index, {}) if attrdef: self._attributes[index].update(attrdef) self._attributes[index].update(attr) if self._item != self._schema_item: for attr in self._item.get("attributes", []): index = attr["defindex"] if schema and index not in self._attributes: attrdef = schema._attribute_definition(index) if attrdef: self._attributes[index] = attrdef self._attributes.setdefault(index, {}) self._attributes[index].update(attr)
class item(object): ''' Stores a single inventory item. ''' @property def attributes(self): ''' Returns a list of attributes ''' pass @property def quality(self): ''' Returns a tuple containing ID, name, and localized name of the quality ''' pass @property def inventory_token(self): ''' Returns the item's inventory token (a bitfield), deprecated. ''' pass @property def position(self): ''' Returns a position in the inventory or -1 if there's no position available (i.e. an item hasn't dropped yet or got displaced) ''' pass @property def equipped(self): ''' Returns a dict of classes that have the item equipped and in what slot ''' pass @property def equipable_classes(self): ''' Returns a list of classes that _can_ use the item. ''' pass @property def schema_id(self): ''' Returns the item's ID in the schema. ''' pass @property def name(self): ''' Returns the item's undecorated name ''' pass @property def type(self): ''' Returns the item's type. e.g. "Kukri" for the Tribalman's Shiv. If Valve failed to provide a translation the type will be the token without the hash prefix. ''' pass @property def icon(self): ''' URL to a small thumbnail sized image of the item, suitable for display in groups ''' pass @property def image(self): ''' URL to a full sized image of the item, for displaying 'zoomed-in' previews ''' pass @property def id(self): ''' Returns the item's unique serial number if it has one ''' pass @property def original_id(self): ''' Returns the item's original ID if it has one. This is the last "version" of the item before it was customized or otherwise changed ''' pass @property def level(self): ''' Returns the item's level (e.g. 10 for The Axtinguisher) if it has one ''' pass @property def slot_name(self): ''' Returns the item's slot as a string, this includes "primary", "secondary", "melee", and "head". Note that this is the slot of the item as it appears in the schema, and not necessarily the actual equipable slot. (see 'equipped')''' pass @property def cvar_class(self): ''' Returns the item's class (what you use in the game to equip it, not the craft class)''' pass @property def craft_class(self): ''' Returns the item's class in the crafting system if it has one. This includes hat, craft_bar, or craft_token. ''' pass @property def craft_material_type(self): pass @property def custom_name(self): ''' Returns the item's custom name if it has one. ''' pass @property def custom_description(self): ''' Returns the item's custom description if it has one. ''' pass @property def quantity(self): ''' Returns the number of uses the item has, for example, a dueling mini-game has 5 uses by default ''' pass @property def description(self): ''' Returns the item's default description if it has one ''' pass @property def min_level(self): ''' Returns the item's minimum level (non-random levels will have the same min and max level) ''' pass @property def max_level(self): ''' Returns the item's maximum level (non-random levels will have the same min and max level) ''' pass @property def contents(self): ''' Returns the item in the container, if there is one. This will be a standard item object. ''' pass @property def tradable(self): ''' Somewhat of a WORKAROUND since this flag is there sometimes, "cannot trade" is there sometimes and then there's "always tradable". Opposed to only occasionally tradable when it feels like it. Attr 153 = cannot trade ''' pass @property def craftable(self): ''' Returns not craftable if the cannot craft flag exists. True, otherwise. ''' pass @property def full_name(self): ''' The full name of the item, generated depending on things such as its quality, rank, the schema language, and so on. ''' pass @property def kill_eaters(self): ''' Returns a list of tuples containing the proper localized kill eater type strings and their values according to set/type/value "order" ''' pass @property def rank(self): ''' Returns the item's rank (if it has one) as a dict that includes required score, name, and level. ''' pass @property def available_styles(self): ''' Returns a list of all styles defined for the item ''' pass @property def style(self): ''' The current style the item is set to or None if the item has no styles ''' pass @property def capabilities(self): ''' Returns a list of capabilities, these are flags for what the item can do or be done with ''' pass @property def tool_metadata(self): ''' A dict containing item dependant metadata such as holiday restrictions, types, and properties used by the client. Do not assume a stable syntax. ''' pass @property def original_id(self): ''' Returns the item's localized origin name ''' pass def __iter__(self): pass def __next__(self): pass def __getitem__(self, key): pass def __contains__(self, key): pass def __str__(self): pass def __init__(self, item, schema=None): pass
77
35
9
1
6
2
2
0.29
1
10
1
1
41
10
41
41
440
85
276
129
199
79
223
94
181
16
1
4
86
144,912
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.item_attribute
class item_attribute(object): """ Wrapper around item attributes. """ @property def formatted_value(self): """ Returns a formatted value as a string""" # TODO: Cleanup all of this, it's just weird and unnatural maths val = self.value pval = val ftype = self.value_type if ftype == "percentage": pval = int(round(val * 100)) if self.type == "negative": pval = 0 - (100 - pval) else: pval -= 100 elif ftype == "additive_percentage": pval = int(round(val * 100)) elif ftype == "inverted_percentage": pval = 100 - int(round(val * 100)) # Can't remember what workaround this was, is it needed? if self.type == "negative": if self.value > 1: pval = 0 - pval elif ftype == "additive" or ftype == "particle_index" or ftype == "account_id": if int(val) == val: pval = int(val) elif ftype == "date": d = time.gmtime(int(val)) pval = time.strftime("%Y-%m-%d %H:%M:%S", d) return u"{0}".format(pval) @property def formatted_description(self): """ Returns a formatted description string (%s* tokens replaced) or None if unavailable """ desc = self.description if desc: return desc.replace("%s1", self.formatted_value) else: return None @property def name(self): """ The attribute's name """ return self._attribute.get("name", str(self.id)) @property def cvar_class(self): """ The attribute class, mostly non-useful except for console usage in some cases """ return self._attribute.get("attribute_class") @property def id(self): """ The attribute ID, used for indexing the description blocks in the schema """ # I'm basically making a pun here, Esky, when you find this. Someday. # You owe me a dollar. return self._attribute.get("defindex", id(self)) @property def type(self): """ Returns the attribute effect type (positive, negative, or neutral). This is not the same as the value type, see 'value_type' """ return self._attribute.get("effect_type") @property def value(self): """ Tries to intelligently return the raw value based on schema data. See also: 'value_int' and 'value_float' """ # TODO: No way to determine which value to use without schema, # could be problem if self._isint: return self.value_int else: return self.value_float @property def value_int(self): try: # This is weird, I know, but so is Valve. # They store floats in value fields sometimes, sometimes not. # Oh and they also store strings in there too now! val = self._attribute.get("value", 0) if not isinstance(val, float): return int(val) else: return float(val) except ValueError: return 0 @property def value_float(self): try: return float(self._attribute.get("float_value", self.value_int)) except ValueError: return 0.0 @property def description(self): """ Returns the attribute's description string, if it is intended to be printed with the value there will be a "%s1" token somewhere in the string. Use 'formatted_description' to build one automatically. """ return self._attribute.get("description_string") @property def value_type(self): """ The attribute's type, note that this is the type of the attribute's value and not its affect on the item (i.e. negative or positive). See 'type' for that. """ redundantprefix = "value_is_" vtype = self._attribute.get("description_format") if vtype and vtype.startswith(redundantprefix): return vtype[len(redundantprefix):] else: return vtype @property def hidden(self): """ True if the attribute is "hidden" (not intended to be shown to the end user). Note that hidden attributes also usually have no description string """ return self._attribute.get("hidden", False) or self.description is None @property def account_info(self): """ Certain attributes have a user's account information associated with it such as a gifted or crafted item. A dict with two keys: 'persona' and 'id64'. None if the attribute has no account information attached to it. """ account_info = self._attribute.get("account_info") if account_info: return {"persona": account_info.get("personaname", ""), "id64": account_info["steamid"]} else: return None def __str__(self): """ Pretty printing """ if not self.hidden: return self.formatted_description else: return self.name + ": " + self.formatted_value def __init__(self, attribute): self._attribute = attribute self._isint = self._attribute.get("stored_as_integer", False)
class item_attribute(object): ''' Wrapper around item attributes. ''' @property def formatted_value(self): ''' Returns a formatted value as a string''' pass @property def formatted_description(self): ''' Returns a formatted description string (%s* tokens replaced) or None if unavailable ''' pass @property def name(self): ''' The attribute's name ''' pass @property def cvar_class(self): ''' The attribute class, mostly non-useful except for console usage in some cases ''' pass @property def id(self): ''' The attribute ID, used for indexing the description blocks in the schema ''' pass @property def type(self): ''' Returns the attribute effect type (positive, negative, or neutral). This is not the same as the value type, see 'value_type' ''' pass @property def value(self): ''' Tries to intelligently return the raw value based on schema data. See also: 'value_int' and 'value_float' ''' pass @property def value_int(self): pass @property def value_float(self): pass @property def description(self): ''' Returns the attribute's description string, if it is intended to be printed with the value there will be a "%s1" token somewhere in the string. Use 'formatted_description' to build one automatically. ''' pass @property def value_type(self): ''' The attribute's type, note that this is the type of the attribute's value and not its affect on the item (i.e. negative or positive). See 'type' for that. ''' pass @property def hidden(self): ''' True if the attribute is "hidden" (not intended to be shown to the end user). Note that hidden attributes also usually have no description string ''' pass @property def account_info(self): ''' Certain attributes have a user's account information associated with it such as a gifted or crafted item. A dict with two keys: 'persona' and 'id64'. None if the attribute has no account information attached to it. ''' pass def __str__(self): ''' Pretty printing ''' pass def __init__(self, attribute): pass
29
13
8
1
6
2
2
0.36
1
4
0
1
15
2
15
15
155
23
97
40
68
35
72
27
56
10
1
3
32
144,913
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.schema
class schema(object): """ Wrapper for item schema of certain games from Valve. Those are currently available (along with their ids): * ``260`` - Counter Strike: Source Beta * ``440`` - Team Fortress 2 * ``520`` - Team Fortress 2 Public Beta * ``570`` - Dota 2 * ``620`` - Portal 2 * ``710`` - Counter-Strike: Global Offensive Beta Dev * ``816`` - Dota 2 internal test * ``841`` - Portal 2 Beta * ``205790`` - Dota 2 (beta) test """ @property def _schema(self): if self._cache: return self._cache try: status = self._api["result"]["status"] # Client schema URL self._cache["client"] = self._api["result"]["items_game_url"] # ID:name origin map onames = self._api["result"].get("originNames", []) self._cache["origins"] = dict([(o["origin"], o["name"]) for o in onames]) # Two maps are built here, one for name:ID and one for ID:loc name. # Most of the time qualities will be resolved by ID (as that's what # they are in inventories, it's mostly just the schema that # specifies qualities by non-loc name) qualities = {} quality_names = {} for k, v in self._api["result"]["qualities"].items(): locname = self._api["result"]["qualityNames"][k] idname = k.lower() qualities[v] = (v, idname, locname) quality_names[idname] = v self._cache["qualities"] = qualities self._cache["quality_names"] = quality_names # Two maps are built here, one for name:ID and one for # ID:attribute. As with qualities it's mostly the schema that needs # this extra layer of mapping. Inventories specify attribute IDs # and quality IDs alike directly. attributes = {} attribute_names = {} for attrib in self._api["result"]["attributes"]: attrid = attrib["defindex"] attributes[attrid] = attrib attribute_names[attrib["name"].lower()] = attrid self._cache["attributes"] = attributes self._cache["attribute_names"] = attribute_names # ID:system particle map particles = self._api["result"].get("attribute_controlled_attached_particles", []) self._cache["particles"] = dict([(p["id"], p) for p in particles]) # Name:level eater rank map levels = self._api["result"].get("item_levels", []) self._cache["eater_ranks"] = dict([(l["name"], l["levels"]) for l in levels]) # Type ID:Type eater score count types killtypes = self._api["result"].get("kill_eater_score_types", []) self._cache["eater_types"] = dict([(k["type"], k) for k in killtypes]) # Schema ID:item map (building this is insanely fast, overhead is # minimal compared to lookup benefits in backpacks) if self._items is not None: items = self._items else: items = self._api["result"]["items"] self._cache["items"] = dict([(i["defindex"], i) for i in items]) except KeyError: # Due to the various fields needed we can't check for certain # fields and fall back ala 'inventory' if status is not None: raise SchemaError("Steam returned bad schema with error code " + str(status)) else: raise SchemaError("Empty or corrupt schema returned") return self._cache @property def client_url(self): """ Client schema URL """ return self._schema["client"] @property def language(self): """ The ISO code of the language the instance is localized to """ return self._language def _attribute_definition(self, attrid): """ Returns the attribute definition dict of a given attribute ID, can be the name or the integer ID """ attrs = self._schema["attributes"] try: # Make a new dict to avoid side effects return dict(attrs[attrid]) except KeyError: attr_names = self._schema["attribute_names"] attrdef = attrs.get(attr_names.get(str(attrid).lower())) if not attrdef: return None else: return dict(attrdef) def _quality_definition(self, qid): """ Returns the ID and localized name of the given quality, can be either ID type """ qualities = self._schema["qualities"] try: return qualities[qid] except KeyError: qid = self._schema["quality_names"].get(str(qid).lower(), 0) return qualities.get(qid, (qid, "normal", "Normal")) @property def attributes(self): """ Returns all attributes in the schema """ attrs = self._schema["attributes"] return [item_attribute(attr) for attr in sorted(attrs.values(), key=operator.itemgetter("defindex"))] @property def origins(self): """ Returns a map of all origins """ return self._schema["origins"] @property def qualities(self): """ Returns a dict of all possible qualities. The key(s) will be the ID, values are a tuple containing ID, name, localized name. To resolve a quality to a name intelligently use '_quality_definition' """ return self._schema["qualities"] @property def particle_systems(self): """ Returns a dictionary of particle system dicts keyed by ID """ return self._schema["particles"] @property def kill_ranks(self): """ Returns a list of ranks for weapons with kill tracking """ return self._schema["eater_ranks"] @property def kill_types(self): """ Returns a dict with keys that are the value of the kill eater type attribute and values that are the name string """ return self._schema["eater_types"] def origin_id_to_name(self, origin): """ Returns a localized origin name for a given ID """ try: oid = int(origin) except (ValueError, TypeError): return None return self.origins.get(oid) def _find_item_by_id(self, id): return self._schema["items"].get(id) def __iter__(self): return next(self) def __next__(self): iterindex = 0 iterdata = list(self._schema["items"].values()) while(iterindex < len(iterdata)): data = item(iterdata[iterindex], self) iterindex += 1 yield data next = __next__ def __getitem__(self, key): realkey = None try: realkey = key["defindex"] except: realkey = key schema_item = self._find_item_by_id(realkey) if schema_item: return item(schema_item, self) else: raise KeyError(key) def __len__(self): return len(self._schema["items"]) def __init__(self, app, lang=None, version=1, **kwargs): """ schema will be used to initialize the schema if given, lang can be any ISO language code. lm will be used to generate an HTTP If-Modified-Since header. """ self._language = loc.language(lang).code self._app = int(app) self._cache = {} # WORKAROUND: CS GO v1 returns 404 if self._app == 730 and version == 1: version = 2 # WORKAROUND: certain apps have moved to GetSchemaOverview/GetSchemaItems if self._app in [440]: self._api = api.interface("IEconItems_" + str(self._app)).GetSchemaOverview(language=self._language, version=version, **kwargs) items = [] next_start = 0 # HACK: build the entire item list immediately because Valve decided not to allow us to get the entire thing at once while next_start is not None: next_items = api.interface("IEconItems_" + str(self._app)).GetSchemaItems(language=self._language, version=version, aggressive=True, start=next_start, **kwargs) items.extend(next_items["result"]["items"]) next_start = next_items["result"].get("next", None) self._items = items else: self._api = api.interface("IEconItems_" + str(self._app)).GetSchema(language=self._language, version=version, **kwargs) self._items = None
class schema(object): ''' Wrapper for item schema of certain games from Valve. Those are currently available (along with their ids): * ``260`` - Counter Strike: Source Beta * ``440`` - Team Fortress 2 * ``520`` - Team Fortress 2 Public Beta * ``570`` - Dota 2 * ``620`` - Portal 2 * ``710`` - Counter-Strike: Global Offensive Beta Dev * ``816`` - Dota 2 internal test * ``841`` - Portal 2 Beta * ``205790`` - Dota 2 (beta) test ''' @property def _schema(self): pass @property def client_url(self): ''' Client schema URL ''' pass @property def language(self): ''' The ISO code of the language the instance is localized to ''' pass def _attribute_definition(self, attrid): ''' Returns the attribute definition dict of a given attribute ID, can be the name or the integer ID ''' pass def _quality_definition(self, qid): ''' Returns the ID and localized name of the given quality, can be either ID type ''' pass @property def attributes(self): ''' Returns all attributes in the schema ''' pass @property def origins(self): ''' Returns a map of all origins ''' pass @property def qualities(self): ''' Returns a dict of all possible qualities. The key(s) will be the ID, values are a tuple containing ID, name, localized name. To resolve a quality to a name intelligently use '_quality_definition' ''' pass @property def particle_systems(self): ''' Returns a dictionary of particle system dicts keyed by ID ''' pass @property def kill_ranks(self): ''' Returns a list of ranks for weapons with kill tracking ''' pass @property def kill_types(self): ''' Returns a dict with keys that are the value of the kill eater type attribute and values that are the name string ''' pass def origin_id_to_name(self, origin): ''' Returns a localized origin name for a given ID ''' pass def _find_item_by_id(self, id): pass def __iter__(self): pass def __next__(self): pass def __getitem__(self, key): pass def __len__(self): pass def __init__(self, app, lang=None, version=1, **kwargs): ''' schema will be used to initialize the schema if given, lang can be any ISO language code. lm will be used to generate an HTTP If-Modified-Since header. ''' pass
28
13
11
1
7
2
2
0.4
1
13
5
0
18
5
18
18
231
38
138
62
110
55
122
53
103
7
1
2
34
144,914
Lagg/steamodd
Lagg_steamodd/steam/loc.py
steam.loc.LanguageError
class LanguageError(api.APIError): pass
class LanguageError(api.APIError): pass
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
10
2
0
2
1
1
0
2
1
1
0
5
0
0
144,915
Lagg/steamodd
Lagg_steamodd/steam/loc.py
steam.loc.language
class language(object): """ Steam API localization tools and reference """ # If there's a new language added feel free to add it here _languages = {"da_DK": "Danish", "nl_NL": "Dutch", "en_US": "English", "fi_FI": "Finnish", "fr_FR": "French", "de_DE": "German", "hu_HU": "Hungarian", "it_IT": "Italian", "ja_JP": "Japanese", "ko_KR": "Korean", "no_NO": "Norwegian", "pl_PL": "Polish", "pt_PT": "Portuguese", "pt_BR": "Brazilian Portuguese", "ro_RO": "Romanian", "ru_RU": "Russian", "zh_CN": "Simplified Chinese", "es_ES": "Spanish", "sv_SE": "Swedish", "zh_TW": "Traditional Chinese", "tr_TR": "Turkish"} _default_language = "en_US" def __init__(self, code=None): """ Raises LanguageUnsupportedError if the code isn't supported by the API or otherwise invalid, uses the default language if no code is given. 'code' is an ISO language code. """ self._code = None if not code: _system_language = os.environ.get("LANG", language._default_language).split('.')[0] if _system_language in language._languages.keys(): self._code = _system_language else: self._code = language._default_language else: code = code.lower() for lcode, lname in language._languages.items(): code_lower = lcode.lower() if code_lower == code or code_lower.split('_')[0] == code: self._code = lcode break try: self._name = language._languages[self._code] except KeyError: self._name = None raise LanguageUnsupportedError(code) @property def code(self): return self._code @property def name(self): return self._name
class language(object): ''' Steam API localization tools and reference ''' def __init__(self, code=None): ''' Raises LanguageUnsupportedError if the code isn't supported by the API or otherwise invalid, uses the default language if no code is given. 'code' is an ISO language code. ''' pass @property def code(self): pass @property def name(self): pass
6
2
10
1
8
1
3
0.1
1
2
1
0
3
2
3
3
61
7
49
13
43
5
25
11
21
6
1
3
8
144,916
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.SchemaError
class SchemaError(api.APIError): pass
class SchemaError(api.APIError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
5
0
0
144,917
Lagg/steamodd
Lagg_steamodd/steam/remote_storage.py
steam.remote_storage.UGCError
class UGCError(api.APIError): pass
class UGCError(api.APIError): pass
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
10
2
0
2
1
1
0
2
1
1
0
5
0
0
144,918
Lagg/steamodd
Lagg_steamodd/steam/remote_storage.py
steam.remote_storage.ugc_file
class ugc_file(object): """ Resolves a UGC file ID into usable metadata. """ @property def size(self): """ Size in bytes """ return self._data["size"] @property def filename(self): """ Local filename is what the user named it, not the URL """ return self._data["filename"] @property def url(self): """ UGC link """ return self._data["url"] @property def _data(self): if self._cache: return self._cache data = None status = None try: data = self._api["data"] status = self._api["status"]["code"] except KeyError: if not data: if status is not None and status != 9: raise UGCError("Code " + str(status)) else: raise FileNotFoundError("File not found") except api.HTTPFileNotFoundError: raise FileNotFoundError("File not found") self._cache = data return self._cache def __init__(self, appid, ugcid64, **kwargs): self._cache = {} self._api = api.interface("ISteamRemoteStorage").GetUGCFileDetails(ugcid=ugcid64, appid=appid, **kwargs)
class ugc_file(object): ''' Resolves a UGC file ID into usable metadata. ''' @property def size(self): ''' Size in bytes ''' pass @property def filename(self): ''' Local filename is what the user named it, not the URL ''' pass @property def url(self): ''' UGC link ''' pass @property def _data(self): pass def __init__(self, appid, ugcid64, **kwargs): pass
10
4
6
0
5
1
2
0.13
1
6
3
0
5
2
5
5
43
7
32
14
22
4
27
10
21
6
1
3
10
144,919
Lagg/steamodd
Lagg_steamodd/steam/sim.py
steam.sim.inventory
class inventory(object): @property def cells_total(self): """ Returns the total amount of "cells" which in this case is just an amount of items """ return self._inv.get("count_total", len(self)) @property def page_end(self): """ Returns the last asset ID of this page if the inventory continues. Can be passed as page_start arg """ return self._inv.get("last_assetid") @property def pages_continue(self): """ Returns True if pages continue beyond the one loaded in this instance, False otherwise """ return self._inv.get("more", False) def __next__(self): iterindex = 0 classes = self._inv.get("classes", {}) for assetid, data in self._inv.get("items", {}).items(): clsid = data["classid"] + "_" + data["instanceid"] data.update(classes.get(clsid, {})) yield item(data) next = __next__ def __getitem__(self, key): key = str(key) for item in self: if str(item.id) == key or str(item.original_id) == key: return item raise KeyError(key) def __iter__(self): return next(self) def __len__(self): return len(self._inv.get("items", [])) @property def _inv(self): if self._cache: return self._cache invstr = "http://steamcommunity.com/inventory/{0}/{1}/{2}" page_url = invstr.format(self._user, self._app, self._section) page_url_args = {} if self._language: page_url_args["l"] = self._language if self._page_size: page_url_args["count"] = self._page_size if self._page_start: page_url_args["start_assetid"] = self._page_start page_url += "?" + urlencode(page_url_args) req = api.http_downloader(page_url, timeout=self._timeout) inventorysection = json.loads(req.download().decode("utf-8")) if not inventorysection: raise items.InventoryError("Empty context data returned") itemdescs = inventorysection.get("descriptions") inv = inventorysection.get("assets") if not itemdescs: raise items.InventoryError("No classes in inv output") if not inv: raise items.InventoryError("No assets in inv output") descs = {} items = {} for desc in itemdescs: descs[desc["classid"] + "_" + desc["instanceid"]] = desc for item in inv: items[item["assetid"]] = item self._cache = { "classes": descs, "items": items, "app": self._app, "section": self._section, "more": inventorysection.get("more_items", False), "count_total": inventorysection.get("total_inventory_count"), "last_assetid": inventorysection.get("last_assetid") } return self._cache def __init__(self, profile, app, section, page_start=None, page_size=2000, timeout=None, lang=None): """ 'profile': User ID or user object 'app': Steam app to get the inventory for 'section': Inventory section to operatoe on 'page_start': Asset ID to use as first item in inv chunk 'page_size': How many assets should be in a page """ self._app = app self._cache = {} self._page_size = page_size self._page_start = page_start self._section = section self._timeout = timeout or api.socket_timeout.get() self._language = loc.language(lang).name.lower() if not app: raise items.InventoryError("No inventory available") try: sid = profile.id64 except AttributeError: sid = profile self._user = sid
class inventory(object): @property def cells_total(self): ''' Returns the total amount of "cells" which in this case is just an amount of items ''' pass @property def page_end(self): ''' Returns the last asset ID of this page if the inventory continues. Can be passed as page_start arg ''' pass @property def pages_continue(self): ''' Returns True if pages continue beyond the one loaded in this instance, False otherwise ''' pass def __next__(self): pass def __getitem__(self, key): pass def __iter__(self): pass def __len__(self): pass @property def _inv(self): pass def __init__(self, profile, app, section, page_start=None, page_size=2000, timeout=None, lang=None): ''' 'profile': User ID or user object 'app': Steam app to get the inventory for 'section': Inventory section to operatoe on 'page_start': Asset ID to use as first item in inv chunk 'page_size': How many assets should be in a page ''' pass
14
4
12
2
9
1
3
0.12
1
8
5
0
9
8
9
9
121
28
83
39
69
10
71
35
61
10
1
2
23
144,920
Lagg/steamodd
Lagg_steamodd/steam/sim.py
steam.sim.inventory_context
class inventory_context(object): """ Builds context data that is fetched from a user's inventory page """ @property def ctx(self): if self._cache: return self._cache try: data = self._downloader.download() contexts = re.search("var g_rgAppContextData = (.+);", data.decode("utf-8")) match = contexts.group(1) self._cache = json.loads(match) except: raise items.InventoryError("No SIM inventory information available for this user") return self._cache def get(self, key): """ Returns context data for a given app, can be an ID or a case insensitive name """ keystr = str(key) res = None try: res = self.ctx[keystr] except KeyError: for k, v in self.ctx.items(): if "name" in v and v["name"].lower() == keystr.lower(): res = v break return res @property def apps(self): """ Returns a list of valid app IDs """ return list(self.ctx.keys()) def __getitem__(self, key): res = self.get(key) if not res: raise KeyError(key) return res def __iter__(self): return next(self) def __next__(self): iterindex = 0 iterdata = sorted(self.ctx.values(), key=operator.itemgetter("appid")) while iterindex < len(iterdata): data = iterdata[iterindex] iterindex += 1 yield data next = __next__ def __init__(self, user, **kwargs): self._cache = {} try: sid = user.id64 except: sid = user self._downloader = api.http_downloader("http://steamcommunity.com/profiles/{0}/inventory/".format(sid), **kwargs) self._user = sid
class inventory_context(object): ''' Builds context data that is fetched from a user's inventory page ''' @property def ctx(self): pass def get(self, key): ''' Returns context data for a given app, can be an ID or a case insensitive name ''' pass @property def apps(self): ''' Returns a list of valid app IDs ''' pass def __getitem__(self, key): pass def __iter__(self): pass def __next__(self): pass def __init__(self, user, **kwargs): pass
10
3
8
1
7
0
2
0.06
1
6
2
0
7
3
7
7
69
15
51
24
41
3
48
22
40
4
1
3
15
144,921
Lagg/steamodd
Lagg_steamodd/steam/sim.py
steam.sim.item
class item(items.item): @property def background_color(self): """ Returns the color associated with the item as a hex RGB tuple """ return self._item.get("background_color") @property def name(self): name = self._item.get("market_name") if not name: name = self._item["name"] return saxutils.unescape(name) @property def custom_name(self): name = saxutils.unescape(self._item["name"]) if name.startswith("''"): return name.strip("''") @property def name_color(self): """ Returns the name color as an RGB tuple """ return self._item.get("name_color") @property def full_name(self): return self.custom_name or self.name @property def hash_name(self): """ The URL-friendly identifier for the item. Generates its own approximation if one isn't available """ name = self._item.get("market_hash_name") if not name: name = "{0.appid}-{0.name}".format(self) return name @property def tool_metadata(self): return self._item.get("app_data") @property def tags(self): """ A list of tags attached to the item if applicable, format is subject to change """ return self._item.get("tags") @property def tradable(self): return self._item.get("tradable") @property def craftable(self): for attr in self: desc = attr.description if desc.startswith("( Not") and desc.find("Usable in Crafting"): return False return True @property def quality(self): """ Can't really trust presence of a schema here, but there is an ID sometimes """ try: qid = int((self.tool_metadata or {}).get("quality", 0)) except: qid = 0 # We might be able to get the quality strings from the item's tags internal_name, name = "normal", "Normal" if self.tags: tags = {x.get('category'): x for x in self.tags} if 'Quality' in tags: internal_name, name = tags['Quality'].get('internal_name'), tags['Quality'].get('name') return qid, internal_name, name @property def quantity(self): return int(self._item["amount"]) @property def attributes(self): # Use descriptions here, with alternative attribute class descs = self._item.get("descriptions") or [] if descs: return [item_attribute(attr) for attr in descs] else: return [] @property def position(self): return self._item["pos"] @property def schema_id(self): """ This *will* return none if there is no schema ID, since it's a valve specific concept for the most part """ try: return int((self.tool_metadata or {}).get("def_index")) except TypeError: return None @property def type(self): return self._item.get("type", '') def _scaled_image_url(self, dims): urlbase = self._item.get("icon_url") if urlbase: cdn = "http://cdn.steamcommunity.com/economy/image/" return cdn + urlbase + '/' + dims else: return '' @property def icon(self): return self._scaled_image_url("96fx96f") @property def image(self): return self._scaled_image_url("512fx512f") @property def id(self): return int(self._item["assetid"]) @property def slot_name(self): # (present sometimes in the form of tags) TODO for tag in self._get_category("Type"): return tag["name"] @property def appid(self): """ Return the app ID that this item belongs to """ return self._item["appid"] def _get_category(self, name): cats = [] if self.tags: for tag in self.tags: if tag["category"] == name: cats.append(tag) return cats def __init__(self, theitem): super(item, self).__init__(theitem)
class item(items.item): @property def background_color(self): ''' Returns the color associated with the item as a hex RGB tuple ''' pass @property def name(self): pass @property def custom_name(self): pass @property def name_color(self): ''' Returns the name color as an RGB tuple ''' pass @property def full_name(self): pass @property def hash_name(self): ''' The URL-friendly identifier for the item. Generates its own approximation if one isn't available ''' pass @property def tool_metadata(self): pass @property def tags(self): ''' A list of tags attached to the item if applicable, format is subject to change ''' pass @property def tradable(self): pass @property def craftable(self): pass @property def quality(self): ''' Can't really trust presence of a schema here, but there is an ID sometimes ''' pass @property def quantity(self): pass @property def attributes(self): pass @property def position(self): pass @property def schema_id(self): ''' This *will* return none if there is no schema ID, since it's a valve specific concept for the most part ''' pass @property def type(self): pass def _scaled_image_url(self, dims): pass @property def icon(self): pass @property def image(self): pass @property def id(self): pass @property def slot_name(self): pass @property def appid(self): ''' Return the app ID that this item belongs to ''' pass def _get_category(self, name): pass def __init__(self, theitem): pass
46
7
5
0
4
1
2
0.12
1
4
1
0
24
0
24
65
156
34
109
60
63
13
86
39
61
4
2
3
39
144,922
Lagg/steamodd
Lagg_steamodd/steam/sim.py
steam.sim.item_attribute
class item_attribute(items.item_attribute): @property def value_type(self): # Because Valve uses this same data on web pages, it's /probably/ # trustworthy, so long as they have fixed all the XSS bugs... return "html" @property def description(self): desc = self.value if desc: return saxutils.unescape(desc) else: return " " @property def description_color(self): """ Returns description color as an RGB tuple """ return self._attribute.get("color") @property def type(self): return self._attribute.get("type") @property def value(self): return self._attribute.get("value") def __init__(self, attribute): super(item_attribute, self).__init__(attribute)
class item_attribute(items.item_attribute): @property def value_type(self): pass @property def description(self): pass @property def description_color(self): ''' Returns description color as an RGB tuple ''' pass @property def type(self): pass @property def value_type(self): pass def __init__(self, attribute): pass
12
1
3
0
3
1
1
0.14
1
1
0
0
6
0
6
21
31
6
22
13
10
3
16
8
9
2
2
1
7
144,923
Lagg/steamodd
Lagg_steamodd/steam/loc.py
steam.loc.LanguageUnsupportedError
class LanguageUnsupportedError(LanguageError): pass
class LanguageUnsupportedError(LanguageError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
6
0
0
144,924
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.ProfilePrivateError
class ProfilePrivateError(InventoryError): pass
class ProfilePrivateError(InventoryError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
6
0
0
144,925
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.BadID64Error
class BadID64Error(InventoryError): pass
class BadID64Error(InventoryError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
6
0
0
144,926
Lagg/steamodd
Lagg_steamodd/steam/user.py
steam.user.BansError
class BansError(ProfileError): pass
class BansError(ProfileError): pass
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
10
2
0
2
1
1
0
2
1
1
0
6
0
0
144,927
Lagg/steamodd
Lagg_steamodd/setup.py
setup.run_tests
class run_tests(Command): description = "Run the steamodd unit tests" user_options = [ ("key=", 'k', "Your API key") ] def initialize_options(self): try: self.key = steam.api.key.get() except steam.api.APIKeyMissingError: self.key = None def finalize_options(self): if not self.key: raise OptionError("API key is required") else: steam.api.key.set(self.key) # Generous timeout so slow server days don't cause failed builds steam.api.socket_timeout.set(20) def run(self): tests = TestLoader().discover("tests") results = TextTestRunner(verbosity = 2).run(tests) sys.exit(int(not results.wasSuccessful()))
class run_tests(Command): def initialize_options(self): pass def finalize_options(self): pass def run(self): pass
4
0
6
0
5
0
2
0.05
1
6
3
0
3
1
3
42
26
5
20
9
16
1
17
9
13
2
2
1
5
144,928
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.APIKeyMissingError
class APIKeyMissingError(APIError): pass
class APIKeyMissingError(APIError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
5
0
0
144,929
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.HTTPError
class HTTPError(APIError): """ Raised for other HTTP codes or results """ pass
class HTTPError(APIError): ''' Raised for other HTTP codes or results ''' pass
1
1
0
0
0
0
0
0.5
1
0
0
4
0
0
0
10
3
0
2
1
1
1
2
1
1
0
5
0
0
144,930
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.HTTPFileNotFoundError
class HTTPFileNotFoundError(HTTPError): """ Raised for HTTP code 404 """ pass
class HTTPFileNotFoundError(HTTPError): ''' Raised for HTTP code 404 ''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
3
0
2
1
1
1
2
1
1
0
6
0
0
144,931
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.HTTPInternalServerError
class HTTPInternalServerError(HTTPError): """ Raised for HTTP code 500 """ pass
class HTTPInternalServerError(HTTPError): ''' Raised for HTTP code 500 ''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
3
0
2
1
1
1
2
1
1
0
6
0
0
144,932
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.HTTPStale
class HTTPStale(HTTPError): """ Raised for HTTP code 304 """ pass
class HTTPStale(HTTPError): ''' Raised for HTTP code 304 ''' pass
1
1
0
0
0
0
0
0.5
1
0
0
0
0
0
0
10
3
0
2
1
1
1
2
1
1
0
6
0
0
144,933
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.HTTPTimeoutError
class HTTPTimeoutError(HTTPError): """ Raised for timeouts (not necessarily from the http lib itself but the socket layer, but the effect and recovery is the same, this just makes it more convenient """ pass
class HTTPTimeoutError(HTTPError): ''' Raised for timeouts (not necessarily from the http lib itself but the socket layer, but the effect and recovery is the same, this just makes it more convenient ''' pass
1
1
0
0
0
0
0
1.5
1
0
0
0
0
0
0
10
5
0
2
1
1
3
2
1
1
0
6
0
0
144,934
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.SteamError
class SteamError(Exception): """ For future expansion, considering that steamodd is already no longer *just* an API implementation """ pass
class SteamError(Exception): ''' For future expansion, considering that steamodd is already no longer *just* an API implementation ''' pass
1
1
0
0
0
0
0
1
1
0
0
1
0
0
0
10
4
0
2
1
1
2
2
1
1
0
3
0
0
144,935
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api._interface_method
class _interface_method(object): def __init__(self, iface, name): self._iface = iface self._name = name def __call__(self, version=1, timeout=None, since=None, aggressive=False, data={}, **kwargs): kwargs.setdefault("format", "json") kwargs.setdefault("key", key.get()) url = "https://api.steampowered.com/{0}/{1}/v{2}?{3}".format(self._iface, self._name, version, urlencode(kwargs)) return method_result(url, last_modified=since, timeout=timeout, aggressive=aggressive, data=data)
class _interface_method(object): def __init__(self, iface, name): pass def __call__(self, version=1, timeout=None, since=None, aggressive=False, data={}, **kwargs): pass
3
0
7
1
6
0
1
0
1
2
2
0
2
2
2
2
15
2
13
7
9
0
9
6
6
1
1
0
2
144,936
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.http_downloader
class http_downloader(object): def __init__(self, url, last_modified=None, timeout=None, data={}): self._user_agent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; Valve Steam Client/1366845241; ) AppleWebKit/535.15 (KHTML, like Gecko) Chrome/18.0.989.0 Safari/535.11" self._url = url self._timeout = timeout or socket_timeout.get() self._last_modified = last_modified self._data = None if data: self._data = data def _build_headers(self): head = {} if self._last_modified: head["If-Modified-Since"] = str(self._last_modified) if self._user_agent: head["User-Agent"] = str(self._user_agent) return head def download(self): head = self._build_headers() status_code = -1 body = '' try: if self._data: url_req = urlrequest(self._url, headers=head, data=urlencode(self._data)) else: url_req = urlrequest(self._url, headers=head); req = urlopen(url_req, timeout=self._timeout) status_code = req.code body = req.read() except urlerror.HTTPError as E: code = E.getcode() # More portability hax (no reason property in 2.6?) try: reason = E.reason except AttributeError: reason = "Connection error" if code == 404: raise HTTPFileNotFoundError("File not found") elif code == 304: raise HTTPStale(str(self._last_modified)) elif code == 500: raise HTTPInternalServerError("Internal Server Error") else: raise HTTPError("Server connection failed: {0} ({1})".format(reason, code)) except (socket.timeout, urlerror.URLError): raise HTTPTimeoutError("Server took too long to respond") except socket.error as E: raise HTTPError("Server read error: {0}".format(E)) lm = req.headers.get("last-modified") self._last_modified = lm return body @property def last_modified(self): return self._last_modified @property def url(self): return self._url
class http_downloader(object): def __init__(self, url, last_modified=None, timeout=None, data={}): pass def _build_headers(self): pass def download(self): pass @property def last_modified(self): pass @property def url(self): pass
8
0
12
2
10
0
3
0.02
1
10
6
0
5
5
5
5
69
13
55
23
47
1
49
20
43
9
1
2
16
144,937
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.interface
class interface(object): def __init__(self, iface): self._iface = iface def __getattr__(self, name): return _interface_method(self._iface, name)
class interface(object): def __init__(self, iface): pass def __getattr__(self, name): pass
3
0
2
0
2
0
1
0
1
1
1
0
2
1
2
2
6
1
5
4
2
0
5
4
2
1
1
0
2
144,938
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.key
class key(object): __api_key = None __api_key_env_var = os.environ.get("STEAMODD_API_KEY") @classmethod def set(cls, value): """ Set the current API key, overrides env var. """ cls.__api_key = str(value) @classmethod def get(cls): """Get the current API key. if one has not been given via 'set' the env var STEAMODD_API_KEY will be checked instead. """ apikey = cls.__api_key or cls.__api_key_env_var if apikey: return apikey else: raise APIKeyMissingError("API key not set")
class key(object): @classmethod def set(cls, value): ''' Set the current API key, overrides env var. ''' pass @classmethod def get(cls): '''Get the current API key. if one has not been given via 'set' the env var STEAMODD_API_KEY will be checked instead. ''' pass
5
2
7
1
4
3
2
0.38
1
2
1
0
0
0
2
2
21
3
13
8
8
5
10
6
7
2
1
1
3
144,939
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.method_result
class method_result(dict): """ Holds a deserialized JSON object obtained from fetching the given URL. If aggressive is True then the data will be fetched when the method is called instead of only when the object is actually accessed. """ def __handle_accessor(self, method, *args, **kwargs): try: if not self._fetched: self.call() except AttributeError: self._fetched = True return getattr(super(method_result, self), method)(*args, **kwargs) def __init__(self, *args, **kwargs): super(method_result, self).__init__() self._fetched = False aggressive = kwargs.get("aggressive") if "aggressive" in kwargs: del kwargs["aggressive"] self._downloader = http_downloader(*args, **kwargs) if aggressive: self.call() def __getitem__(self, *args, **kwargs): return self.__handle_accessor("__getitem__", *args, **kwargs) def __setitem__(self, *args, **kwargs): return self.__handle_accessor("__setitem__", *args, **kwargs) def __delitem__(self, *args, **kwargs): return self.__handle_accessor("__delitem__", *args, **kwargs) def __iter__(self): return self.__handle_accessor("__iter__") def __contains__(self, *args, **kwargs): return self.__handle_accessor("__contains__", *args, **kwargs) def __len__(self): return self.__handle_accessor("__len__") def __str__(self): return self.__handle_accessor("__str__") def call(self): """ Make the API call again and fetch fresh data. """ data = self._downloader.download() # Only try to pass errors arg if supported if sys.version >= "2.7": data = data.decode("utf-8", errors="ignore") else: data = data.decode("utf-8") self.update(json.loads(data)) self._fetched = True def get(self, *args, **kwargs): return self.__handle_accessor("get", *args, **kwargs) def keys(self): return self.__handle_accessor("keys")
class method_result(dict): ''' Holds a deserialized JSON object obtained from fetching the given URL. If aggressive is True then the data will be fetched when the method is called instead of only when the object is actually accessed. ''' def __handle_accessor(self, method, *args, **kwargs): pass def __init__(self, *args, **kwargs): pass def __getitem__(self, *args, **kwargs): pass def __setitem__(self, *args, **kwargs): pass def __delitem__(self, *args, **kwargs): pass def __iter__(self): pass def __contains__(self, *args, **kwargs): pass def __len__(self): pass def __str__(self): pass def call(self): ''' Make the API call again and fetch fresh data. ''' pass def get(self, *args, **kwargs): pass def keys(self): pass
13
2
4
1
4
0
1
0.14
1
3
1
0
12
2
12
39
67
18
43
17
30
6
42
17
29
3
2
2
17
144,940
Lagg/steamodd
Lagg_steamodd/steam/api.py
steam.api.socket_timeout
class socket_timeout(object): """ Global timeout, can be overridden by timeouts passed to ctor """ __timeout = 5 @classmethod def set(cls, value): cls.__timeout = value @classmethod def get(cls): return cls.__timeout
class socket_timeout(object): ''' Global timeout, can be overridden by timeouts passed to ctor ''' @classmethod def set(cls, value): pass @classmethod def get(cls): pass
5
1
2
0
2
0
1
0.13
1
0
0
0
0
0
2
2
11
2
8
6
3
1
6
4
3
1
1
0
2
144,941
Lagg/steamodd
Lagg_steamodd/steam/apps.py
steam.apps.AppError
class AppError(api.APIError): pass
class AppError(api.APIError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
5
0
0
144,942
Lagg/steamodd
Lagg_steamodd/steam/apps.py
steam.apps.app_list
class app_list(object): """ Retrieves a list of all Steam apps with their ID and localized name. """ _builtin = { 753: "Steam", 440: "Team Fortress 2", 520: "Team Fortress 2 Beta", 620: "Portal 2", 570: "DOTA 2", 205700: "DOTA 2 Test", 816: "DOTA 2 Internal", 730: "Counter Strike Global Offensive" } def __contains__(self, key): try: self[key] return True except KeyError: return False def __getitem__(self, key): try: return key, self._builtin[key] except KeyError: key = str(key).lower() for app, name in self: if str(app) == key or name.lower() == key: return app, name raise def __init__(self, **kwargs): self._api = api.interface("ISteamApps").GetAppList(version=2, **kwargs) self._cache = {} def __iter__(self): return next(self) def __len__(self): return len(self._apps) @property def _apps(self): if not self._cache: try: self._cache = self._api["applist"]["apps"] except KeyError: raise AppError("Bad app list returned") return self._cache def __next__(self): i = 0 data = self._apps while(i < len(data)): app = data[i]["appid"] name = data[i]["name"] i += 1 yield (app, name) next = __next__
class app_list(object): ''' Retrieves a list of all Steam apps with their ID and localized name. ''' def __contains__(self, key): pass def __getitem__(self, key): pass def __init__(self, **kwargs): pass def __iter__(self): pass def __len__(self): pass @property def _apps(self): pass def __next__(self): pass
9
1
6
0
5
0
2
0.02
1
4
2
0
7
2
7
7
60
8
51
17
42
1
40
16
32
4
1
3
14
144,943
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.AssetError
class AssetError(api.APIError): pass
class AssetError(api.APIError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
5
0
0
144,944
Lagg/steamodd
Lagg_steamodd/steam/items.py
steam.items.InventoryError
class InventoryError(api.APIError): pass
class InventoryError(api.APIError): pass
1
0
0
0
0
0
0
0
1
0
0
2
0
0
0
10
2
0
2
1
1
0
2
1
1
0
5
0
0
144,945
Lagg/steamodd
Lagg_steamodd/steam/user.py
steam.user.BansNotFoundError
class BansNotFoundError(BansError): pass
class BansNotFoundError(BansError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
7
0
0
144,946
Lagg/steamodd
Lagg_steamodd/steam/remote_storage.py
steam.remote_storage.FileNotFoundError
class FileNotFoundError(UGCError): pass
class FileNotFoundError(UGCError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
6
0
0
144,947
Lagg/steamodd
Lagg_steamodd/steam/user.py
steam.user.ProfileNotFoundError
class ProfileNotFoundError(ProfileError): pass
class ProfileNotFoundError(ProfileError): pass
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
10
2
0
2
1
1
0
2
1
1
0
6
0
0