-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed multithreading and added JSON helper methods (#38)
* Remove multiprocessing from README * Add part data container that can encode itself as a JSON string * Add description of `to_json()` method in PartData * Remove multithreading and integrate PartData * Check and make sure that all the parts can be parsed into JSON * Bump version to 2.2.0
- Loading branch information
1 parent
cb5ef83
commit 1536c84
Showing
9 changed files
with
57 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from .api import API | ||
|
||
__name__ = ["pcpartpicker"] | ||
__version__ = '2.1.1' | ||
__version__ = '2.2.0' | ||
__author__ = 'Jonathan Vusich' | ||
__email__ = '[email protected]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from datetime import datetime | ||
import json | ||
from dataclasses import is_dataclass | ||
from moneyed import Money | ||
|
||
|
||
class PartData(dict): | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.timestamp: datetime = datetime.now() | ||
|
||
def to_json(self) -> str: | ||
class CustomEncoder(json.JSONEncoder): | ||
def default(self, o): | ||
if is_dataclass(o): | ||
return o.__dict__ | ||
if isinstance(o, Money): | ||
return o.currency.code, str(o.amount) | ||
if isinstance(o, datetime): | ||
return str(o) | ||
raise TypeError("Not JSON serializable!") | ||
return json.dumps(self, indent=4, cls=CustomEncoder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ def read(file_name: str): | |
|
||
setup( | ||
name="pcpartpicker", | ||
version="2.1.1", | ||
version="2.2.0", | ||
author="Jonathan Vusich", | ||
author_email="[email protected]", | ||
description="A fast, simple API for PCPartPicker.com.", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters