1. Jason R. Coombs
  2. jaraco.office

Commits

jaraco  committed 61561bd

Removed src folder (unnecessary container)

  • Participants
  • Parent commits d2979a1
  • Branches default

Comments (0)

Files changed (8)

File jaraco/__init__.py

View file
+# this is a namespace package
+__import__('pkg_resources').declare_namespace(__name__)

File jaraco/excel/__init__.py

View file
+#

File jaraco/excel/excel.py

View file
+
+def sheet_as_dict(worksheet):
+	"""
+	Take an xsrd worksheet and convert it to a dict, using the first
+	row as a header (to create keys for the subsequent rows).
+	"""
+	keys = worksheet.row_values(0)
+	value_range = range(1, worksheet.nrows)
+	to_dict = lambda values: dict(zip(keys, values))
+	return [
+		to_dict(worksheet.row_values(n))
+		for n in value_range
+		]

File jaraco/excel/grep.py

View file
+from win32com.client import Dispatch
+from itertools import takewhile
+import re
+
+app = Dispatch('Excel.Application')
+#wb = app.Workbooks.Open(filename)
+
+default_pattern = 'Total'
+
+def CleanRow(row):
+	return filter(None, row.Value[0])
+
+def HasPattern(row, pattern = default_pattern):
+	strings = map(unicode, CleanRow(row))
+	pattern = re.compile(pattern, re.I)
+	return bool(filter(pattern.search, strings))
+
+def NotHasPattern(row, pattern = default_pattern):
+	return not HasPattern(row, pattern)
+
+def IsNotBlank(row):
+	return bool(CleanRow(row))
+
+def IsBlank(row):
+	return not IsNotBlank(row)
+
+def DeleteUnmatchedRows():
+	"""
+	Delete rows that don't match the pattern; you'll have to run this
+	multiple times if you want to get consecutive matches
+	"""
+	# excel doesn't support iteration
+	#valueRows = takewhile(IsNotBlank, app.Rows)
+	#map(DeleteRow, filter(NotHasPattern, valueRows))
+	for row in GetPopulatedRows():
+		if NotHasPattern(row):
+			print 'deleting row', CleanRow(row)
+			row.Delete()
+
+def GetPopulatedRows():
+	for row in app.Rows:
+		if IsBlank(row): break
+		yield row
+
+def FixBlankWPNCD(row):
+	if row.Cells(1,1).Value is None:
+		app.Cells(row.Row, row.Column).Value = app.Cells(row.Row-1, row.Column).Value

File src/jaraco/__init__.py

-# this is a namespace package
-__import__('pkg_resources').declare_namespace(__name__)

File src/jaraco/excel/__init__.py

-#

File src/jaraco/excel/excel.py

-
-def sheet_as_dict(worksheet):
-	"""
-	Take an xsrd worksheet and convert it to a dict, using the first
-	row as a header (to create keys for the subsequent rows).
-	"""
-	keys = worksheet.row_values(0)
-	value_range = range(1, worksheet.nrows)
-	to_dict = lambda values: dict(zip(keys, values))
-	return [
-		to_dict(worksheet.row_values(n))
-		for n in value_range
-		]

File src/jaraco/excel/grep.py

-from win32com.client import Dispatch
-from itertools import takewhile
-import re
-
-app = Dispatch('Excel.Application')
-#wb = app.Workbooks.Open(filename)
-
-default_pattern = 'Total'
-
-def CleanRow(row):
-	return filter(None, row.Value[0])
-
-def HasPattern(row, pattern = default_pattern):
-	strings = map(unicode, CleanRow(row))
-	pattern = re.compile(pattern, re.I)
-	return bool(filter(pattern.search, strings))
-
-def NotHasPattern(row, pattern = default_pattern):
-	return not HasPattern(row, pattern)
-
-def IsNotBlank(row):
-	return bool(CleanRow(row))
-
-def IsBlank(row):
-	return not IsNotBlank(row)
-
-def DeleteUnmatchedRows():
-	"""
-	Delete rows that don't match the pattern; you'll have to run this
-	multiple times if you want to get consecutive matches
-	"""
-	# excel doesn't support iteration
-	#valueRows = takewhile(IsNotBlank, app.Rows)
-	#map(DeleteRow, filter(NotHasPattern, valueRows))
-	for row in GetPopulatedRows():
-		if NotHasPattern(row):
-			print 'deleting row', CleanRow(row)
-			row.Delete()
-
-def GetPopulatedRows():
-	for row in app.Rows:
-		if IsBlank(row): break
-		yield row
-
-def FixBlankWPNCD(row):
-	if row.Cells(1,1).Value is None:
-		app.Cells(row.Row, row.Column).Value = app.Cells(row.Row-1, row.Column).Value