[gpapers] 9 new revisions pushed by marcelCo...@gmail.com on 2012-04-09 21:50 GMT

4 views
Skip to first unread message

codesite...@google.com

unread,
Apr 9, 2012, 5:52:19 PM4/9/12
to gpapers...@googlegroups.com
9 new revisions:

Revision: 06d8d92f4761
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:15:01 2012
Log: fix wrong import for deseb
http://code.google.com/p/gpapers/source/detail?r=06d8d92f4761

Revision: ab141589cf10
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:15:18 2012
Log: very first setup.py script
http://code.google.com/p/gpapers/source/detail?r=ab141589cf10

Revision: 1d8ae915b607
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:29:00 2012
Log: add copyright/license info to files
http://code.google.com/p/gpapers/source/detail?r=1d8ae915b607

Revision: f8c6c2d9d2db
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:52:25 2012
Log: remove unused function and openanything module that is no longer
used ...
http://code.google.com/p/gpapers/source/detail?r=f8c6c2d9d2db

Revision: 4e4d5f5803af
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:44:00 2012
Log: add more dependencies and acknowledge code that is used within
gPapers
http://code.google.com/p/gpapers/source/detail?r=4e4d5f5803af

Revision: b1b5eb2da764
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 14:09:14 2012
Log: rearrange imports a bit
http://code.google.com/p/gpapers/source/detail?r=b1b5eb2da764

Revision: 18d7c60a2481
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 14:16:22 2012
Log: make directory import equivalent to file import
http://code.google.com/p/gpapers/source/detail?r=18d7c60a2481

Revision: cfc6481144cd
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 14:43:34 2012
Log: fix table refresh
http://code.google.com/p/gpapers/source/detail?r=cfc6481144cd

Revision: aca8357a17e3
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 14:48:32 2012
Log: remove status message about searching the local library
http://code.google.com/p/gpapers/source/detail?r=aca8357a17e3

==============================================================================
Revision: 06d8d92f4761
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:15:01 2012
Log: fix wrong import for deseb
http://code.google.com/p/gpapers/source/detail?r=06d8d92f4761

Modified:
/gpapers/__init__.py

=======================================
--- /gpapers/__init__.py Tue Apr 3 14:56:09 2012
+++ /gpapers/__init__.py Mon Apr 9 13:15:01 2012
@@ -66,7 +66,7 @@
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver

-import gpapers.deseb
+import deseb
from gpapers.gPapers.models import *
import gpapers.importer as importer


==============================================================================
Revision: ab141589cf10
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:15:18 2012
Log: very first setup.py script
http://code.google.com/p/gpapers/source/detail?r=ab141589cf10

Added:
/setup.py

=======================================
--- /dev/null
+++ /setup.py Mon Apr 9 13:15:18 2012
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+from distutils.core import setup
+
+setup(name='gPapers',
+ version='0.5dev',
+ description='The Gnome-based Scientific Paper Organizer',
+ author='Derek Anderson',
+ author_email='pub...@kered.org',
+ url='http://gpapers.org/',
+ packages=['gpapers', 'gpapers.gPapers', 'gpapers.importer', 'deseb'],
+ scripts=['gpapers.py'],
+ #TODO: Icons, UI files, desktop file
+ )

==============================================================================
Revision: 1d8ae915b607
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:29:00 2012
Log: add copyright/license info to files
http://code.google.com/p/gpapers/source/detail?r=1d8ae915b607

Modified:
/gpapers.py
/gpapers/__init__.py
/gpapers/importer/__init__.py
/gpapers/importer/bibtex.py
/gpapers/importer/google_scholar.py
/gpapers/importer/jstor.py
/gpapers/importer/pdf_file.py
/gpapers/importer/pubmed.py
/gpapers/logger.py
/setup.py

