Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/01-web/04-twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# The pd() function returns the parent directory of this script + any given path.
table = Datasheet.load(pd("cool.csv"))
index = set(table.columns[0])
except:
except Exception:
table = Datasheet()
index = set()

Expand Down
2 changes: 1 addition & 1 deletion examples/01-web/11-facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# With an index on the first column we can quickly check if an id already exists.
table = Datasheet.load(pd("opinions.csv"))
index = set(table.columns[0])
except:
except Exception:
table = Datasheet()
index = set()

Expand Down
2 changes: 1 addition & 1 deletion examples/06-graph/05-trends.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# Exclude common phrases such as "this is the new thing".
if A and B and A not in ("it", "this", "here", "what", "why", "where"):
comparisons.append((A, B))
except:
except Exception:
pass

g = Graph()
Expand Down
2 changes: 1 addition & 1 deletion pattern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@
# (instead of pattern.text.en, pattern.text.es, ...)
try:
__path__.append(os.path.join(__path__[0], "text"))
except:
except Exception:
pass
18 changes: 9 additions & 9 deletions pattern/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

from pattern.helpers import encode_string, decode_string
Expand Down Expand Up @@ -259,12 +259,12 @@ def date(*args, **kwargs):
args = (args[0].decode("utf-8"),)
try:
d = Date.fromtimestamp(mktime_tz(parsedate_tz(args[0])))
except:
except Exception:
for format in ("format" in kwargs and [kwargs["format"]] or []) + date_formats:
try:
d = Date.strptime(args[0], format)
break
except:
except Exception:
pass
if d is None:
raise DateError("unknown date format for %s" % repr(args[0]))
Expand Down Expand Up @@ -334,7 +334,7 @@ def encrypt_string(s, key=""):
for i in range(len(s)):
try:
a.append(chr(ord(s[i]) + ord(key[i % len(key)]) % 256).encode("latin-1"))
except:
except Exception:
raise EncryptionError()
s = b"".join(a)
s = base64.urlsafe_b64encode(s)
Expand All @@ -351,7 +351,7 @@ def decrypt_string(s, key=""):
for i in range(len(s)):
try:
a.append(chr(ord(s[i]) - ord(key[i % len(key)]) % 256))
except:
except Exception:
raise DecryptionError()
s = "".join(a)
s = decode_utf8(s)
Expand Down Expand Up @@ -456,7 +456,7 @@ def cast(x, f, default=None):
f = lambda x: int(round(float(x)))
try:
return f(x)
except:
except Exception:
return default

#### LIST FUNCTIONS ################################################################################
Expand Down Expand Up @@ -864,7 +864,7 @@ def _delete(self):
def __delete__(self):
try:
self.disconnect()
except:
except Exception:
pass

#### FIELD #########################################################################################
Expand Down Expand Up @@ -2154,7 +2154,7 @@ def insert(self, i, row, default=None, **kwargs):
try:
# Copy the row (fast + safe for generators and DatasheetColumns).
row = [v for v in row]
except:
except Exception:
raise TypeError("Datasheet.insert(x): x must be list")
list.insert(self, i, row)
m = max((len(self) > 1 and self._m or 0, len(row)))
Expand Down Expand Up @@ -2461,7 +2461,7 @@ def insert(self, j, column, default=None, field=None):
"""
try:
column = [v for v in column]
except:
except Exception:
raise TypeError("Datasheet.columns.insert(x): x must be list")
column = column + [default] * (len(self._datasheet) - len(column))
if len(column) > len(self._datasheet):
Expand Down
2 changes: 1 addition & 1 deletion pattern/graph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

# float("inf") doesn't work on windows.
Expand Down
2 changes: 1 addition & 1 deletion pattern/graph/commonsense.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

if sys.version > "3":
Expand Down
4 changes: 2 additions & 2 deletions pattern/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def decode_string(v, encoding="utf-8"):
for e in encoding:
try:
return v.decode(*e)
except:
except Exception:
pass
return v
return str(v)
Expand All @@ -36,7 +36,7 @@ def encode_string(v, encoding="utf-8"):
for e in encoding:
try:
return v.encode(*e)
except:
except Exception:
pass
return v
return bytes(v)
Expand Down
2 changes: 1 addition & 1 deletion pattern/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def run():
raise TypeError("%s is not a function" % type(function))
try:
import cProfile as profile
except:
except Exception:
import profile
import pstats
import os
Expand Down
12 changes: 6 additions & 6 deletions pattern/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
try:
# Folder that contains pattern.server.
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

try:
Expand All @@ -79,7 +79,7 @@
f = inspect.getouterframes(f)[-1][0]
f = f.f_globals["__file__"]
SCRIPT = os.path.dirname(os.path.abspath(f))
except:
except Exception:
SCRIPT = os.getcwd()


Expand All @@ -95,7 +95,7 @@ def chown(path, owner=None):
grp.getgrnam(y).gr_gid if not isinstance(y, int) else y)
os.chown(path, x, y)
return True
except:
except Exception:
return False

# On Linux + Apache mod_wsgi, the user that executes the Python script is "www-data".
Expand Down Expand Up @@ -339,7 +339,7 @@ def __repr__(self):
def __del__(self):
try:
self.disconnect()
except:
except Exception:
pass

@property
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def _cast(self, v):
return ""
try: # (bool, int, float, object.__unicode__)
return str(v)
except:
except Exception:
return encode_entities(repr(v))

@cp.expose
Expand Down Expand Up @@ -1327,7 +1327,7 @@ def stop(self):
"""
try:
atexit._exithandlers.remove((self.stop, (), {}))
except:
except Exception:
pass
cp.engine.exit()
sys.stdout = sys.__stdout__
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

