autoFlip
index
/Users/GHawkins/Documents/python/Flipboard_AutoFlip/autoFlip/autoFlip.py

 
Modules
       
json
os
pickle
urllib
urlparse
selenium.webdriver

 
Classes
       
__builtin__.object
pickleDB
urllib.FancyURLopener(urllib.URLopener)
MyOpener

 
class MyOpener(urllib.FancyURLopener)
    ##################
## URL scrapper ##
##################
 
 
Method resolution order:
MyOpener
urllib.FancyURLopener
urllib.URLopener

Data and other attributes defined here:
version = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15'

Methods inherited from urllib.FancyURLopener:
__init__(self, *args, **kwargs)
get_user_passwd(self, host, realm, clear_cache=0)
http_error_301(self, url, fp, errcode, errmsg, headers, data=None)
Error 301 -- also relocated (permanently).
http_error_302(self, url, fp, errcode, errmsg, headers, data=None)
Error 302 -- relocated (temporarily).
http_error_303(self, url, fp, errcode, errmsg, headers, data=None)
Error 303 -- also relocated (essentially identical to 302).
http_error_307(self, url, fp, errcode, errmsg, headers, data=None)
Error 307 -- relocated, but turn POST into error.
http_error_401(self, url, fp, errcode, errmsg, headers, data=None)
Error 401 -- authentication required.
This function supports Basic authentication only.
http_error_407(self, url, fp, errcode, errmsg, headers, data=None)
Error 407 -- proxy authentication required.
This function supports Basic authentication only.
http_error_default(self, url, fp, errcode, errmsg, headers)
Default error handling -- don't raise an exception.
prompt_user_passwd(self, host, realm)
Override this in a GUI environment!
redirect_internal(self, url, fp, errcode, errmsg, headers, data)
retry_http_basic_auth(self, url, realm, data=None)
retry_https_basic_auth(self, url, realm, data=None)
retry_proxy_http_basic_auth(self, url, realm, data=None)
retry_proxy_https_basic_auth(self, url, realm, data=None)

Methods inherited from urllib.URLopener:
__del__(self)
addheader(self, *args)
Add a header to be used by the HTTP interface only
e.g. u.addheader('Accept', 'sound/basic')
cleanup(self)
close(self)
http_error(self, url, fp, errcode, errmsg, headers, data=None)
Handle http errors.
Derived class can override this, or provide specific handlers
named http_error_DDD where DDD is the 3-digit error code.
open(self, fullurl, data=None)
Use URLopener().open(file) instead of open(file, 'r').
open_data(self, url, data=None)
Use "data" URL.
open_file(self, url)
Use local file or FTP depending on form of URL.
open_ftp(self, url)
Use FTP protocol.
open_http(self, url, data=None)
Use HTTP protocol.
open_https(self, url, data=None)
Use HTTPS protocol.
open_local_file(self, url)
Use local file.
open_unknown(self, fullurl, data=None)
Overridable interface to open unknown URL type.
open_unknown_proxy(self, proxy, fullurl, data=None)
Overridable interface to open unknown URL type.
retrieve(self, url, filename=None, reporthook=None, data=None)
retrieve(url) returns (filename, headers) for a local object
or (tempfilename, headers) for a remote object.

 
class pickleDB(__builtin__.object)
    A Pickle DB
 
vars:
container - the underlying container of the db with the intention of it being a dictionary. Each key returns a set.
    The key should be a flipboard magazine title and the the set should be a list of urls of articles flipped into the magazine
 
  Methods defined here:
__init__(self, dbName)
__str__(self)
add(self, key, item)
adds a new item to set given by key
addAndSave(self, key, item)
adds a new item to set given by key and saves db
contains(self, key, value)
check if table key is in db
get(self)
getSet(self, key)
returns the set stored by key
loadDB(self)
Loads the db from file
newTable(self, key)
Creates a new set() accessible by key
saveDB(self)
saves the db to file set in init.properties

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
assert_property(prop, expectedType)
Assert properties were read in correctly from init()
 
arguments:
prop -- some properties variable
expectedType -- the expected type of prop
filter(url, ls)
filters a list based on a pre-defined criteria
 
args:
ls - a list
 
returns a subset of list
flipIntoMag(url, magazine, username, password, vDisplay=False, browserName=None)
flips an article into flipboard magazines. Uses Selenium to execute javascript in firefox.
 
args:
url - the url of the article to be flipped
magazines - a list of flipboard magazine names
username - the user's login name as a string
password - the user's password as a string
vDisplay - flag to determine if we are to use the python virtual display
getTime()
Returns the local time as a string
init()
reads the json login.properties and init.properties in. These determine the system and login properties
 
returns:
a dictionary containing the key-value results
localtime(...)
localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,
                          tm_sec,tm_wday,tm_yday,tm_isdst)
 
Convert seconds since the Epoch to a time tuple expressing local time.
When 'seconds' is not passed in, convert the current time instead.
log(report, indent=False, extraLine=False, time=True)
Generates a log by saving to log.txt and outputting to command line
 
parameters:
report -- a string containing the message to log
indent -- flag to determine if line should be indented (default False)
extraLine -- flag to determine if an extra line should be appended to current line (default False)
time -- flag to determine if time should be appended to start of line (default true)
scrape(url)
return a list of urls scraped from the given url
 
args:
url - the url as the string in which we are to use to extract other urls
 
returns a list of urls gathered from the given url
selectMagazines(url, magazines)
given a url string and a list of magazine names, determine a subset of magazines from the url string
 
args:
url -- a url string
magazines -- a list of flipboard magazine names
 
returns list which is a subset of magazines, derived in some way by the url string
selectWebdriver(browserName)
Firefox is recommended - selects the browser for selenium to launch
args:
browserName = the name of the broswer selenium should launch (chooses firefox is no match)
 
returns the webdriver obj corresponding to browserName
sleep(...)
sleep(seconds)
 
Delay execution for a given number of seconds.  The argument may be
a floating point number for subsecond precision.
strftime(...)
strftime(format[, tuple]) -> string
 
Convert a time tuple to a string according to a format specification.
See the library reference manual for formatting codes. When the time tuple
is not present, current time as returned by localtime() is used.

 
Data
        __author__ = 'Guy Hawkins'

 
Author
        Guy Hawkins