[pybliographer] pyblio: pyflakes
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pybliographer] pyblio: pyflakes
- Date: Wed, 28 Mar 2018 23:07:42 +0000 (UTC)
commit d9a472a88c7bcd467011deefc7286b9755b1a810
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Wed Mar 28 15:43:42 2018 -0300
pyblio: pyflakes
Pyblio/Autoload.py | 22 +++++++++++-----------
Pyblio/Base.py | 33 +++++++++++++++------------------
Pyblio/Config.py | 22 +++++++++++++---------
Pyblio/Fields.py | 30 +++++++++++++++++-------------
Pyblio/Formatter.py | 21 ++++++++++-----------
Pyblio/Key.py | 25 ++++++++++++-------------
Pyblio/LyX.py | 26 +++++++++++++++-----------
Pyblio/Open.py | 21 +++++++++++----------
Pyblio/Query.py | 28 +++++++++++++++++-----------
Pyblio/Resource.py | 13 ++++++++-----
Pyblio/Search.py | 24 ++++++++++++------------
Pyblio/Selection.py | 23 ++++++++++-------------
Pyblio/Sort.py | 46 ++++++++++++++++++++++++----------------------
Pyblio/TextUI.py | 30 +++++++++++++++---------------
Pyblio/Types.py | 3 ++-
Pyblio/Utils.py | 27 ++++++++++++++-------------
Pyblio/ut_Utils.py | 13 +++----------
17 files changed, 209 insertions(+), 198 deletions(-)
---
diff --git a/Pyblio/Autoload.py b/Pyblio/Autoload.py
index ccb17a2..74a4766 100644
--- a/Pyblio/Autoload.py
+++ b/Pyblio/Autoload.py
@@ -1,25 +1,23 @@
# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyirhgt (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
-#
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
-
+#
"""
Handling of on-demand loading of python extensions.
@@ -39,7 +37,9 @@ the module is expected to call Autoload.register to define which entry
point it provides.
"""
-import os, string, re, sys
+import string
+import re
+
class Loader:
''' An object containing the description of a loadable object '''
diff --git a/Pyblio/Base.py b/Pyblio/Base.py
index e421e00..f06e672 100644
--- a/Pyblio/Base.py
+++ b/Pyblio/Base.py
@@ -1,36 +1,33 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
''' This Module contains the base classes one might want to inherit
from in order to provide a new database format '''
-
-from string import *
-import re, copy, os
-import Pyblio.Help
-from types import *
+import os
+import string
+import shutil
from Pyblio import Autoload, Config, Iterator, Key, Open, Selection, Utils
-from shutil import copyfile
class Entry:
'''
@@ -116,7 +113,7 @@ class Entry:
dico = self.keys ()
for f in fields:
name = f.name
- lcname = lower(name)
+ lcname = string.lower(name)
if not self.has_key(lcname):
continue
@@ -241,7 +238,7 @@ class DataBase:
name = self.key.url[2]
if Config.get('base/directsave').data:
if Config.get('base/backup').data:
- copyfile(name, name + '.bak')
+ shutil.copyfile(name, name + '.bak')
namefile = open(name, 'w')
iterator = Selection.Selection(sort=sorting).iterator(self.iterator())
Open.bibwrite(iterator, out=namefile, how=self.id, database=self)
diff --git a/Pyblio/Config.py b/Pyblio/Config.py
index 842bb34..3e22207 100644
--- a/Pyblio/Config.py
+++ b/Pyblio/Config.py
@@ -1,29 +1,33 @@
# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
+#
# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
-#
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
''' System for Configuration handling '''
+import atexit
+import cPickle
+import os
+import string
+import sys
+import types
-import atexit, cPickle, os, string, sys, types
pickle = cPickle
del cPickle
diff --git a/Pyblio/Fields.py b/Pyblio/Fields.py
index 1e59e8d..c79e74e 100644
--- a/Pyblio/Fields.py
+++ b/Pyblio/Fields.py
@@ -1,27 +1,32 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
-from Pyblio import Exceptions, Key
+import os
+import re
+import recode
+import string
+import types
+import urlparse
-import copy, os, re, recode, string, time, types, urlparse
+from Pyblio import Exceptions, Key
year_match = re.compile ('(\d\d\d\d)')
@@ -533,4 +538,3 @@ class Reference:
ft = get_formatter (fmt)
return map (ft, self.list)
-
diff --git a/Pyblio/Formatter.py b/Pyblio/Formatter.py
index 91e5046..92f4dd6 100644
--- a/Pyblio/Formatter.py
+++ b/Pyblio/Formatter.py
@@ -1,23 +1,23 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
''' This class defines certain graphical properties of output, in
order to insulate a bibliographic style definition from its
@@ -25,7 +25,6 @@ realization in a given language '''
import sys
-from Pyblio import Autoload, Base
class Formatter:
diff --git a/Pyblio/Key.py b/Pyblio/Key.py
index 9323877..365e1e0 100644
--- a/Pyblio/Key.py
+++ b/Pyblio/Key.py
@@ -1,25 +1,25 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
-from types import *
+import types
class Key:
@@ -34,7 +34,7 @@ class Key:
database itself. '''
def __init__ (self, base, key):
- if type (key) is InstanceType:
+ if type (key) is types.InstanceType:
self.base = key.base
self.key = key.key
else:
@@ -69,4 +69,3 @@ class Key:
def __hash__ (self):
return hash (`self.key` + `self.base`)
-
diff --git a/Pyblio/LyX.py b/Pyblio/LyX.py
index 2c3203e..2a1971d 100644
--- a/Pyblio/LyX.py
+++ b/Pyblio/LyX.py
@@ -1,29 +1,31 @@
# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) Germán Poo-Caamaño <gpoo gnome org>
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
-#
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
-import os, string, select, signal
+import os
+import string
+import signal
from Pyblio import Config
+
class LyXClient:
def __init__ (self):
self.pin = None
@@ -34,12 +36,14 @@ class LyXClient:
pin = os.path.expanduser (base + '.in')
try:
ans = os.stat (pin)
- except OSError, msg:
+ del ans
+ except OSError:
raise IOError (_(u"no input pipe “%s”") % pin)
pout = os.path.expanduser (base + '.out')
try:
ans = os.stat (pout)
+ del ans
except os.error:
raise IOError (_(u"no output pipe “%s”") % pout)
diff --git a/Pyblio/Open.py b/Pyblio/Open.py
index 364c9d5..446112b 100644
--- a/Pyblio/Open.py
+++ b/Pyblio/Open.py
@@ -1,31 +1,32 @@
# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
+#
# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
-#
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
+import os
+import sys
+import urllib
+import urlparse
-from types import *
from Pyblio import Autoload, Config, Exceptions, Fields, Help
-import os, string, sys, tempfile, traceback, urllib, urlparse
def url_to_local (url):
diff --git a/Pyblio/Query.py b/Pyblio/Query.py
index 964f68c..a6043f9 100644
--- a/Pyblio/Query.py
+++ b/Pyblio/Query.py
@@ -1,23 +1,24 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
+
"""
Search a keyword in a medline database
@@ -28,7 +29,12 @@ Updated by Z. Kota in 2011 for eutils.
"""
# The time module is added for querying date ranges of publications
-import urllib, urllib2, sys, re, string, time, tempfile, os
+import os
+import urllib
+import urllib2
+import time
+import tempfile
+
from xml.dom.minidom import parse
diff --git a/Pyblio/Resource.py b/Pyblio/Resource.py
index ef407ee..276094e 100644
--- a/Pyblio/Resource.py
+++ b/Pyblio/Resource.py
@@ -2,7 +2,7 @@
# This file is part of pybliographer
#
# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
-# Copyright (C) 2005 Peter Schulte-Stracke <mail schulte-stracke de>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -27,16 +27,19 @@
"""
+import os
+import sys
+import urllib
+import gio
+
+from Pyblio import Config, Fields, userexit
+
config_fields = 'resource/viewable-fields'
config_viewers = 'resource/viewers'
CHOOSER_ACTIONS = ('enter/edit', 'select', 'select-directory',
'download', 'move/copy' )
-import os, sys, urllib, urlparse
-import gio
-
-from Pyblio import Config, Fields, userexit
def is_interactive ():
return sys.modules.has_key ('gtk')
diff --git a/Pyblio/Search.py b/Pyblio/Search.py
index 74c09c7..2d19ab5 100644
--- a/Pyblio/Search.py
+++ b/Pyblio/Search.py
@@ -1,28 +1,28 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
''' In this module are defined the search operators that can be applied
in a Selection '''
-from string import *
+import string
import re
# ----- Boolean tests -----
@@ -61,7 +61,7 @@ class Tester (Bool):
Bool.__init__ (self)
self.__test = re.compile (value, re.IGNORECASE)
- self.field = lower (field)
+ self.field = string.lower(field)
self.value = value
return
diff --git a/Pyblio/Selection.py b/Pyblio/Selection.py
index 9bf5cf0..69b4c8b 100644
--- a/Pyblio/Selection.py
+++ b/Pyblio/Selection.py
@@ -1,23 +1,23 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
from Pyblio.Iterator import Iterator
@@ -126,6 +126,3 @@ class Selection:
return SortSelection (self.sort,
SearchSelection (self.search, iterator))
-
-
-
diff --git a/Pyblio/Sort.py b/Pyblio/Sort.py
index ee6ace6..94fd757 100644
--- a/Pyblio/Sort.py
+++ b/Pyblio/Sort.py
@@ -1,42 +1,44 @@
# -*- coding: iso-8859-1 -*-
# This file is part of pybliographer
-#
+#
# Copyright (C) 1998-2004 Frederic GOBRY
# Email : gobry pybliographer org
-#
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
+#
-from Pyblio import Fields, Types
+import re
+import string
+
+from Pyblio import Types
-import re, string, time
class Sort:
''' This class defines the methods used to sort a database '''
-
+
def __init__ (self, fields = None):
''' Create a Sort class with a given set of SortFields '''
-
+
self.fields = fields or []
return
def sort (self, iterator):
''' Returns a list of keys sorted according to the current
sort settings '''
-
+
self.base = iterator.base
S = []
@@ -55,7 +57,7 @@ class Sort:
return 'Sort (%s)' % str (self.fields)
class AnySort (object):
-
+
def __init__ (self, ascend = 1):
self.ascend = ascend
return
@@ -68,7 +70,7 @@ class AnySort (object):
extractor (e))
else :
return extractor
-
+
class TypeSort (AnySort):
def get_field (self, entry):
@@ -100,7 +102,7 @@ class KeySort (AnySort):
return [str(entry.key).lower()]
class FieldSort (AnySort):
-
+
def __init__ (self, field, ascend = 1):
self.field = field
AnySort.__init__ (self, ascend)
@@ -121,7 +123,7 @@ class FieldSort (AnySort):
rakify, entry.get(field, [])))
else:
return AnySort.get_extractor(self)
-
+
def get_field (self, entry):
try:
return entry [self.field]
@@ -133,7 +135,7 @@ class FieldSort (AnySort):
def __cmp__ (self, other):
if not hasattr (other, 'field'): return -1
-
+
return cmp (string.lower (self.field),
string.lower (other.field))
@@ -142,20 +144,20 @@ class FieldSort (AnySort):
return [str(entry[self.field]).rstrip().lower()]
except KeyError :
return []
-
+
def author_editor_extractor (self, entry):
return map (rakify, entry.get('author', entry.get('editor', [])))
-
+
def date_extractor (self, entry):
d = entry.get('date', 0)
try:
return [d.asInt()]
except AttributeError:
return [0]
-
+
def rakify (author):
-
+
s = "%s,%s" %(author.last,author.first)
s = s.lower()
Z = []
diff --git a/Pyblio/TextUI.py b/Pyblio/TextUI.py
index 01bb81a..3db09db 100644
--- a/Pyblio/TextUI.py
+++ b/Pyblio/TextUI.py
@@ -1,33 +1,33 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
''' This module provides basical high level functions '''
-from types import *
+import os
+import sys
+import string
-import os, sys, traceback, tempfile, string
-
-from Pyblio import Base, Help, Search, Types, Autoload, Fields
+from Pyblio import Help, Search, Types, Autoload, Fields
from Pyblio.Selection import Selection
-from Pyblio.Open import bibopen, bibwrite, bibnew
+from Pyblio.Open import bibwrite
from Pyblio.Style import Utils
# ----- Create elementary Test -----
diff --git a/Pyblio/Types.py b/Pyblio/Types.py
index 845ea78..3597525 100644
--- a/Pyblio/Types.py
+++ b/Pyblio/Types.py
@@ -19,7 +19,8 @@
#
#
-import string, copy
+import string
+
from Pyblio import Config, Fields
diff --git a/Pyblio/Utils.py b/Pyblio/Utils.py
index caa4023..e13618c 100644
--- a/Pyblio/Utils.py
+++ b/Pyblio/Utils.py
@@ -1,30 +1,33 @@
+# -*- coding: utf-8 -*-
# This file is part of pybliographer
-#
-# Copyright (C) 1998-2004 Frederic GOBRY
-# Email : gobry pybliographer org
-#
+#
+# Copyright (C) 2018 Germán Poo-Caamaño <gpoo gnome org>
+# Copyright (C) 1998-2004 Frederic GOBRY <gobry pybliographer org>
+#
# 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 2
+# as published by the Free Software Foundation; either version 2
# 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.
-#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#
+#
+
import re
-from string import *
+
+from string import rstrip, join, split
from Pyblio import Key, Autoload, recode
_flat = recode.recode ('latin1..flat')
+
def compress_page_range (pages, separator='-'):
"""Returns a page range with common prefix
elided from the second number. Resulte is string
@@ -150,5 +153,3 @@ class StringStream:
def write (self, text):
self.text = self.text + text
return
-
-
diff --git a/Pyblio/ut_Utils.py b/Pyblio/ut_Utils.py
index 542b153..ede68c6 100644
--- a/Pyblio/ut_Utils.py
+++ b/Pyblio/ut_Utils.py
@@ -1,16 +1,14 @@
# unit test for Utils
-
-import unittest, sys
+import unittest
+import sys
sys.path.append ('..')
-from Pyblio import Utils, userformat
-
+from Pyblio import Utils
class compress_page_range_test (unittest.TestCase):
-
data = [("1-9", '1', '9'),
("200-201", '200', '1'),
("300-500", '300', '500'),
@@ -18,15 +16,10 @@ class compress_page_range_test (unittest.TestCase):
]
def test01 (self):
-
for i in self.data:
p, r = i[0], i[1:]
self.assertEqual (Utils.compress_page_range(p,False), r)
-
if __name__ == '__main__':
unittest.main ()
-
-
-
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]