from pattern.text.tree import Tree, Text, Sentence, Slice, Chunk, PNPChunk, Chink, Word, table
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/de/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/de/inflect.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/en/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/en/inflect.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
10 changes: 5 additions & 5 deletions pattern/text/en/inflect_quantify.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down Expand Up @@ -155,7 +155,7 @@ def number(s):
# Words that are not in any dicionary may be numbers (e.g. "2.5" => 2.5).
try:
i += "." in x and float(x) or int(x)
except:
except Exception:
pass
return n + i + f

Expand Down Expand Up @@ -267,7 +267,7 @@ def approximate(word, amount=1, plural={}):
"""
try:
p = pluralize(word, custom=plural)
except:
except Exception:
raise TypeError("can't pluralize %s (not a string)" % word.__class__.__name__)
# Anything up to 200.
if amount == 0:
Expand Down Expand Up @@ -331,7 +331,7 @@ def count(*args, **kwargs):
try:
count.setdefault(word, 0)
count[word] += 1
except:
except Exception:
raise TypeError("can't count %s (not a string)" % word.__class__.__name__)
# Create an iterator of (count, item) tuples, sorted highest-first.
s = [(count[word], word) for word in count]
Expand Down Expand Up @@ -394,7 +394,7 @@ def reflect(object, quantify=True, replace=readable_types):
for v in object.__dict__.values():
try:
types.append(str(v.__classname__))
except:
except Exception:
# Not a class after all (some stuff like ufunc in Numeric).
types.append(_type(v))
# Lists and tuples can consist of several types of objects.
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/en/wordlist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""


Expand Down
10 changes: 5 additions & 5 deletions pattern/text/en/wordnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

# Path to WordNet /dict folder.
Expand Down Expand Up @@ -98,7 +98,7 @@ def normalize(word):
if not isinstance(word, str):
try:
word = word.encode("utf-8", "ignore")
except:
except Exception:
pass
for k, v in DIACRITICS.items():
for v in v:
Expand Down Expand Up @@ -154,7 +154,7 @@ def __getitem__(self, k):
for pos in ("n", "v", "a", "r"):
try:
synset = wn._synset_from_pos_and_offset(pos, k)
except:
except Exception:
pass
if synset:
return synset
Expand Down Expand Up @@ -429,7 +429,7 @@ def map32(id, pos=NOUN):

try:
from pattern.text import Sentiment
except:
except Exception:
class Sentiment(object):
PLACEHOLDER = True

Expand All @@ -455,7 +455,7 @@ def synset(self, id, pos=ADJECTIVE):
s = wn._synset_from_pos_and_offset(pos, id)
lemma = s.lemma_names()[0]
return self[lemma]
except:
except Exception:
pass

return None
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/es/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/es/inflect.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/fr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/fr/inflect.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
2 changes: 1 addition & 1 deletion pattern/text/it/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

try:
MODULE = os.path.dirname(os.path.realpath(__file__))
except:
except Exception:
MODULE = ""

sys.path.insert(0, os.path.join(MODULE, "..", "..", "..", ".."))
Expand Down
Loading