Skip to content

Commit

Permalink
Added pyatom project for gathering some more metrics.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkwiatkowski committed Apr 16, 2011
1 parent 6b29377 commit 94186f5
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions pythoscope/generator/objects_namer.py
Expand Up @@ -9,6 +9,7 @@ def get_name_base_for_object(obj):
common_names = {'list': 'alist',
'dict': 'adict',
'array.array': 'array',
'datetime': 'dt', # we can't name it 'datetime', because that is module's name
'types.FunctionType': 'function',
'types.GeneratorType': 'generator'}
return common_names.get(obj.type_name, underscore(obj.type_name))
Expand Down
11 changes: 9 additions & 2 deletions pythoscope/inspector/static.py
Expand Up @@ -27,10 +27,15 @@ def unindent(string):
"""Remove the initial part of whitespace from string.
>>> unindent("1 + 2 + 3\\n")
'1 + 2 + 3\\n'
'1 + 2 + 3'
>>> unindent(" def fun():\\n return 42\\n")
'def fun():\\n return 42\\n'
'def fun():\\n return 42'
>>> unindent("\\n def fun():\\n return 42\\n")
'def fun():\\n return 42'
>>> unindent(" def fun():\\n return 42\\n\\n")
'def fun():\\n return 42'
"""
string = re.sub(r'^\n*', '', string.rstrip()) # ignore leading and trailing newlines
match = re.match(r'^([\t ]+)', string)
if not match:
return string
Expand Down Expand Up @@ -61,6 +66,8 @@ def is_generator_definition(definition):
True
>>> is_generator_definition(" def indented_gen():\\n yield 3\\n")
True
>>> is_generator_definition("\\n def indented_gen():\\n yield 3\\n")
True
"""
try:
return is_generator_code(function_code_from_definition(definition))
Expand Down
4 changes: 4 additions & 0 deletions pythoscope/serializer.py
Expand Up @@ -211,6 +211,10 @@ class LibraryObject(SerializedObject):
("Element(%s)",
["tagName", "namespaceURI", "prefix"],
set([("xml.dom.minidom", "Element")])),
('datetime', 'datetime'):
("datetime.datetime(%s)",
["year", "month", "day", "hour", "minute", "second", "microsecond", "tzinfo"],
set(["datetime"])),
}

def __init__(self, obj, serialize):
Expand Down
15 changes: 13 additions & 2 deletions tools/gather-metrics.py
Expand Up @@ -75,7 +75,7 @@ def contains_dynamic_inspection_error(output):

def run_nosetests(project_dir, test_path):
notify("Running nosetests on the generated test module...")
command = "nosetests -w %s %s" % (project_dir, test_path)
command = "PYTHONPATH=%s nosetests -w %s %s" % (project_dir, project_dir, test_path)
print " $", command
status, output = commands.getstatusoutput(command)
print output
Expand All @@ -95,7 +95,7 @@ def get_test_counts(output):

def run_nosetests_with_coverage(project_dir, test_path, cover_package):
notify("Running nosetests with coverage on the generated test module...")
command = "nosetests --with-coverage --cover-package=%s -w %s %s" % (cover_package, project_dir, test_path)
command = "PYTHONPATH=%s nosetests --with-coverage --cover-package=%s -w %s %s" % (project_dir, cover_package, project_dir, test_path)
print " $", command
status, output = commands.getstatusoutput(command)
print output
Expand All @@ -109,6 +109,11 @@ def extract_coverage_percent(output):
for line in output.splitlines():
if line.startswith("TOTAL"):
return line.split()[3]
else:
# If there was only one module, coverage doesn't report TOTAL.
for line in output.splitlines():
if "%" in line:
return line.split()[3]
raise GatheringError("Can't find coverage in the output.")

def cleanup_project(project_dir):
Expand Down Expand Up @@ -165,6 +170,12 @@ def main():
appfile="isodate/*.py",
testfile="tests/*.py",
cover_package="isodate"),
dict(project="pyatom-1.2",
poes=["pyatom_poe_from_readme.py"],
snippets=[],
appfile="pyatom.py",
testfile="tests/*.py",
cover_package="pyatom"),
]
try:
results = map(lambda p: gather_metrics_from_project(**p), projects)
Expand Down
Binary file added tools/projects/pyatom-1.2.tar.gz
Binary file not shown.
18 changes: 18 additions & 0 deletions tools/projects/pyatom_poe_from_readme.py
@@ -0,0 +1,18 @@
from pyatom import AtomFeed
import datetime

feed = AtomFeed(title="My Blog",
subtitle="My example blog for a feed test.",
feed_url="http://example.org/feed",
url="http://example.org",
author="Me")

# Do this for each feed entry
feed.add(title="My Post",
content="Body of my post",
content_type="html",
author="Me",
url="http://example.org/entry1",
updated=datetime.datetime.utcnow())

print feed.to_string()

0 comments on commit 94186f5

Please sign in to comment.