Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python:
env:
- TOX_ENV=py36
- TOX_ENV=coveralls
- TOX_ENV=flake8
install:
- pip install tox
script:
Expand Down
2 changes: 0 additions & 2 deletions carbon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
"""

__version__ = '1.2.0'

from .app import people, person_feed, articles, article_feed
9 changes: 5 additions & 4 deletions carbon/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def people():
persons.c.PERSONNEL_SUBAREA_CODE,
persons.c.APPOINTMENT_END_DATE, orcids.c.ORCID,
dlcs.c.ORG_HIER_SCHOOL_AREA_NAME,
dlcs.c.HR_ORG_LEVEL5_NAME,]) \
dlcs.c.HR_ORG_LEVEL5_NAME, ]) \
.select_from(persons.outerjoin(orcids).join(dlcs)) \
.where(persons.c.EMAIL_ADDRESS != None) \
.where(persons.c.LAST_NAME != None) \
Expand All @@ -67,7 +67,7 @@ def people():
.where(persons.c.APPOINTMENT_END_DATE >= datetime(2009, 1, 1)) \
.where(func.upper(dlcs.c.ORG_HIER_SCHOOL_AREA_NAME).in_(AREAS)) \
.where(persons.c.PERSONNEL_SUBAREA_CODE.in_(PS_CODES)) \
.where(func.upper(persons.c.JOB_TITLE).in_(TITLES))
.where(func.upper(persons.c.JOB_TITLE).in_(TITLES)) # noqa: E711
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, this is required due to how SQLAlchemy is handling the operator overloading for things like some_column != None. pep8 says the comparison should be some_column is not None but this will not generate valid SQL.

with closing(engine().connect()) as conn:
for row in conn.execute(sql):
yield dict(zip(row.keys(), row))
Expand All @@ -82,7 +82,7 @@ def articles():
.where(aa_articles.c.ARTICLE_ID != None) \
.where(aa_articles.c.ARTICLE_TITLE != None) \
.where(aa_articles.c.DOI != None) \
.where(aa_articles.c.MIT_ID != None)
.where(aa_articles.c.MIT_ID != None) # noqa: E711
with closing(engine().connect()) as conn:
for row in conn.execute(sql):
yield dict(zip(row.keys(), row))
Expand Down Expand Up @@ -124,6 +124,7 @@ def group_name(dlc, sub_area):
qualifier = 'Faculty' if sub_area in ('CFAT', 'CFAN') else 'Non-faculty'
return "{} {}".format(dlc, qualifier)


def _ns(namespace, element):
return ET.QName(namespace, element)

Expand Down Expand Up @@ -301,7 +302,7 @@ class Config(dict):
def from_env(cls):
cfg = cls()
for var in ['FTP_USER', 'FTP_PASS', 'FTP_PATH', 'FTP_HOST',
'CARBON_DB',]:
'CARBON_DB', ]:
cfg[var] = os.environ.get(var)
return cfg

Expand Down
2 changes: 1 addition & 1 deletion carbon/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

from sqlalchemy import (create_engine, Table, Column, String, Date, MetaData,
ForeignKey, Numeric, Text, Unicode, UnicodeText)
ForeignKey, Numeric, Unicode, UnicodeText)


os.environ['NLS_LANG'] = 'AMERICAN_AMERICA.UTF8'
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ def articles_data(aa_data):
B.ARTICLE(
B.AA_MATCH_SCORE('0.9'),
B.ARTICLE_ID('1234567'),
B.ARTICLE_TITLE(u'Interaction between hatsopoulos microfluids and the Yawning Abyss of Chaos ☈.'),
B.ARTICLE_TITLE('Interaction between hatsopoulos microfluids and '
'the Yawning Abyss of Chaos ☈.'),
B.ARTICLE_YEAR('1999'),
B.AUTHORS(u'McRandallson, Randall M.|Lord, Dark|☭'),
B.DOI('10.0000/1234LETTERS56'),
Expand Down
3 changes: 1 addition & 2 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
from lxml import etree as ET
import pytest

from carbon import people, articles
from carbon.app import (person_feed, ns, NSMAP, add_child, initials,
article_feed, group_name, Writer, PipeWriter,
FTPReader)
FTPReader, people, articles)


pytestmark = pytest.mark.usefixtures('load_data')
Expand Down
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36,coverage
envlist = py36,coverage,flake8
skipsdist = True

[testenv]
Expand All @@ -8,6 +8,7 @@ deps =
pipenv
{coverage,coveralls}: pytest-cov
coveralls: coveralls
flake8: flake8
setenv =
{coverage,coveralls}: PYTEST_COV="--cov=carbon"
commands =
Expand All @@ -19,3 +20,7 @@ passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
commands =
{[testenv]commands}
coveralls

[testenv:flake8]
commands =
flake8 carbon