From 6a990970acc632351625c46176772eeb315d64e6 Mon Sep 17 00:00:00 2001 From: James Geiger Date: Tue, 24 Nov 2020 17:20:01 -0600 Subject: [PATCH 1/4] Create ElsSource This commit creates ElsSource which returns Scopus data from the source endpoint given an ISSN. --- elsapy/elssource.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 elsapy/elssource.py diff --git a/elsapy/elssource.py b/elsapy/elssource.py new file mode 100644 index 0000000..c804ce1 --- /dev/null +++ b/elsapy/elssource.py @@ -0,0 +1,36 @@ +from abc import ABCMeta, abstractmethod +from .elsentity import ElsEntity + +class ElsSource(ElsEntity): + """An serial in Scopus. Initialize with URI or source ISSN.""" + + # static variables + _payload_type = 'serial-metadata-response' + _uri_base = u'https://api.elsevier.com/content/serial/title/issn/' + + # constructors + def __init__(self, uri = '', serial_issn = ''): + """Initializes a serial given a Scopus source URI or serial ISSN""" + if uri and not serial_issn: + super().__init__(uri) + elif serial_issn and not uri: + super().__init__(self._uri_base + str(serial_issn)) + elif not uri and not serial_issn: + raise ValueError('No URI or ISSN specified') + else: + raise ValueError('Both URI and ISSN specified; just need one.') + + # properties + @property + def title(self): + """Gets the serial's title""" + return self.data[u'entry'][0][u'dc:title'] + + # modifier functions + def read(self, els_client = None): + """Reads the JSON representation of the author from ELSAPI. + Returns True if successful; else, False.""" + if ElsEntity.read(self, self._payload_type, els_client): + return True + else: + return False From a72a1759cb66b8d3b6fcd913ab3c495ab42203b2 Mon Sep 17 00:00:00 2001 From: James Geiger Date: Tue, 24 Nov 2020 17:53:11 -0600 Subject: [PATCH 2/4] Create python-publish.yml --- .github/workflows/python-publish.yml | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..4e1ef42 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* From 22a3d893456d9e25de9b9c759961a46a21d12dd3 Mon Sep 17 00:00:00 2001 From: James Geiger Date: Mon, 30 Nov 2020 13:50:18 -0600 Subject: [PATCH 3/4] Added conda meta and python build files --- bld.bat | 2 ++ build.sh | 1 + meta.yaml | 26 ++++++++++++++++++++++++++ setup.py | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 bld.bat create mode 100644 build.sh create mode 100644 meta.yaml diff --git a/bld.bat b/bld.bat new file mode 100644 index 0000000..6021130 --- /dev/null +++ b/bld.bat @@ -0,0 +1,2 @@ +"%PYTHON%" setup.py install +if errorlevel 1 exit 1 \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..fec5047 --- /dev/null +++ b/build.sh @@ -0,0 +1 @@ +$PYTHON setup.py install # Python command to install the script. \ No newline at end of file diff --git a/meta.yaml b/meta.yaml new file mode 100644 index 0000000..dc0c195 --- /dev/null +++ b/meta.yaml @@ -0,0 +1,26 @@ +source: + git_tag: v0.5.1 + git_url: "https://github.com/james-geiger/elsapy.git" + +package: + name: elsapy + version: {{ environ['GIT_DESCRIBE_TAG'] }} + +build: + number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} + string: {{ environ.get('GIT_BUILD_STR', '') }} + +requirements: + build: + - python + - setuptools + - requests + - pandas + + run: + - python + - requests + - pandas + +about: + home: "https://github.com/james-geiger/elsapy/tree/conda" \ No newline at end of file diff --git a/setup.py b/setup.py index 7d9c6de..0c03b0b 100644 --- a/setup.py +++ b/setup.py @@ -21,5 +21,5 @@ 'Programming Language :: Python :: 3', ], packages = find_packages(exclude=['contrib', 'docs', 'tests*']), - install_requires = ['requests'] + install_requires = ['requests', 'pandas'] ) \ No newline at end of file From 51968ef7ff509ef130f5598b05668591db2d29cf Mon Sep 17 00:00:00 2001 From: James Geiger Date: Mon, 30 Nov 2020 13:53:59 -0600 Subject: [PATCH 4/4] Update meta.yaml to v0.5.2 --- meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta.yaml b/meta.yaml index dc0c195..79f9bb7 100644 --- a/meta.yaml +++ b/meta.yaml @@ -1,5 +1,5 @@ source: - git_tag: v0.5.1 + git_tag: v0.5.2 git_url: "https://github.com/james-geiger/elsapy.git" package: