Coder Social home page Coder Social logo

python-operative's Introduction

python-operative

python-operative is a very light-weight Python bridge to the Operative FTP flatfile system.

Setup

Setup virtualenv:

$ mkvirtualenv --distribute python-operative
$ workon python-operative

Run installation script:

$ python setup.py install

Testing

There are two options for running the tests. If you prefer not to test using a live FTP endpoint, then you can use the caliendo cache instead.

###Using Live FTP endpoint

Copy default settings file:

cp operative/settings.py.default operative/settings.py

Update the settings.py file with your own FTP credentials

###Using caliendo cache

Set caliendo env vars:

$ export USE_CALIENDO=True
$ export CALIENDO_CACHE_PREFIX=/absolute/path/to/caliendo/dir

Run tests:

$ python setup.py nosetests

Usage

Using python-operative to retrieve data from an Operative flatfile report is very straightforward.

First step is to define an FTPCredentials object:

import operative

FTP_LOGIN_DICT = {
    'host': <str>,
    'port': <optional int>,
    'username': <str>,
    'password': <str>}

ftp_creds = operative.FTPCredentials(**FTP_LOGIN_DICT)

From there you can pull an array of Report objects:

import datetime
from operative.reports.line_item_report import LineItemReport

since = datetime.datetime.today() - datetime.timedelta(days=1)
path = '/flatfile'

line_item_reports = LineItemReport().get_report_files(ftp_credentials=ftp_creds, ftp_path=path, since=since)

Each Report object has a 'data' array attribute that represents the rows in the report. Each item in the 'data' array is a python-operative model. In the case of this example, they would be LineItem models.

See the model definitions for more info.

Extending / Contributing

If you need to represent an Operative object that is not currently supported, then simply add it to the model definitions.

If you need a report that is currently not supported, then add it to the report definitions.

python-operative's People

Contributors

finn avatar

Watchers

Graham Blache avatar Joel Souza avatar Steve Peterson avatar mellissa avatar Tom Harman avatar Laura Madsen avatar Curtis Thompson avatar Mark Wilkie avatar Gordon Mei avatar Ricardo Soares avatar Ryan Lombardo avatar John Templon avatar Patrick Carey avatar Nick Bauman avatar Tom Biegeleisen avatar John Cleveley avatar Phil Olson avatar Ryan Johnson avatar Stephane Krzywoglowy avatar Nikolay Aviltsev avatar Suman Deb Roy avatar Sandeep Chayapathi avatar Peter Wang avatar Kevin Lord avatar Francisco Albarran Cristobal avatar  avatar James Burns avatar  avatar  avatar Daria Knyazeva avatar Gilad Lotan avatar Jaim Zuber avatar Jesse Shapins avatar Kevin Mangubat avatar Erik Price avatar Ryan Oliver avatar Alp Aker avatar Randy Karels avatar Sameer avatar James Cloos avatar Greg Thompson Jr. avatar  avatar Anthony L Rivera avatar Justin Hines avatar Andrew Paulus avatar  avatar Joseph Oh avatar Dave Marchevsky avatar Abe Handler avatar  avatar Andres Castro avatar Lyle Payne Morgan Smith avatar Walter Menendez avatar Chris Kelley avatar Ola Sendecka avatar Patty Delgado avatar  avatar JS Tan avatar Kyle Lucovsky avatar Brian Clifton (he/him) avatar Jennifer avatar Raymond Wong avatar Funmi Doro avatar  avatar Max Woolf avatar Malcolm Ray avatar Sofi Millares avatar Anita Mehrotra avatar Kate Zasada avatar Salim Rekaibi avatar Motahera Shermin avatar  avatar Ivan Lavriv avatar Benjamin Running avatar  avatar Dat Boi Diego avatar  avatar Jane Hwang avatar Arun avatar Jake Levy avatar Andriy Rushhcak avatar  avatar  avatar Jay Gordon avatar Satoshi Kawase avatar Q avatar Renée Carrington avatar Phil Wilson avatar Sergey avatar Maxim Kapustin avatar  avatar  avatar Agustina Varela avatar millie tran avatar Natalya avatar Lam Thuy Vo avatar  avatar Raz Shlomovich avatar Lyubomyr Rudko avatar Viktor Kushchenko avatar

python-operative's Issues

automatically set caliendo env vars on test run

need to run the following lines at the beginning of every test:
os.environ['CALIENDO_CACHE_PREFIX'] = path.join(PATH, 'caliendo')
os.environ['USE_CALIENDO'] = 'True'

This can probably be achieved by just adding them to the init method of the test parent class

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.