Skip to content

Commit

Permalink
- The config file is now created when the module is imported for the …
Browse files Browse the repository at this point in the history
…first time. Everything whould work fine when installing from pypi.

- Changed the name of pyscholar.py to scopus.py.
- Updated the documentation source files to reflect this name change.
- Moved the examples part of the docstrings in scopus.py to the respective docs source (in progress).
- Added intersphinx info for pandas and networkx.
- Fixed some typos in the docstrings.
  • Loading branch information
csaorl committed Jul 5, 2016
1 parent 0182fca commit 69ac878
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 185 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include README.rst
include pyscholar/keys.cfg
include ~/.pyscholar
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ A library to create collaboration science networks.
Requirements
-------------

- `Python <https://www.python.org/download/releases/2.7/>`_ >= 2.7
- `Python <https://www.python.org/download/releases/2.7/>`_ 2.7
- `Networkx <http://networkx.github.io/documentation/networkx-1.7/install.html>`_
- `Matplotlib <http://matplotlib.org/users/installing.html>`_

Expand Down
6 changes: 4 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../../src'))
sys.path.insert(0, os.path.abspath('../../pyscholar'))

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -267,4 +267,6 @@


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'http://docs.python.org/': None}
intersphinx_mapping = {'http://docs.python.org/': None,
'pandas': ('http://pandas.pydata.org/pandas-docs/stable/', None),
'networkx': ('https://networkx.readthedocs.io/en/stable/', None)}
17 changes: 8 additions & 9 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
Welcome to Pyscholar's documentation!
=====================================

Pyscholar gives you easy, Pythonic access to Scopus's API.
Pyscholar gives you easy, pythonic access to Scopus' API.

Some of the functionalities implemented in Pyscholar are as follows:
Some of the functionalities implemented in Pyscholar are:

* Retrieve information about the affiliated authors to Scopus.
* Retrieve information about the articles registered in Scopus.
* Retrieve information about the Institutions registered in Scopus.
* Retrieve information about authors affiliated to Scopus.
* Retrieve information about articles registered in Scopus.
* Retrieve information about institutions registered in Scopus.


From the information obtained in the above points, Pyscholar can with this information build citation graphs and coauthor graphs, since it has features that allow you to perform this task.
Pyscholar can also build citation and coauthor graphs with this information.

Contents:

Expand All @@ -25,7 +25,7 @@ Contents:


Installation <installation>
Pyscholar Module <pyscholar>
Scopus Module <scopus>
Tutorial <tutorial>


Expand All @@ -35,5 +35,4 @@ Indices and tables

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

* :ref:`search`
7 changes: 4 additions & 3 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.. _installation:
================
Installation
================

============
Installation
============

Requirements
================
Expand Down
54 changes: 0 additions & 54 deletions docs/source/pyscholar.rst

This file was deleted.

122 changes: 122 additions & 0 deletions docs/source/scopus.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
.. _scopus:

================
scopus module
================

.. currentmodule:: scopus

Scopus Author/Co-Authors
==========================
.. autofunction:: find_author_scopus_id_by_name
.. autofunction:: get_authors_by_id_affiliation

.. autofunction:: get_coauthors (id_author,min_year="",max_year="")

.. autofunction:: get_ids_authors_by_id_paper
.. autofunction:: load_authors_from_file

:param path: The directory where the file is located.
:type path: :class:`str`
:returns: A list with the authors ids.
:rtype: :class:`list`

:Example:

>>> import pyscholar
>>> pyscholar.load_authors_from_file("/home/dir/authors.txt")
>>> ['56013555800', '12645109800', '12645615700', '12646275800', '15740951000', '23388216300', '23398643600', '24171073600', '24512697200', '26032291700', '34870304900', '35566511400', '36117667600', '36117782600', '36118513000', '36141027800', '37107692000', '37111010900', '54792735300', '55439178900', '55468916100', '55669785100', '55918277800', '55943170800', '55993686500', '56002701400', '56013629200', '56013731100', '56013734400', '56240672400', '56263920000', '56279187000']
>>>

.. autofunction:: search_author