=======================================
--- /gpapers.py Thu Apr 5 14:13:17 2012
+++ /gpapers.py Mon Apr 9 13:29:00 2012
@@ -1,4 +1,24 @@
#!/usr/bin/env python
+
+# gPapers
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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.
+#
+# gPapers 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 gPapers. If not, see <http://www.gnu.org/licenses/>.
+
'''
Simple script for starting gpapers. Will do some checking for Python
version
and available paths in the future.
=======================================
--- /gpapers/__init__.py Mon Apr 9 13:15:01 2012
+++ /gpapers/__init__.py Mon Apr 9 13:29:00 2012
@@ -2,21 +2,23 @@
# -*- coding: utf-8 -*-

# gPapers
-# Copyright (C) 2007 Derek Anderson
-#
-# This program is free software; you can redistribute it and/or modify
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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 2 of the License, or
+# 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,
+# gPapers 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, write to the Free Software Foundation,
Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with gPapers. If not, see <http://www.gnu.org/licenses/>.

import commands, math, os, sys, thread, threading, time, traceback
import mimetypes
=======================================
--- /gpapers/importer/__init__.py Tue Apr 3 14:20:42 2012
+++ /gpapers/importer/__init__.py Mon Apr 9 13:29:00 2012
@@ -1,19 +1,21 @@
# gPapers
-# Copyright (C) 2007 Derek Anderson
-#
-# This program is free software; you can redistribute it and/or modify
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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 2 of the License, or
+# 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,
+# gPapers 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, write to the Free Software Foundation,
Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with gPapers. If not, see <http://www.gnu.org/licenses/>.

import commands, dircache, getopt, math, os, re, string, sys, thread,
threading, time, traceback
from datetime import date, datetime, timedelta
=======================================
--- /gpapers/importer/bibtex.py Thu Apr 5 14:13:17 2012
+++ /gpapers/importer/bibtex.py Mon Apr 9 13:29:00 2012
@@ -1,17 +1,41 @@
# coding: utf8
+
+# gPapers
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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.
+#
+# gPapers 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 gPapers. If not, see <http://www.gnu.org/licenses/>.
+#
+# This file is based on code by Matthew Brett
(http://pastebin.com/ZzU19NLJ),
+# published under a simplified BSD license.
+
+# -- begin of pyparsing code
+# Pyparsing parser for BibTeX files
+#
+# A standalone parser using pyparsing.
+#
+# pyparsing has a simple and expressive syntax so the grammar is easy to
read and
+# write.
+#
+# Matthew Brett 2010
+# Simplified BSD license
+
import re
from gpapers.logger import log_info, log_debug
import pprint
-""" Pyparsing parser for BibTeX files
-
-A standalone parser using pyparsing.
-
-pyparsing has a simple and expressive syntax so the grammar is easy to
read and
-write.
-
-Matthew Brett 2010
-Simplified BSD license
-"""

from pyparsing import (Regex, Suppress, ZeroOrMore, Group, Optional,
Forward,
SkipTo, CaselessLiteral, Dict)
@@ -123,31 +147,7 @@
def parse_str(str):
return bibfile.parseString(str)

-if __name__ == '__main__':
- # Run basic test
- txt = """
-@article{10.1371/journal.pone.0020409,
- author = {Tkačik, Gašper AND Garrigan, Patrick AND Ratliff, Charles
AND Milčinski, Grega AND Klein, Jennifer M. AND Seyfarth, Lucia H. AND
Sterling, Peter AND Brainard, David H. AND Balasubramanian, Vijay},
- journal = {PLoS ONE},
- publisher = {Public Library of Science},
- title = {Natural {I}mages from the Birthplace of the Human Eye},
- year = {2011},
- month = {06},
- volume = {6},
- url = {http://dx.doi.org/10.1371%2Fjournal.pone.0020409},
- pages = {e20409},
- abstract = {
- <p>Here we introduce a database of calibrated natural images
publicly available through an easy-to-use web interface. Using a Nikon D70
digital SLR camera, we acquired about <inline-formula><inline-graphic
xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:href="info:doi/10.1371/journal.pone.0020409.e001" mimetype="image"
xlink:type="simple"/></inline-formula> six-megapixel images of Okavango
Delta of Botswana, a tropical savanna habitat similar to where the human
eye is thought to have evolved. Some sequences of images were captured
unsystematically while following a baboon troop, while others were designed
to vary a single parameter such as aperture, object distance, time of day
or position on the horizon. Images are available in the raw RGB format and
in grayscale. Images are also available in units relevant to the physiology
of human cone photoreceptors, where pixel values represent the expected
number of photoisomerizations per second for cones sensitive to long (L),
medium (M) and short (S) wavelengths. This database is distributed under a
Creative Commons Attribution-Noncommercial Unported license to facilitate
research in computer vision, psychophysics of perception, and visual
neuroscience.</p>
- },
- number = {6},
- doi = {10.1371/journal.pone.0020409}
-}
-"""
- pp = pprint.PrettyPrinter(indent=4)
-
- pp.pprint(mydict)
-
-p_bibtex = re.compile('[@][a-z]+[\s]*{(.*)}', re.IGNORECASE | re.DOTALL)
+# -- end of pyparsing code

def latex2unicode(s):
"""
=======================================
--- /gpapers/importer/google_scholar.py Thu Apr 5 14:13:17 2012
+++ /gpapers/importer/google_scholar.py Mon Apr 9 13:29:00 2012
@@ -1,3 +1,22 @@
+# gPapers
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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.
+#
+# gPapers 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 gPapers. If not, see <http://www.gnu.org/licenses/>.
+
import urllib, hashlib, random, traceback

from gi.repository import Soup # @UnresolvedImport
=======================================
--- /gpapers/importer/jstor.py Thu Apr 5 14:13:17 2012
+++ /gpapers/importer/jstor.py Mon Apr 9 13:29:00 2012
@@ -1,3 +1,22 @@
+# gPapers
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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.
+#
+# gPapers 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 gPapers. If not, see <http://www.gnu.org/licenses/>.
+
from gi.repository import Soup
from BeautifulSoup import BeautifulStoneSoup
from gpapers.importer import SimpleWebSearchProvider
=======================================
--- /gpapers/importer/pdf_file.py Tue Apr 3 14:56:31 2012
+++ /gpapers/importer/pdf_file.py Mon Apr 9 13:29:00 2012
@@ -1,3 +1,22 @@
+# gPapers
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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.
+#
+# gPapers 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 gPapers. If not, see <http://www.gnu.org/licenses/>.
+
from io import BytesIO
import cStringIO
import re
=======================================
--- /gpapers/importer/pubmed.py Thu Apr 5 14:13:17 2012
+++ /gpapers/importer/pubmed.py Mon Apr 9 13:29:00 2012
@@ -1,3 +1,22 @@
+# gPapers
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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.
+#
+# gPapers 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 gPapers. If not, see <http://www.gnu.org/licenses/>.
+
import urllib

import BeautifulSoup
=======================================
--- /gpapers/logger.py Thu Apr 5 14:13:17 2012
+++ /gpapers/logger.py Mon Apr 9 13:29:00 2012
@@ -1,7 +1,26 @@
'''
-Logging information for Brian
+Logging information for gPapers
'''

+# gPapers
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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.
+#
+# gPapers 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 gPapers. If not, see <http://www.gnu.org/licenses/>.
+
import logging
import sys

@@ -16,32 +35,39 @@
def log_error(message):
logging.getLogger('gPapers').error(message)

+
def log_warn(message):
logging.getLogger('gPapers').warn(message)

+
def log_info(message):
logging.getLogger('gPapers').info(message)

+
def log_debug(message):
logging.getLogger('gPapers').debug(message)

+
def log_level_error():
'''Shows log messages only of level ERROR or higher.
'''
logging.getLogger('gPapers').setLevel(logging.ERROR)

+
def log_level_warn():
'''Shows log messages only of level WARNING or higher (including ERROR
level).
'''
logging.getLogger('gPapers').setLevel(logging.WARN)

+
def log_level_info():
'''Shows log messages only of level INFO or higher (including WARNING
and
ERROR levels).
'''
logging.getLogger('gPapers').setLevel(logging.INFO)

+
def log_level_debug():
'''Shows log messages only of level DEBUG or higher (including INFO,
WARNING and ERROR levels).
=======================================
--- /setup.py Mon Apr 9 13:15:18 2012
+++ /setup.py Mon Apr 9 13:29:00 2012
@@ -1,5 +1,24 @@
#!/usr/bin/env python

