pypartkeepr package¶
Submodules¶
pypartkeepr.core module¶
-
class
pypartkeepr.core.
PKClass
(**kwargs)[source]¶ Bases:
collections.abc.MutableMapping
Class to pythonize PartKeepr web resources
This is the class for parts, part_categories, projects, users, … resources found in the PartKeepr object.
-
add
(dc)[source]¶ Add PKDataClass dc to the PartKeepr database
Add dc to the PartKeepr database if not in the database else update it. Then return the object created/updated.
Parameters: dc – PKDataClass to add Returns: The PKDataClass added Return type: PKDataClass
-
addStock
(**kwargs)¶
-
clear
()[source]¶ Remove all items from the PartKeepr database. NOT IMPLEMENTED
D.clear() Remove all items from D.
Not Implemented
THIS METHOD MIGHT NEVER BE IMPLEMENTED, SEEMS TOO DANGEROUS FOR THE USEFULNESS.
Returns: no return Return type:
-
get
(key, default=None)[source]¶ Get the value referenced by key
D.get(k, default) - Get value of key k if it exists in D else default
Parameters: - key – The id of the item
- default – The value to return if key does not exists, default to None
Returns: The value referenced by key
Return type:
-
get_attr
(val, attr='name', create=False, parent=None)[source]¶ Get item where attr = val
D.get_name( val, attr, create=False, parent=None) -> obj
Parameters: - (str) (val) – The name to retreive, the search is by using the ‘name’ attribute of the item. Some types don’t have that attribute, there is no warnings.
- attr – The attribute name to get
- (bool, optional) (create) – create (or not) if attr`=`val not found. Default to False
- (int, optional) (parent) – if create and a parent needed, use that parent. It could be a int, str(id str) or PKDataClassBase derived class instance.
Returns: A PKDataClassBase derived class instance of the item found or created
Return type:
-
get_name
(val, create=False, parent=None)[source]¶ Get item where name = val
Parameters: - (str) (val) – The name to retreive, the search is by using the ‘name’ attribute of the item. Some types don’t have that attribute, there is no warnings.
- (bool, optional) (create) – create (or not) if attr`=`val not found. Default to False
- (int, optional) (parent) – if create and a parent needed, use that parent. It could be a int, str (id str) or PKDataClassBase derived class instance.
Returns: A PKDataClassBase derived class instance of the item found or created
Return type:
-
items
()[source]¶ Items iterator, (key, value) pair
D.items() - To iterate over items, (key, value) pair.Returns: (key, value) tuple Return type: (int, PKDataClassBase)
-
keys
()[source]¶ Iterate over keys
D.keys() - To iterate over keys.
Returns: key iterator Return type: int
-
massRemoveStock
(**kwargs)¶
-
pop
(key, default=None)[source]¶ Get the item referenced by key else default
Not Implemented
If key is in the dictionary, remove it and return its value, else return default. If default is not given and key is not in the dictionary, a KeyError is raised.
Parameters: - key – the id of the item
- default – The value to return if key is in the dictionary
Returns: item
Return type:
-
popitem
()[source]¶ Remove and return a (key, value) pair from the dictionary.
Not Implemented
D.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty.
Returns: Key, value pair Return type: (key, value) tuple
-
removeStock
(**kwargs)¶
-
search
(prop, op, val)[source]¶ Get items where prop op val (e.g. ‘name’ ‘=’ ‘555’)
Parameters: - (str) (val) – The name of the attribute to search
- (str) – The comparison operation of the search. These are SQL string comparison operators: ‘=’, ‘LIKE, ‘NOT LIKE’, …
- (str) – The value to match
Returns: A list generator of PKDataClassBase derived class instance of the items found or created
Return type:
-
setStock
(**kwargs)¶
-
setdefault
(key, default=None)[source]¶ set key to default if not present
Not Implemented
If key is in the dictionary, return its value. If not, insert key with a value of default and return default. default defaults to None.
Parameters: - key – the id of the item
- default – The item to insert if key not in dictionary. Default: None
Returns: item referenced by key
Return type:
-
update
()[source]¶ Update PartKeepr database with this other PKClass dictionary
Not Implemented
Update the dictionary with the key/value pairs from other, overwriting existing keys. Return None.
update() accepts either another dictionary object or an iterable of key/value pairs (as tuples or other iterables of length two). If keyword arguments are specified, the dictionary is then updated with those key/value pairs: d.update(red=1, blue=2).
Parameters: other – another PKClass dictionnary Returns: None Return type: NoneType
-
values
()[source]¶ Iterate over values.
D.values() - To iterate over values.
Returns: value iterator Return type: PKDataClassBase
-
-
class
pypartkeepr.core.
PKResource
(**kwargs)[source]¶ Bases:
simple_rest_client.resource.Resource
-
add_action
(**kwargs)¶
-
-
class
pypartkeepr.core.
PartKeepr
(config_dir=PosixPath('/home/docs/.config/pypartkeepr'), config_file=PosixPath('/home/docs/.config/pypartkeepr/config'), cookies_file=PosixPath('/home/docs/.config/pypartkeepr/cookies'), timeout=30)[source]¶ Bases:
object
-
octopart_get_category
(part)[source]¶ Get the OctoPart category of part
- Will return a list containing the name of the category and all of its
- ancestors. Indice 0 is the root, and indice -1 is the category.
If no category found then return [ ‘Root Category’, ‘uncategorized’ ]
Parameters: part – An octopart.Part returned by octopart_match()
oroctopart_match1()
Returns List[str]: list of category names Return type: List[str]
-
octopart_match
(queries)[source]¶ Interrogate the octopart database for matching queries
This method support multiple queries, for single query refer to
octopart_match1()
.The following is the query fields supported: (Taken from octopart._PartsMatchQuery schema)
The following is the query fields supported: (Taken from octopart._PartsMatchQuery schema)
q Free-form keyword query mpn MPN search filter brand Brand search filter sku SKU search filter seller Seller search filter mpn_or_sku MPN or SKU search filter start Ordinal position of first returned item limit Maximum number of items to return reference Arbitrary string for identifying e.g.
queries=[{'mpn': 'SN74S74N', brand: 'Texas Instruments'}, {'sku': '595-SN74S74N'}]
Parameters: (dict) (query) – Is a dictionnary with keys taken from below and the value the str to match. The matching is SQL LIKE style. Returns: a list of list of matched octopart.Part. Return one list of matched octopart.Part per queries. Return type: List[List[octopart.Part]]
-
octopart_match1
(query)[source]¶ Interrogate the octopart database for a matching query
This method support one query, for multiple query refer to
octopart_match()
.The following is the query fields supported: (Taken from octopart._PartsMatchQuery schema)
q Free-form keyword query mpn MPN search filter brand Brand search filter sku SKU search filter seller Seller search filter mpn_or_sku MPN or SKU search filter start Ordinal position of first returned item limit Maximum number of items to return reference Arbitrary string for identifying e.g.
queries={'mpn': 'SN74S74N', brand: 'Texas Instruments'}
Parameters: (dict) (query) – Is a dictionnary with keys taken from below and the value the str to match. The matching is SQL LIKE style. Returns: a list of matched octopart.Part Return type: List[octopart.Part]:
-
pypartkeepr.dataclasses module¶
-
class
pypartkeepr.dataclasses.
BatchJob
(id:int, type:str, name:str, batchJobQueryFields:List[pypartkeepr.dataclasses.BatchJobQueryField], batchJobUpdateFields:List[pypartkeepr.dataclasses.BatchJobUpdateField], baseEntity:str)[source]¶
-
class
pypartkeepr.dataclasses.
BatchJobQueryField
(id:int, type:str, property:str, operator:str, value:str, description:str, dynamic:bool)[source]¶
-
class
pypartkeepr.dataclasses.
BatchJobUpdateField
(id:int, type:str, property:str, value:str, description:str, dynamic:bool)[source]¶
-
class
pypartkeepr.dataclasses.
Distributor
(id:int, type:str, name:str, address:str, url:str, phone:str, fax:str, email:str, comment:str, skuurl:str, enabledForReports:bool)[source]¶
-
class
pypartkeepr.dataclasses.
Footprint
(id:int, type:str, name:str, description:str, category:pypartkeepr.dataclasses.FootprintCategory, image:pypartkeepr.dataclasses.FootprintImage, attachments:List[pypartkeepr.dataclasses.FootprintAttachment], categoryPath:str)[source]¶
-
class
pypartkeepr.dataclasses.
FootprintAttachment
(id:int, type:str, filename:str, originalFilename:str, mimetype:str, size:int, extension:str, description:str, replacement:str)[source]¶
-
class
pypartkeepr.dataclasses.
FootprintCategory
(id:int, type:str, parent:Any, children:List[Any], categoryPath:str, expanded:bool, name:str, description:str)[source]¶
-
class
pypartkeepr.dataclasses.
FootprintImage
(id:int, type:str, filename:str, originalFilename:str, mimetype:str, size:int, extension:str, description:str, replacement:str)[source]¶
-
class
pypartkeepr.dataclasses.
GridPreset
(id:int, type:str, grid:str, name:str, configuration:str, gridDefault:bool)[source]¶
-
class
pypartkeepr.dataclasses.
ImportPreset
(id:int, type:str, baseEntity:str, name:str, configuration:str)[source]¶
-
class
pypartkeepr.dataclasses.
Manufacturer
(id:int, type:str, name:str, address:str, url:str, email:str, comment:str, phone:str, fax:str, icLogos:List[pypartkeepr.dataclasses.ManufacturerICLogo])[source]¶
-
class
pypartkeepr.dataclasses.
ManufacturerICLogo
(id:int, type:str, filename:str, originalFilename:str, mimetype:str, size:int, extension:str, description:str, replacement:str)[source]¶
-
class
pypartkeepr.dataclasses.
MetaPartParameterCriteria
(id:int, type:str, partParameterName:str, operator:str, value:float, siPrefix:pypartkeepr.dataclasses.SiPrefix, stringValue:str, valueType:str, unit:pypartkeepr.dataclasses.Unit)[source]¶
-
class
pypartkeepr.dataclasses.
Part
(id:int, type:str, category:pypartkeepr.dataclasses.PartCategory, name:str, description:str, footprint:pypartkeepr.dataclasses.Footprint, partUnit:pypartkeepr.dataclasses.PartMeasurementUnit, storageLocation:pypartkeepr.dataclasses.StorageLocation, manufacturers:List[pypartkeepr.dataclasses.PartManufacturer], distributors:List[pypartkeepr.dataclasses.PartDistributor], attachments:List[pypartkeepr.dataclasses.PartAttachment], comment:str, stockLevel:int, minStockLevel:int, averagePrice:float, stockLevels:List[pypartkeepr.dataclasses.StockEntry], parameters:List[pypartkeepr.dataclasses.PartParameter], metaPartParameterCriterias:List[pypartkeepr.dataclasses.MetaPartParameterCriteria], status:str, needsReview:bool, partCondition:str, productionRemarks:str, createDate:str, internalPartNumber:str, removals:bool, lowStock:bool, metaPart:bool, metaPartMatches:str, categoryPath:str, projectNames:str)[source]¶
-
class
pypartkeepr.dataclasses.
PartAttachment
(id:int, type:str, isImage:bool, filename:str, originalFilename:str, mimetype:str, size:int, extension:str, description:str, replacement:str)[source]¶
-
class
pypartkeepr.dataclasses.
PartCategory
(id:int, type:str, parent:Any, children:List[Any], categoryPath:str, expanded:bool, name:str, description:str)[source]¶
-
class
pypartkeepr.dataclasses.
PartDistributor
(id:int, type:str, distributor:pypartkeepr.dataclasses.Distributor, orderNumber:str, packagingUnit:int, price:float, currency:str, sku:str, ignoreForReports:bool)[source]¶
-
class
pypartkeepr.dataclasses.
PartManufacturer
(id:int, type:str, manufacturer:pypartkeepr.dataclasses.Manufacturer, partNumber:str)[source]¶
-
class
pypartkeepr.dataclasses.
PartMeasurementUnit
(id:int, type:str, name:str, shortName:str, default:bool)[source]¶
-
class
pypartkeepr.dataclasses.
PartParameter
(id:int, type:str, name:str, description:str, unit:pypartkeepr.dataclasses.Unit, value:float, maxValue:float, minValue:float, stringValue:str, valueType:str, siPrefix:pypartkeepr.dataclasses.SiPrefix, minSiPrefix:pypartkeepr.dataclasses.SiPrefix, maxSiPrefix:pypartkeepr.dataclasses.SiPrefix)[source]¶
-
class
pypartkeepr.dataclasses.
PartStock
(id:int, type:str, quantity:int, price:float, comment:str)[source]¶
-
class
pypartkeepr.dataclasses.
Project
(id:int, type:str, name:str, parts:List[pypartkeepr.dataclasses.ProjectPart], description:str, attachments:List[pypartkeepr.dataclasses.ProjectAttachment])[source]¶
-
class
pypartkeepr.dataclasses.
ProjectAttachment
(id:int, type:str, filename:str, originalFilename:str, mimetype:str, size:int, extension:str, description:str, replacement:str)[source]¶
-
class
pypartkeepr.dataclasses.
ProjectPart
(id:int, type:str, part:pypartkeepr.dataclasses.Part, quantity:int, remarks:str, overageType:str, overage:int, lotNumber:str, totalQuantity:int)[source]¶
-
class
pypartkeepr.dataclasses.
ProjectRun
(id:int, type:str, runDateTime:str, project:pypartkeepr.dataclasses.Project, quantity:int, parts:List[pypartkeepr.dataclasses.ProjectRunPart])[source]¶
-
class
pypartkeepr.dataclasses.
ProjectRunPart
(id:int, type:str, projectRun:Any, part:pypartkeepr.dataclasses.Part, quantity:int, lotNumber:str)[source]¶
-
class
pypartkeepr.dataclasses.
Report
(id:int, type:str, name:str, createDateTime:str, reportProjects:List[pypartkeepr.dataclasses.ReportProject], reportParts:List[pypartkeepr.dataclasses.ReportPart])[source]¶
-
class
pypartkeepr.dataclasses.
ReportPart
(id:int, type:str, report:Any, part:pypartkeepr.dataclasses.Part, quantity:int, distributor:pypartkeepr.dataclasses.Distributor, distributorOrderNumber:str, itemPrice:str, orderSum:str, metaPart:bool, subParts:pypartkeepr.dataclasses.Part, projectParts:List[pypartkeepr.dataclasses.ProjectPart], itemSum:str, missing:int)[source]¶
-
class
pypartkeepr.dataclasses.
ReportProject
(id:int, type:str, project:pypartkeepr.dataclasses.Project, quantity:int)[source]¶
-
class
pypartkeepr.dataclasses.
SiPrefix
(id:int, type:str, prefix:str, symbol:str, exponent:int, base:int)[source]¶
-
class
pypartkeepr.dataclasses.
StockEntry
(id:int, type:str, stockLevel:int, part:Any, user:Any, price:float, dateTime:str, correction:bool, comment:str)[source]¶
-
class
pypartkeepr.dataclasses.
StorageLocation
(id:int, type:str, name:str, image:pypartkeepr.dataclasses.StorageLocationImage, category:pypartkeepr.dataclasses.StorageLocationCategory, categoryPath:str)[source]¶
-
class
pypartkeepr.dataclasses.
StorageLocationCategory
(id:int, type:str, parent:Any, children:List[Any], categoryPath:str, expanded:bool, name:str, description:str)[source]¶
-
class
pypartkeepr.dataclasses.
StorageLocationImage
(id:int, type:str, filename:str, originalFilename:str, mimetype:str, size:int, extension:str, description:str, replacement:str)[source]¶
-
class
pypartkeepr.dataclasses.
SystemNotice
(id:int, type:str, date:str, title:str, description:str, acknowledged:bool)[source]¶
-
class
pypartkeepr.dataclasses.
SystemPreference
(id:int, type:str, preferenceKey:str, preferenceValue:str)[source]¶
-
class
pypartkeepr.dataclasses.
TempImage
(id:int, type:str, created:str, replacement:str, originalFilename:str, size:int, description:str, fullFilename:str, filename:str, extension:str, legacyExtension:str, mimeType:str)[source]¶
-
class
pypartkeepr.dataclasses.
TempUploadedFile
(id:int, type:str, created:str, replacement:str, originalFilename:str, size:int, description:str, fullFilename:str, filename:str, extension:str, legacyExtension:str, mimeType:str)[source]¶
-
class
pypartkeepr.dataclasses.
TipOfTheDayHistory
(id:int, type:str, name:str, user:pypartkeepr.dataclasses.User)[source]¶
-
class
pypartkeepr.dataclasses.
Unit
(id:int, type:str, name:str, symbol:str, prefixes:pypartkeepr.dataclasses.SiPrefix)[source]¶
-
class
pypartkeepr.dataclasses.
User
(id:int, type:str, username:str, password:str, newPassword:str, email:str, legacy:bool, provider:pypartkeepr.dataclasses.UserProvider, initialUserPreferences:str, active:bool, protected:bool)[source]¶