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/* 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/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 diff --git a/meta.yaml b/meta.yaml new file mode 100644 index 0000000..79f9bb7 --- /dev/null +++ b/meta.yaml @@ -0,0 +1,26 @@ +source: + git_tag: v0.5.2 + 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