+# gPapers
+# Copyright (C) 2007-2009 Derek Anderson
+# 2012 Derek Anderson and Marcel Stimberg
+#
+# This file is part of gPapers.
+#
+# gPapers 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.
+#
+# gPapers 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 gPapers. If not, see <http://www.gnu.org/licenses/>.
+
from distutils.core import setup

setup(name='gPapers',

==============================================================================
Revision: f8c6c2d9d2db
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:52:25 2012
Log: remove unused function and openanything module that is no longer
used as well
http://code.google.com/p/gpapers/source/detail?r=f8c6c2d9d2db

Deleted:
/gpapers/openanything.py
Modified:
/gpapers/__init__.py
/gpapers/importer/__init__.py

=======================================
--- /gpapers/openanything.py Thu Apr 5 14:13:17 2012
+++ /dev/null
@@ -1,165 +0,0 @@
-'''OpenAnything: a kind and thoughtful library for HTTP web services
-
-This program is part of 'Dive Into Python', a free Python book for
-experienced programmers. Visit http://diveintopython.org/ for the
-latest version.
-'''
-
-__author__ = 'Mark Pilgrim (ma...@diveintopython.org)'
-__version__ = '$Revision: 1.6 $'[11:-2]
-__date__ = '$Date: 2004/04/16 21:16:24 $'
-__copyright__ = 'Copyright (c) 2004 Mark Pilgrim'
-__license__ = 'Python'
-
-import cookielib, urllib2, urlparse, gzip, httplib, mimetypes
-from StringIO import StringIO
-from django.template.defaultfilters import urlencode
-
-
-USER_AGENT = 'OpenAnything/%s
+http://diveintopython.org/http_web_services/' % __version__
-
-cj = cookielib.CookieJar()
-
-class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
- def http_error_301(self, req, fp, code, msg, headers):
- result = urllib2.HTTPRedirectHandler.http_error_301(
- self, req, fp, code, msg, headers)
- result.status = code
- return result
-
- def http_error_302(self, req, fp, code, msg, headers):
- result = urllib2.HTTPRedirectHandler.http_error_302(
- self, req, fp, code, msg, headers)
- result.status = code
- return result
-
-class DefaultErrorHandler(urllib2.HTTPDefaultErrorHandler):
- def http_error_default(self, req, fp, code, msg, headers):
- result = urllib2.HTTPError(
- req.get_full_url(), code, msg, headers, fp)
- result.status = code
- return result
-
-def encode_post_data_dict( post_data ):
- data = []
- for key in post_data.keys():
- data.append( urlencode(key) +'='+ urlencode(post_data[key]) )
- return '&'.join(data)
-
-def encode_post_data( post_data ):
- data = []
- for x in post_data:
- data.append( urlencode(x[0]) +'='+ urlencode(x[1]) )
- return '&'.join(data)
-
-def openAnything( source, etag=None, lastmodified=None, agent=USER_AGENT,
post_data=None, files=None ):
- """URL, filename, or string --> stream
-
- This function lets you define parsers that take any input source
- (URL, pathname to local or network file, or actual data as a string)
- and deal with it in a uniform manner. Returned object is guaranteed
- to have all the basic stdio read methods (read, readline, readlines).
- Just .close() the object when you're done with it.
-
- If the etag argument is supplied, it will be used as the value of an
- If-None-Match request header.
-
- If the lastmodified argument is supplied, it must be a formatted
- date/time string in GMT (as returned in the Last-Modified header of
- a previous request). The formatted date/time will be used
- as the value of an If-Modified-Since request header.
-
- If the agent argument is supplied, it will be used as the value of a
- User-Agent request header.
- """
-
- if hasattr(source, 'read'):
- return source
-
- if source == '-':
- return sys.stdin
-
- if isinstance(post_data, dict):
- post_data_dict = post_data
- post_data = []
- for key in post_data_dict.keys():
- post_data.append( (key, post_data_dict[key]) )
-
- protocol = urlparse.urlparse(source)[0]
- if protocol=='http' or protocol=='https':
- # open URL with urllib2
- request = urllib2.Request(source)
- request.add_header('User-Agent', agent)
- if lastmodified:
- request.add_header('If-Modified-Since', lastmodified)
- if etag:
- request.add_header('If-None-Match', etag)
- if post_data and files:
- content_type, body = encode_multipart_formdata( post_data,
files )
- request.add_header('Content-Type', content_type)
- request.add_data(body)
- elif post_data:
- request.add_data( encode_post_data( post_data ) )
- request.add_header('Accept-encoding', 'gzip')
- opener = urllib2.build_opener(SmartRedirectHandler(),
DefaultErrorHandler(), urllib2.HTTPCookieProcessor(cj))
- return opener.open(request)
-
- # try to open with native open function (if source is a filename)
- try:
- return open(source)
- except (IOError, OSError):
- pass
-
- # treat source as string
- return StringIO(str(source))
-
-def fetch(source, etag=None, lastmodified=None, agent=USER_AGENT,
post_data=None, files=None):
- '''Fetch data and metadata from a URL, file, stream, or string'''
- result = {}
- f = openAnything(source, etag, lastmodified, agent, post_data, files)
- result['data'] = f.read()
- if hasattr(f, 'headers'):
- # save ETag, if the server sent one
- result['etag'] = f.headers.get('ETag')
- # save Last-Modified header, if the server sent one
- result['lastmodified'] = f.headers.get('Last-Modified')
- if f.headers.get('content-encoding') == 'gzip':
- # data came back gzip-compressed, decompress it
- result['data'] =
gzip.GzipFile(fileobj=StringIO(result['data'])).read()
- if hasattr(f, 'url'):
- result['url'] = f.url
- result['status'] = 200
- if hasattr(f, 'status'):
- result['status'] = f.status
- f.close()
- return result
-
-def encode_multipart_formdata(fields, files):
- """
- fields is a sequence of (name, value) elements for regular form fields.
- files is a sequence of (name, filename, value) elements for data to be
uploaded as files
- Return (content_type, body) ready for httplib.HTTP instance
- """
- BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
- CRLF = '\r\n'
- L = []
- for (key, value) in fields:
- L.append('--' + BOUNDARY)
- L.append('Content-Disposition: form-data; name="%s"' % key)
- L.append('')
- L.append(value)
- for (key, filename) in files:
- L.append('--' + BOUNDARY)
- L.append('Content-Disposition: form-data; name="%s";
filename="%s"' % (key, filename))
- L.append('Content-Type: %s' % get_content_type(filename))
- L.append('')
- L.append(open(filename,'rb').read())
- L.append('--' + BOUNDARY + '--')
- L.append('')
- body = CRLF.join(L)
- content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
- #print '--== encode_multipart_formdata:body ==--'
- return content_type, body
-
-def get_content_type(filename):
- return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
=======================================
--- /gpapers/__init__.py Mon Apr 9 13:29:00 2012
+++ /gpapers/__init__.py Mon Apr 9 13:52:25 2012
@@ -57,7 +57,7 @@
PDF_PREVIEW_MOVE_NOTE_DND_ACTION = ('move_note',
Gtk.TargetFlags.SAME_WIDGET, 2)

import gpapers.settings
-import gpapers.desktop, gpapers.openanything
+import gpapers.desktop

os.environ['DJANGO_SETTINGS_MODULE'] = 'gpapers.settings'
import django.core.management
=======================================
--- /gpapers/importer/__init__.py Mon Apr 9 13:29:00 2012
+++ /gpapers/importer/__init__.py Mon Apr 9 13:52:25 2012
@@ -37,7 +37,6 @@
#from gPapers.models import *
from django.template import defaultfilters
import BeautifulSoup
-from gpapers import openanything

from gpapers.logger import *
import bibtex
@@ -293,72 +292,6 @@
return import_citation(pdf_link)


-def find_and_attach_pdf(paper, urls, visited_urls=set()):
-
- # search for a PDF linked directly
- for url in urls:
- if url.find('?') > 0: url = url[ : url.find('?') ]
- if url.lower().endswith('pdf'):
- log_debug('found PDF link: %s' % url)
- visited_urls.add(url)
- params = openanything.fetch(url)
- if params['status'] == 200 or params['status'] == 302 :
- if params['data'].startswith('%PDF'):
- # we have a live one!
- try:
- filename = params['url'][ params['url'].rfind('/')
+ 1 : ]
- log_info('importing paper: %s' % filename)
-
paper.save_file(defaultfilters.slugify(filename.replace('.pdf', ''))
+ '.pdf', params['data'])
- paper.save()
- return True
- except:
- traceback.print_exc()
-
- for url in urls:
- visited_urls.add(url)
- params = openanything.fetch(url)
- if params['status'] == 200 or params['status'] == 302 :
- if params['data'].startswith('%PDF'):
- # we have a live one!
- try:
- filename = params['url'][ params['url'].rfind('/') +
1 : ]
- log_info('importing paper: %s' % filename)
-
paper.save_file(defaultfilters.slugify(filename.replace('.pdf', ''))
+ '.pdf', params['data'])
- paper.save()
- return True
- except:
- traceback.print_exc()
- else:
- soup = BeautifulSoup.BeautifulSoup(params['data'])
- promising_links = set()
- for a in soup.findAll('a', href=True):
- if len(a.contents) > 8: continue
- web_dir_root = params['url'][: params['url'].find('/',
8) ]
- web_dir_current = params['url'][:
params['url'].rfind('/') ]
- href = a['href']
- if not href.lower().startswith('http'):
- if href.startswith('/'):
- href = web_dir_root + href
- else:
- href = web_dir_current + '/' + href
- x = href
- if x.find('?') > 0: x = x[ : x.find('?') ]
- if x.lower().endswith('pdf'):
- if href not in visited_urls:
- log_info('found PDF link: %s' % a)
- promising_links.add(href)
- continue
- for c in a.contents:
- c = str(c).lower()
- if c.find('pdf') != -1:
- if href not in visited_urls:
- log_info('found PDF link: %s' % a)
- promising_links.add(href)
- continue
- if promising_links: print promising_links
- if find_and_attach_pdf(paper, list(promising_links),
visited_urls=visited_urls): return
-
-
def get_bibtex_for_doi(doi, callback):
'''
Asynchronously retrieves the bibtex data for a document with a given
`doi`,

==============================================================================
Revision: 4e4d5f5803af
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 13:44:00 2012
Log: add more dependencies and acknowledge code that is used within
gPapers
http://code.google.com/p/gpapers/source/detail?r=4e4d5f5803af

Modified:
/README

=======================================
--- /README Sat Mar 31 14:20:15 2012
+++ /README Mon Apr 9 13:44:00 2012
@@ -2,7 +2,7 @@
============

gPapers is currently developed and tested under Ubuntu 12.04 and depends
on the
-following packages:
+following packages (giving the current version numbers in Ubuntu 12.04):

gir1.2-glib-2.0: 1.32.0-1
gir1.2-gtk-3.0: 3.4.0-0ubuntu2
@@ -12,3 +12,16 @@
gir1.2-soup-2.4: 2.38.0-0ubuntu1
python-django: 1.3.1-4ubuntu1
python-pdfminer: 20110515+dfsg-1
+python-beautifulsoup: 3.2.0-2build1
+
+In addition, gPapers contains code from the following sources:
+
+deseb
+ http://code.google.com/p/deseb/
+ Written by Derek Anderson, published under a BSD license
+desktop
+ http://pypi.python.org/pypi/desktop
+ Written by Paul Boddie, published under LGPLv3
+pyparsing parser for BibTeX
+ http://pastebin.com/ZzU19NLJ
+ Written by Matthew Brett, published under a simplified BSD license

==============================================================================
Revision: b1b5eb2da764
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 14:09:14 2012
Log: rearrange imports a bit
http://code.google.com/p/gpapers/source/detail?r=b1b5eb2da764

Modified:
/gpapers/__init__.py
/gpapers/gPapers/models.py
/gpapers/importer/__init__.py
/gpapers/importer/google_scholar.py
/gpapers/importer/jstor.py
/gpapers/importer/pubmed.py

=======================================
--- /gpapers/__init__.py Mon Apr 9 13:52:25 2012
+++ /gpapers/__init__.py Mon Apr 9 14:09:14 2012
@@ -20,64 +20,67 @@
# You should have received a copy of the GNU General Public License
# along with gPapers. If not, see <http://www.gnu.org/licenses/>.

-import commands, math, os, sys, thread, threading, time, traceback
-import mimetypes
+import commands
from datetime import datetime, timedelta, date
-
-from gpapers.logger import *
-from gpapers.importer import bibtex, pdf_file
+import math
+import mimetypes
+import os
+import sys
+import thread
+import threading
+import time
+import traceback
+
from gi.repository import Gio
-
-log_level_debug()
-
-BASE_DIR = os.path.abspath(os.path.split(__file__)[0]) + '/../'
-PROGRAM = 'gPapers'
-__version__ = '0.5dev'
-
-DATE_FORMAT = '%Y-%m-%d'
-
-# GUI imports
-try:
- from gi.repository import GObject
- from gi.repository import Gdk
- from gi.repository import Gtk
- from gi.repository import GdkPixbuf
- from gi.repository import Pango
- from gi.repository import Poppler
- GObject.threads_init()
-except:
- traceback.print_exc()
- log_error('Could not import required GTK libraries.')
- sys.exit()
-
-LEFT_PANE_ADD_TO_PLAYLIST_DND_ACTION = ('add_to_playlist',
- Gtk.TargetFlags.SAME_APP, 0)
-MIDDLE_TOP_PANE_REORDER_PLAYLIST_DND_ACTION = ('reorder_playlist',
-
Gtk.TargetFlags.SAME_WIDGET, 1)
-PDF_PREVIEW_MOVE_NOTE_DND_ACTION = ('move_note',
Gtk.TargetFlags.SAME_WIDGET, 2)
-
-import gpapers.settings
-import gpapers.desktop
+from gi.repository import GObject
+from gi.repository import Gdk
+from gi.repository import Gtk
+from gi.repository import GdkPixbuf
+from gi.repository import Pango
+from gi.repository import Poppler

os.environ['DJANGO_SETTINGS_MODULE'] = 'gpapers.settings'
+import gpapers.settings
import django.core.management
-from django.core.exceptions import MultipleObjectsReturned
django.core.management.setup_environ(gpapers.settings)
+from django.core.exceptions import MultipleObjectsReturned
from django.db.models import Q
from django.template import defaultfilters
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver

import deseb
+
+from gpapers.logger import *
+from gpapers.importer import bibtex, pdf_file
+import gpapers.desktop
from gpapers.gPapers.models import *
import gpapers.importer as importer
-
from gpapers.importer import pango_escape, get_md5_hexdigest_from_data
from gpapers.importer import pubmed, google_scholar, jstor

-NOTE_ICON =
GdkPixbuf.Pixbuf.new_from_file(os.path.join(BASE_DIR, 'icons', 'note.png'))
-BOOKMARK_ICON =
GdkPixbuf.Pixbuf.new_from_file(os.path.join(BASE_DIR, 'icons', 'bookmark.png'))
-GRAPH_ICON =
GdkPixbuf.Pixbuf.new_from_file(os.path.join(BASE_DIR, 'icons', 'drawing.png'))
+log_level_debug()
+
+BASE_DIR = os.path.abspath(os.path.split(__file__)[0]) + '/../'
+PROGRAM = 'gPapers'
+DATE_FORMAT = '%Y-%m-%d'
+LEFT_PANE_ADD_TO_PLAYLIST_DND_ACTION = ('add_to_playlist',
+ Gtk.TargetFlags.SAME_APP, 0)
+MIDDLE_TOP_PANE_REORDER_PLAYLIST_DND_ACTION = ('reorder_playlist',
+
Gtk.TargetFlags.SAME_WIDGET, 1)
+PDF_PREVIEW_MOVE_NOTE_DND_ACTION = ('move_note',
Gtk.TargetFlags.SAME_WIDGET,
+ 2)
+NOTE_ICON = GdkPixbuf.Pixbuf.new_from_file(os.path.join(BASE_DIR, 'icons',
+ 'note.png'))
+BOOKMARK_ICON =
GdkPixbuf.Pixbuf.new_from_file(os.path.join(BASE_DIR, 'icons',
+ 'bookmark.png'))
+GRAPH_ICON = GdkPixbuf.Pixbuf.new_from_file(os.path.join(BASE_DIR, 'icons',
+ 'drawing.png'))
+
+__version__ = '0.5dev'
+
+GObject.threads_init()
+

def humanize_count(x, s, p, places=1):
output = []
=======================================
--- /gpapers/gPapers/models.py Thu Apr 5 14:13:17 2012
+++ /gpapers/gPapers/models.py Mon Apr 9 14:09:14 2012
@@ -19,7 +19,6 @@
from django.db import models
import django.core.files.base
from gpapers import desktop
-import pyPdf

from gpapers.logger import log_debug

=======================================
--- /gpapers/importer/__init__.py Mon Apr 9 13:52:25 2012
+++ /gpapers/importer/__init__.py Mon Apr 9 14:09:14 2012
@@ -17,11 +17,23 @@
# You should have received a copy of the GNU General Public License
# along with gPapers. If not, see <http://www.gnu.org/licenses/>.

-import commands, dircache, getopt, math, os, re, string, sys, thread,
threading, time, traceback
+import commands
+import dircache
+import getopt
+import math
+import os
+import re
+import string
+import sys
+import thread
+import threading
+import time
+import traceback
from datetime import date, datetime, timedelta
from time import strptime
from htmlentitydefs import name2codepoint as n2cp
-import urllib, urlparse
+import urllib
+import urlparse
import hashlib

import gi
@@ -31,10 +43,6 @@
from gi.repository import Gtk
from gi.repository import Pango
from gi.repository import Soup
-
-from pyPdf import PdfFileReader
-
-#from gPapers.models import *
from django.template import defaultfilters
import BeautifulSoup

=======================================
--- /gpapers/importer/google_scholar.py Mon Apr 9 13:29:00 2012
+++ /gpapers/importer/google_scholar.py Mon Apr 9 14:09:14 2012
@@ -17,10 +17,12 @@
# You should have received a copy of the GNU General Public License
# along with gPapers. If not, see <http://www.gnu.org/licenses/>.

-import urllib, hashlib, random, traceback
+import urllib
+import hashlib
+import random
+import traceback

from gi.repository import Soup # @UnresolvedImport
-
import BeautifulSoup
from django.template import defaultfilters

=======================================
--- /gpapers/importer/jstor.py Mon Apr 9 13:29:00 2012
+++ /gpapers/importer/jstor.py Mon Apr 9 14:09:14 2012
@@ -19,9 +19,9 @@

from gi.repository import Soup
from BeautifulSoup import BeautifulStoneSoup
+
from gpapers.importer import SimpleWebSearchProvider
from gpapers.gPapers.models import Paper
-
from gpapers.logger import *

QUERY_STRING = 'http://dfr.jstor.org/sru/?version=1.1&' + \
=======================================
--- /gpapers/importer/pubmed.py Mon Apr 9 13:29:00 2012
+++ /gpapers/importer/pubmed.py Mon Apr 9 14:09:14 2012
@@ -20,11 +20,10 @@
import urllib

import BeautifulSoup
+from BeautifulSoup import BeautifulStoneSoup
from gi.repository import Soup # @UnresolvedImport

from gpapers.logger import log_debug, log_info, log_error
-from BeautifulSoup import BeautifulStoneSoup
-
from gpapers.importer import WebSearchProvider, soup_session

BASE_URL = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/'

==============================================================================
Revision: 18d7c60a2481
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 14:16:22 2012
Log: make directory import equivalent to file import
http://code.google.com/p/gpapers/source/detail?r=18d7c60a2481

Modified:
/gpapers/__init__.py

=======================================
--- /gpapers/__init__.py Mon Apr 9 14:09:14 2012
+++ /gpapers/__init__.py Mon Apr 9 14:16:22 2012
@@ -498,8 +498,16 @@
dialog.show_all()
response = dialog.run()
if response == Gtk.ResponseType.OK:
- threading.Thread(target=import_documents_via_filenames,
- args=(dialog.get_filenames(),)).start()
+
+ def mycallback(file_object, asyncresult, user_data):
+ # Get the actual file content
+ file_content =
file_object.load_contents_finish(asyncresult)[1]
+
+ self.document_imported(paper_data=file_content,
paper_info=None,
+ user_data=user_data)
+
+ import_documents_via_filenames(dialog.get_filenames(),
+ mycallback)
dialog.destroy()

def import_bibtex_dialog(self, o):

==============================================================================
Revision: cfc6481144cd
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 14:43:34 2012
Log: fix table refresh
http://code.google.com/p/gpapers/source/detail?r=cfc6481144cd

Modified:
/gpapers/__init__.py

=======================================
--- /gpapers/__init__.py Mon Apr 9 14:16:22 2012
+++ /gpapers/__init__.py Mon Apr 9 14:43:34 2012
@@ -33,6 +33,7 @@

from gi.repository import Gio
from gi.repository import GObject
+from gi.repository import GLib
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GdkPixbuf
@@ -577,12 +578,14 @@
self.init_bookmark_pane()
self.init_pdf_preview_pane()
self.refresh_left_pane()
+
# make sure the GUI updates on database changes
def receiver_wrapper(sender, **kwargs):
- # Make sure this gets only called from the main thread
- GObject.idle_add(lambda x : self.handle_library_updates, ())
+ self.handle_library_updates()
+
post_save.connect(receiver_wrapper, sender=Paper, weak=False)
post_delete.connect(receiver_wrapper, sender=Paper, weak=False)
+
self.main_window.show()

def init_busy_notifier(self):

==============================================================================
Revision: aca8357a17e3
Author: Marcel Stimberg <marcel...@gmail.com>
Date: Mon Apr 9 14:48:32 2012
Log: remove status message about searching the local library
http://code.google.com/p/gpapers/source/detail?r=aca8357a17e3

Modified:
/gpapers/__init__.py

=======================================
--- /gpapers/__init__.py Mon Apr 9 14:43:34 2012
+++ /gpapers/__init__.py Mon Apr 9 14:48:32 2012
@@ -613,6 +613,7 @@
for x in self.active_threads.items():
self.treeview_running_tasks_model.append(x)
if not self.busy_notifier_is_running:
+ log_debug('Setting spinning busy notifier')

self.ui.get_object('busy_notifier').set_from_file(os.path.join(BASE_DIR, 'icons', 'process-working.gif'))
self.busy_notifier_is_running = True
self.ui.get_object('treeview_running_tasks').show()
@@ -1973,7 +1974,6 @@
self.refresh_my_library_filter_pane)

def refresh_middle_pane_from_my_library(self,
refresh_library_filter_pane=True):
- self.active_threads[ str(thread.get_ident()) ] = 'searching local
library...'
try:
rows = []
my_library_filter_pane =
self.ui.get_object('my_library_filter_pane')
@@ -2090,8 +2090,6 @@
self.refresh_my_library_count()
except:
traceback.print_exc()
- if self.active_threads.has_key(str(thread.get_ident())):
- del self.active_threads[ str(thread.get_ident()) ]

def refresh_my_library_count(self):
selection = self.ui.get_object('left_pane_selection')
Reply all
Reply to author
Forward
0 new messages