Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

some doc

  • Loading branch information...
commit 85a55e755bfa8454baccaf3df1ad05722dd149cf 1 parent 6085ea5
@volpino authored
View
5 README.md
@@ -36,3 +36,8 @@ Contribute
Writing a plugin for Ciciòl is very easy! Start having a look at the existing
plugins.
Feel free to fork this repo, open issues and send pull requests
+
+
+Development Status
+------------------
+[![Build Status](https://secure.travis-ci.org/volpino/Ciciol.png?branch=develop)](http://travis-ci.org/volpino/Ciciol)
View
10 ciciol/__init__.py
@@ -7,7 +7,13 @@
class Ciciol(object):
+ """
+ Main class for Ciciol
+ """
def __init__(self, config_fn=None):
+ """
+ Loads a config from config_fn or using autodiscover
+ """
self.config = Config()
if config_fn:
self.config.load(config_fn)
@@ -15,7 +21,11 @@ def __init__(self, config_fn=None):
self.config.autodiscover()
def run(self):
+ """
+ Launches handlers in separate threads
+ """
threads = []
+
for Handler in self.config["handlers"]:
logger.info("Threading handler %s", Handler)
runner = HandlerRunner(Handler, self.config)
View
27 ciciol/config.py
@@ -24,12 +24,22 @@
class Config(object):
- def __init__(self, config_file=None):
+ """
+ Class that handles configuration
+ """
+ def __init__(self):
+ """
+ __init__ for Config
+ """
self._config = defaultdict(lambda: None)
self._config.update(CONFIG_DEFAULT)
- self._config_file = config_file
+ self._config_file = None
def autodiscover(self):
+ """
+ Tries to autodiscover a config file, then it loads it.
+ If no config file is found the default config is loaded.
+ """
filenames = CONFIG_FILENAMES + ["." + fn for fn in CONFIG_FILENAMES]
for path in CONFIG_AUTODISCOVER_PATHS:
for filename in filenames:
@@ -41,15 +51,22 @@ def autodiscover(self):
self.load()
def _import_class(self, path):
+ """
+ Imports class from string path
+ """
splitted = path.split(".")
cls = splitted[-1]
module = __import__(".".join(splitted[:-1]), fromlist=[cls])
return getattr(module, splitted[-1])
def load(self, filepath=None):
+ """
+ Loads a config file from filepath
+ """
if filepath:
logger.info("Loading config file %s", filepath)
with open(filepath) as f:
+ self._config_file = filepath
self._config.update(yaml.load(f))
self._config["handlers"] = [self._import_class(handler)
@@ -58,6 +75,9 @@ def load(self, filepath=None):
for backend in self._config["backends"]]
def get_handler_config(self, handler):
+ """
+ Returns config for handler
+ """
h_config = defaultdict(lambda: None)
if self[handler]:
h_config.update(self[handler])
@@ -66,4 +86,7 @@ def get_handler_config(self, handler):
return h_config
def __getitem__(self, key):
+ """
+ Allows getting config data from config
+ """
return self._config[key]
View
3  ciciol/handlers/__init__.py
@@ -14,6 +14,9 @@ class HandlerRunner(threading.Thread):
Runner for threaded handlers
"""
def __init__(self, Handler, config):
+ """
+ Receives an Handler and a config object
+ """
self.running = True
if hasattr(Handler, "handler_config"):
h_config = config.get_handler_config(Handler.handler_config)
View
9 ciciol/utils/twitter_access_token.py
@@ -3,12 +3,11 @@
from ciciol.handlers.twitter import CONSUMER_KEY, CONSUMER_SECRET
-"""
-Query the user for their consumer key/secret
-then attempt to fetch a valid access token.
-"""
-if __name__ == "__main__":
+def twitter_access_token():
+ """
+ Attempt to fetch a valid access token.
+ """
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
# Open authorization URL in browser
Please sign in to comment.
Something went wrong with that request. Please try again.