-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from RMeli/develop
duecredit
- Loading branch information
Showing
13 changed files
with
174 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: ["https://www.buymeacoffee.com/rmeli"] |
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 |
---|---|---|
|
@@ -70,6 +70,9 @@ ENV/ | |
# mypy | ||
.mypy_cache/ | ||
|
||
# duecredit | ||
.duecredit.p | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
|
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,9 @@ | ||
#!/bin/bash | ||
|
||
cd tests | ||
|
||
python -m duecredit test_import.py | ||
|
||
printf "\n\nBIBTEX\n------\n\n" | ||
|
||
duecredit summary --format bibtex |
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 |
---|---|---|
|
@@ -35,7 +35,9 @@ dependencies: | |
|
||
# Doc | ||
- sphinx | ||
- sphinx_rtd_theme | ||
- sphinx_rtd_theme | ||
- pip: | ||
- duecredit | ||
|
||
# Dev | ||
- mypy | ||
|
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,79 @@ | ||
# emacs: at the end of the file | ||
# ex: set sts=4 ts=4 sw=4 et: | ||
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### # | ||
""" | ||
Stub file for a guaranteed safe import of duecredit constructs: if duecredit | ||
is not available. | ||
To use it, place it into your project codebase to be imported, e.g. copy as | ||
cp stub.py /path/tomodule/module/due.py | ||
Note that it might be better to avoid naming it duecredit.py to avoid shadowing | ||
installed duecredit. | ||
Then use in your code as | ||
from .due import due, Doi, BibTeX, Text | ||
See https://github.com/duecredit/duecredit/blob/master/README.md for examples. | ||
Origin: Originally a part of the duecredit | ||
Copyright: 2015-2019 DueCredit developers | ||
License: BSD-2 | ||
""" | ||
|
||
__version__ = "0.0.8" | ||
|
||
|
||
class InactiveDueCreditCollector(object): | ||
"""Just a stub at the Collector which would not do anything""" | ||
|
||
def _donothing(self, *args, **kwargs): | ||
"""Perform no good and no bad""" | ||
pass | ||
|
||
def dcite(self, *args, **kwargs): | ||
"""If I could cite I would""" | ||
|
||
def nondecorating_decorator(func): | ||
return func | ||
|
||
return nondecorating_decorator | ||
|
||
active = False | ||
activate = add = cite = dump = load = _donothing | ||
|
||
def __repr__(self): | ||
return self.__class__.__name__ + "()" | ||
|
||
|
||
def _donothing_func(*args, **kwargs): | ||
"""Perform no good and no bad""" | ||
pass | ||
|
||
|
||
try: | ||
from duecredit import due, BibTeX, Doi, Url, Text # lgtm[py/unused-import] | ||
|
||
if "due" in locals() and not hasattr(due, "cite"): | ||
raise RuntimeError("Imported due lacks .cite. DueCredit is now disabled") | ||
except Exception as e: | ||
if not isinstance(e, ImportError): | ||
import logging | ||
|
||
logging.getLogger("duecredit").error( | ||
"Failed to import duecredit due to %s" % str(e) | ||
) | ||
# Initiate due stub | ||
due = InactiveDueCreditCollector() | ||
BibTeX = Doi = Url = Text = _donothing_func | ||
|
||
# Emacs mode definitions | ||
# Local Variables: | ||
# mode: python | ||
# py-indent-offset: 4 | ||
# tab-width: 4 | ||
# indent-tabs-mode: nil | ||
# End: |
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 |
---|---|---|
@@ -1,3 +0,0 @@ | ||
""" | ||
Empty init file in case you choose a package besides PyTest such as Nose which may look for such a file | ||
""" | ||
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,36 @@ | ||
""" | ||
Test imported package and modules. | ||
This test is useful to generate a citation report: | ||
.. code | ||
python -m duecite test_import.py | ||
""" | ||
|
||
import sys | ||
|
||
import pytest | ||
|
||
from spyrmsd import graph, hungarian, io, molecule, qcp, rmsd, spyrmsd, utils | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"name", | ||
[ | ||
# Package | ||
spyrmsd.__name__, | ||
# Modules | ||
graph.__name__, | ||
hungarian.__name__, | ||
io.__name__, | ||
molecule.__name__, | ||
qcp.__name__, | ||
rmsd.__name__, | ||
spyrmsd.__name__, | ||
utils.__name__, | ||
], | ||
) | ||
def test_imported(name): | ||
assert name in sys.modules |