-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from mlsecproject/arch
Re-architecture in line with https://github.com/mlsecproject/combine/wiki/Combine-architecture
- Loading branch information
Showing
20 changed files
with
350 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
recursive-include docs * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import csv | ||
import json | ||
|
||
|
||
def bale_csv(harvest, output_file): | ||
with open(output_file, 'wb') as csv_file: | ||
bale_writer = csv.writer(csv_file) | ||
|
||
# header row | ||
bale_writer.writerow(('entity', 'type', 'direction', 'source', 'notes', 'date')) | ||
bale_writer.writerows(harvest) | ||
|
||
|
||
def bale(input_file, output_file, output_format): | ||
with open(input_file, 'rb') as f: | ||
harvest = json.load(f) | ||
|
||
format_funcs = { 'csv': bale_csv } | ||
format_funcs[output_format](harvest, output_file) | ||
|
||
|
||
if __name__ == "__main__": | ||
bale('crop.json', 'harvest.csv', 'csv') |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Copyright (C) 2014 MLSec Project | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see [http://www.gnu.org/licenses/]. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data/harvest-20140715.json |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
application: combine | ||
developer: MLSec Project | ||
license: GPL version 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
import grequests | ||
|
||
|
||
def exception_handler(request, exception): | ||
print "Request %r failed: %r" % (request, exception) | ||
|
||
|
||
def reap(file_name): | ||
with open('urls.txt', 'rb') as f: | ||
urls = [url.rstrip('\n') for url in f.readlines()] | ||
headers = {'User-Agent': 'harvest.py'} | ||
|
||
reqs = [grequests.get(url, headers=headers) for url in urls] | ||
responses = grequests.map(reqs) | ||
harvest = [(response.url, response.status_code, response.text) for response in responses] | ||
|
||
with open(file_name, 'wb') as f: | ||
json.dump(harvest, f, indent=2) | ||
|
||
|
||
if __name__ == "__main__": | ||
reap('harvest.json') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CsvSchema==1.1.1 | ||
argparse==1.2.1 | ||
gevent==1.0.1 | ||
greenlet==0.4.2 | ||
grequests==0.2.0 | ||
requests==2.3.0 | ||
wsgiref==0.1.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[wheel] | ||
universal = 1 |
Oops, something went wrong.