Skip to content

Commit

Permalink
Merge branch 'release/v0.11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Mar 18, 2022
2 parents 3f6b659 + 7e66af2 commit 5e3b139
Show file tree
Hide file tree
Showing 10 changed files with 1,759 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Install is either via pip or cloning the repository.

From pip:
```sh
python3 -m pip install thothlibrary==0.10.5
python3 -m pip install thothlibrary==0.11.0
```

Or from the repo:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"thothrest.thoth-0_4_2",
"thothlibrary.thoth-0_5_0",
"thothlibrary.thoth-0_6_0",
"thothlibrary.thoth-0_8_0"
],
include_package_data=True,
install_requires=["graphqlclient", "requests", "munch"],
Expand Down
2 changes: 1 addition & 1 deletion thothlibrary/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""GraphQL client for Thoth"""

__version__ = "0.10.5"
__version__ = "0.11.0"
__author__ = "Javier Arias <[email protected]>"
__copyright__ = "Copyright (c) 2020 Open Book Publishers"
__license__ = "Apache 2.0"
Expand Down
4 changes: 2 additions & 2 deletions thothlibrary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self):
A Thoth CLI client
"""
self.endpoint = "https://api.thoth.pub"
self.version = "0.6.0"
self.version = "0.8.0"

self.thoth_email = getenv('THOTH_EMAIL')
self.thoth_pwd = getenv('THOTH_PWD')
Expand Down Expand Up @@ -1012,7 +1012,7 @@ def update_cover(self, doi=None, work_id=None, url=None, version=None,

client.login(self.thoth_email, self.thoth_pwd)

mutation = client.mutation('updateWork', data, units='MM')
mutation = client.mutation('updateWork', data)


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions thothlibrary/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def login(self, email, password):
bearer = "Bearer {}".format(auth.get_token())
self.client.inject_token(bearer)

def mutation(self, mutation_name, data, units=False):
def mutation(self, mutation_name, data):
"""Instantiate a thoth mutation and execute"""
mutation = ThothMutation(mutation_name, data, units)
mutation = ThothMutation(mutation_name, data)
return mutation.run(self.client)

def query(self, query_name, parameters, raw=False):
Expand Down
18 changes: 6 additions & 12 deletions thothlibrary/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class ThothMutation():
("doi", True),
("publicationDate", True),
("place", True),
("width", False),
("height", False),
("pageCount", False),
("pageBreakdown", True),
("imageCount", False),
Expand All @@ -84,6 +82,10 @@ class ThothMutation():
"fields": [
("publicationType", False),
("workId", True),
("width", False),
("height", False),
("depth", False),
("weight", False),
("isbn", True)
],
"return_value": "publicationId"
Expand Down Expand Up @@ -213,8 +215,6 @@ class ThothMutation():
("doi", True),
("publicationDate", True),
("place", True),
("width", False),
("height", False),
("pageCount", False),
("pageBreakdown", True),
("imageCount", False),
Expand All @@ -237,15 +237,14 @@ class ThothMutation():
}
}

def __init__(self, mutation_name, mutation_data, units=False):
def __init__(self, mutation_name, mutation_data):
"""Returns new ThothMutation object with specified mutation data
mutation_name: Must match one of the keys found in MUTATIONS.
mutation_data: Dictionary of mutation fields and their values.
"""
self.mutation_name = mutation_name
self.units = units
self.return_value = self.MUTATIONS[mutation_name]["return_value"]
self.mutation_data = mutation_data
self.data_str = self.generate_values()
Expand All @@ -256,17 +255,12 @@ def prepare_request(self):
values = {
"mutation_name": self.mutation_name,
"data": self.data_str,
"return_value": self.return_value,
"units": ""
"return_value": self.return_value
}

if self.units:
values.update({"units": "units: {},".format(self.units)})

payload = """
mutation {
%(mutation_name)s(
%(units)s
data: {
%(data)s
}
Expand Down
Empty file.
Loading

0 comments on commit 5e3b139

Please sign in to comment.