Skip to content

Commit

Permalink
Fix several issues regarding first release on PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillermo Lozano Branger committed Sep 17, 2019
1 parent fdbace0 commit 6d6f6d7
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 85 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ nosetests.xml
coverage.xml
.pytest_cache/

# Sphinx documentation
docs/*.txt
docs/_build

tests/__pycache__/

# Translations
Expand Down
23 changes: 23 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ install:
- pip install -r requirements.txt
# command to run tests
script:
- python setup.py
- python setup.py install --user
- pytest
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ Changelog
------------------

* First release on GitHub.
* First release on PyPI (2019-09-17)
7 changes: 6 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ include CONTRIBUTING.rst
include LICENSE
include README.rst

include tox.ini .travis.yml .appveyor.yml
include tox.ini .travis.yml .appveyor.yml .readthedocs.yml

global-exclude *.py[cod] __pycache__/* *.so *.dylib

include requirements.txt

prune .eggs
prune docs\_build
68 changes: 0 additions & 68 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,36 +86,6 @@ Import the aomie library into your Python libraries, scripts or applications as
import aomie

amoie includes a succint command line interface that make OMIE data handling extremely easy.

From the command line help:

.. raw:: html

<div>
<PRE>
<B>AOMIE</B> User Commands <B>AOMIE</B>

Usage: omie [OPTIONS] COMMAND [ARGS]...

aomie: OMIE electricity market data handling tool

Options:
--version Display version.
-f, --config-file TEXT Configuration file name and location.
-d, --display-config Display configuration
-c, --config KEY VALUE Overrides a config key/value pair.
-v, --verbose Enables verbose mode.
--help Show this message and exit.

Commands:
download Download OMIE data.
extract Extract data from zip files.
fetch Download, extract and insert files into database.
insert Insert data into SQLite database.

</PRE></div>


Some usage examples follow.

A typical aomie starts by jointly setting the required configuration parameters through
Expand Down Expand Up @@ -151,25 +121,6 @@ To check the current configuration settings type

omie -d

This will return something like this

.. raw:: html

<div>
<PRE>
&lt;Config OrderedDict([('servername', 'www.omel.es'),
('fichero', 'pdbf'),
('start', 200501),
('end', 200512),
('path', '_data3/'),
('dbname', 'test2.db3'),
('filter_unit',
['BES5',
'CTN4',
'PGR5',
'ECT2'])])&gt;
</PRE></div>

Once the zip files have been downloaded we can extract them like this

::
Expand Down Expand Up @@ -202,25 +153,6 @@ aomie commands such as download type

omie download --help

to display this

.. raw:: html

<div>
<PRE>
<B>AOMIE</B> User Commands <B>AOMIE</B>

Usage: omie download [OPTIONS]

Download OMIE files to local destination.

Options:
-e, --extract Extract downloaded files.
--help Show this message and exit.

</PRE></div>


From this help we learn that we can download and extract in a single step by typing

::
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def read(*names, **kwargs):
re.compile('^.. start-badges.*^.. end-badges', re.M | re.S).sub('', read('README.rst')),
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst'))
),
long_description_content_type='text/x-rst',
author='Guillermo Lozano Branger',
author_email='qheuristics@gmail.com',
url='https://github.com/qheuristics/aomie',
Expand Down
10 changes: 6 additions & 4 deletions src/aomie/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@
Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration
"""
import sys
import os
import shutil
import sys
from collections import OrderedDict
from pprint import pformat

import click
import toml

from aomie import __version__
from aomie.handling import (download_files, extract_files, insert_files,
fetch_files)
from aomie.handling import download_files
from aomie.handling import extract_files
from aomie.handling import fetch_files
from aomie.handling import insert_files

TML = '.omie\omie.toml'
TML = '.omie\\omie.toml'

MSGNOCFG = ('No amoie configuration available.\n'
'Type omie --help for information about '
Expand Down
14 changes: 7 additions & 7 deletions src/aomie/handling.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import glob
import os
import zipfile
import shutil
import glob
import sqlite3
import urllib.request
import zipfile
from functools import partial

import numpy as np
import pandas as pd


dtype = {'year': np.int32, 'month': np.int32, 'day': np.int32,
'hour': np.int32, 'unit': str, 'energy': np.float64,
'offer_type': np.int32}
Expand All @@ -35,10 +34,11 @@ def download_files(servername, fichero, path, start, end, **kwargs):
fileroot = f'/datosPub/{fichero}/'
os.makedirs(os.path.dirname(path), exist_ok=True)

items=[*map('pdbf_{}.zip'.format,
pd.date_range(start=pd.to_datetime(str(start),format='%Y%m'),
end=pd.to_datetime(str(end), format='%Y%m'),
freq='MS').strftime('%Y%m'))]
items = [*map('pdbf_{}.zip'.format,
pd.date_range(start=pd.to_datetime(str(start),
format='%Y%m'),
end=pd.to_datetime(str(end), format='%Y%m'),
freq='MS').strftime('%Y%m'))]
for item in items:
filename = fileroot + item
localname = path + item
Expand Down
2 changes: 1 addition & 1 deletion tests/test_aomie.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from click.testing import CliRunner

from aomie.cli import fetch, cli
from aomie.cli import cli


def test_help():
Expand Down
24 changes: 21 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py37, docs
envlist = py37, docs, check


[testenv]
Expand All @@ -13,5 +13,23 @@ commands =
deps =
-r{toxinidir}/docs/requirements.txt
commands =
sphinx-build -b html docs dist/docs
; sphinx-build -b linkcheck docs dist/docs
sphinx-build -b html docs docs/_build
; sphinx-build -b linkcheck docs docs/_build


[testenv:check]
deps =
docutils
check-manifest
flake8
readme-renderer
pygments
isort
twine
skip_install = true
commands =
twine check dist/*
check-manifest {toxinidir}
flake8 src tests setup.py
isort --verbose --check-only --diff --recursive src tests setup.py
; python setup.py check --strict --metadata --restructuredtext

0 comments on commit 6d6f6d7

Please sign in to comment.