Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
still refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonza committed Apr 28, 2014
1 parent 3b4becf commit 27d375b
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*~
*.db
*.pyc
*.json
*.gz
*.py#
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tyler Brown
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include AUTHORS.rst
include README.rst
20 changes: 17 additions & 3 deletions gathernews/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@
# - better organization of tables for large entries
# - support for databases other than SQLite3

import duplicates
# Asynchronous stuff, twisted
import async
# Any functions that must be called to keep the versions compatible
import bug_fixes
# Module that lets you commit RSS feeds to a SQLite3 database
import gRSS
# Does anything related to reading or writing from file storage
import io
import new_tables
import populate_tables
# Anything related to Mongo IO
import mongo_io
# Filter out any garbage from Feedparser input
import rm_garbage
# Anything related to SQLite3 IO
import sqlite3_io
# Multithreading
import threads



Empty file added gathernews/async.py
Empty file.
14 changes: 11 additions & 3 deletions gathernews/bug_fixes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
from io import ReadFiles
from sqlite3_io import Sqlite3IO

class v1_bugs:
""" Any functions that must be called to keep the versions compatible"""

class v1_bugs(object):
""" Any functions that must be called to keep the version 1 compatible"""

def __init__(self, path):
self.read_files = ReadFiles(path)
self.use_sqlite3 = Sqlite3IO(path)
self.path = path

def fix_create_table_bug(self):
""" Fix the create table bug
Expand All @@ -27,7 +35,7 @@ def fix_create_table_bug(self):
"""

# get table names from the database
db_names = self.get_tablenames()
db_names = self.use_sqlite3.get_tablenames()

# get table names from RSS feeds
create_these_tables = {}
Expand Down
Empty file added gathernews/duplicates.py
Empty file.
13 changes: 13 additions & 0 deletions gathernews/gRSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@
import json
import logging

## custom modules

# clean input
from io import ReadFiles, WriteFiles
from rm_garbage import FilterGarbage
from bug_fixes import v1_bugs
# play well with DBs
from mongo_io import MongoIO
from sqlite3_io import Sqlite3IO
# handle requests quickly
#from async import *
#from threads import *


class CaptureFeeds(object):
""" Commits RSS news feeds to a SQLite3 database """
Expand Down
57 changes: 31 additions & 26 deletions gathernews/io.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class io(object):
""" Does anything related to reading or writing from file storage """
class ReadFiles(object):
""" Does anything related to reading from file storage """

def __init__(self, path):
self.path = path
Expand Down Expand Up @@ -41,7 +41,35 @@ def read_file(self, path, your_file_name):
return clean_file


def update_feeds_json(self, path, create_these_tables,
def does_json_exist(self, path, your_file_name):
""" If a json object exists then return it
Args:
file_name: This is the name of your file.
Returns:
A json object from your specified path is returned.
"""
try:
with open(path + your_file_name, 'r') as f:
return json.load(f)
# At some point you should create a method that checks to see if the
# file path given by the user is accurate.
except:
return False


def get_RSS_link(self):
"""RSS links used to pull feeds"""
return self.read_file(self.path, "feeds_list")


class WriteFiles(ReadFiles):
""" Does anything related to writing from file storage """
# Not sure what this will inherit for a file_path from ReadFiles
# under which conditions, but hey, isn't learning fun

def update_feeds_json(self, path, create_these_tables,
previous_feeds_list, current_feeds_list):
""" A JSON object of table_names in the database is updated.
Expand Down Expand Up @@ -73,26 +101,3 @@ def update_feeds_json(self, path, create_these_tables,
return json.dump(previous_feeds_list, f)
else:
return False


def does_json_exist(self, path, your_file_name):
""" If a json object exists then return it
Args:
file_name: This is the name of your file.
Returns:
A json object from your specified path is returned.
"""
try:
with open(path + your_file_name, 'r') as f:
return json.load(f)
# At some point you should create a method that checks to see if the
# file path given by the user is accurate.
except:
return False


def get_RSS_link(self):
"""RSS links used to pull feeds"""
return self.read_file(self.path, "feeds_list.txt")
5 changes: 5 additions & 0 deletions gathernews/mongo_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


class MongoIO(object):
""" Anything related to MongoDB io """
pass
Empty file added gathernews/new_tables.py
Empty file.
3 changes: 3 additions & 0 deletions gathernews/rm_garbage.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from io import ReadFiles



class FilterGarbage:
""" Filter out any garbage from Feedparser input """
Expand Down
10 changes: 9 additions & 1 deletion gathernews/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
import test_gRSS
import test_gRSS # this is more or less contains the main method
import test_async
import test_bug_fixes
import test_io
import test_mongo_io
import test_rm_garbage
import test_sqlite3_io
import test_threads

2 changes: 2 additions & 0 deletions gathernews/tests/bad_feeds_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# these are bad rss links
dontcha know...
10 changes: 10 additions & 0 deletions gathernews/tests/feeds_list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
http://feeds.reuters.com/reuters/businessNews
http://feeds.reuters.com/reuters/entertainment
http://feeds.reuters.com/reuters/topNews
http://feeds.reuters.com/Reuters/worldNews
http://rss.cnn.com/rss/money_latest.rss
http://rss.cnn.com/rss/cnn_showbiz.rss
http://rss.cnn.com/rss/cnn_topstories.rss
http://rss.cnn.com/rss/cnn_world.rss


Empty file added gathernews/tests/test_async.py
Empty file.
Empty file.
Empty file added gathernews/tests/test_io.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added master
Empty file.

0 comments on commit 27d375b

Please sign in to comment.