Scopus Paper
==============
.. autofunction:: count_citations_by_id_paper
.. autofunction:: get_common_papers
.. autofunction:: get_papers
.. autofunction:: get_references_by_paper
.. autofunction:: get_title_abstract_by_idpaper
.. autofunction:: get_title_abstract_by_idpaper
.. autofunction:: load_papers_from_file

:param path: The directory where the file is located.
:type path: :class:`str`
:returns: A list with the papers ids.
:rtype: :class:`list`

:Example:

>>> import pyscholar
>>> pyscholar.load_papers_from_file("/home/dir/papers.txt")
>>> ['78149425675', '79959254005', '84883029526', '84887837079', '84892691931', '84893836569', '84897620666', '84904102369', '84908190310', '84919922003', '84924004559', '84925067887', '84928486421', '84928490197', '84928742486', '84939945186', '84939973084', '84945466401', '84961373040']



Scopus Affiliation
====================
.. autofunction:: find_affiliation_scopus_id_by_name

:param organization: The name of the affiliation to search.
:type organization: :class:`str`
:returns: A data frame with the following attributes: id,city,country,name_variant,eid,affiliation_name,identifier,document_count.
:rtype: :class:`pandas.DataFrame`

:Example:

>>> import pyscholar
>>> pyscholar.find_affiliation_scopus_id_by_name("CINVESTAV")
id city country name_variant eid affiliation_name identifier document_count
0 60017323 Mexico City Mexico [CINVESTAV-IPN, CINVESTAV] 10-s2.0-60017323 Centro de Investigacion y de Estudios Avanzados AFFILIATION_ID:60017323 19254
1 60010531 M&eacute;rida Mexico [CINVESTAV-IPN] 10-s2.0-60010531 CINVESTAV Unidad Merida AFFILIATION_ID:60010531 1811
2 60018216 Guadalajara Mexico [CINVESTAV, CINVESTAV Unidad Guadalajara] 10-s2.0-60018216 CINVESTAV Unidad Guadalajara AFFILIATION_ID:60018216 1010
.
.
.
.

.. autofunction:: search_affiliation_by_id


Graph Generators
===================
.. autofunction:: get_citation_graph
.. autofunction:: get_coauthors_graph


Reading and Writing Graphs
=============================
.. autofunction:: save_graph_pickle

:param G: The graph object to be saved.
:param path: The directory where the graph will be saved.
:param name_graph: The name of the graph.
:type G: :ref:`networkx.graph <networkx:Graph>`
:type path: :class:`str`
:type name_graph: :class:`str`
:returns: :class:`NoneType`

:Example:

>>> import pyscholar
>>> psycholar.save_graph_pickle(G,"~/dir/","my_graph")

.. autofunction:: load_graph_pickle

:param path: The directory where the pickle object is located.
:type path: :class:`str`
:returns: A graph G.
:rtype: :ref:`networkx.graph <networkx:Graph>`

:Example:

>>> import pyscholar
>>> my_graph = psycholar.load_graph_pickle("~/dir/graph.pickle")
>>> my_graph


Other Functions
=================
.. autofunction:: disable_graphical_interface
.. autofunction:: enable_graphical_interface
20 changes: 19 additions & 1 deletion pyscholar/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
import pyscholar
import os, ConfigParser
#Check if .pyscholar exists and create it if necessary
pyscholarDir = os.path.join(os.path.expanduser("~"), ".pyscholar")
if not os.path.exists(pyscholarDir):
os.makedirs(pyscholarDir)

#Same for .pyscholar/keys.cfg
if not os.path.exists(os.path.join(pyscholarDir, "keys.cfg")):
keysParser = ConfigParser.ConfigParser()
keysParser.add_section("Keys")
keysParser.set('Keys', 'Scopus', "")
originalMask = os.umask(0)
keysDescriptor = os.open(os.path.join(pyscholarDir, 'keys.cfg'), os.O_WRONLY | os.O_CREAT, 0666)
keysFile = os.fdopen(keysDescriptor, 'w')
os.umask(originalMask)
keysParser.write(keysFile)
keysFile.close()

import scopus
Loading

0 comments on commit 69ac878

Please sign in to comment.