Commits

Antonio Alvarado Hernández committed cff88de

last version before porting to python3

* updated copyright's year to include 2013
* fixed minor issues, but for now nothing has been tested
* collected missing scripts into `extras` directory

  • Participants
  • Parent commits dc4a6ff

Comments (0)

Files changed (8)

 
 *.elc
 *.pyc
+*.swp
 *~
 
 .spyderproject
 
-# EOF
+# EOF

File extras/cm_mergecsv.py

File contents unchanged.

File extras/cm_parsejson.py

+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from __future__ import print_function
+
+from datetime import datetime
+
+import sys
+import json
+import pprint
+
+
+class CmReportData(object):
+    """TODO"""
+
+    def __init__(self, raw):
+        """Constructs an object with given raw data."""
+        self._data = raw
+        self._from_dict(raw)
+
+    def __str__(self):
+        """Returns a human readable representation."""
+        print(self._client_id, self._generated)
+        return pprint.pformat(self._data)
+
+    def _from_dict(self, raw):
+        self._from_header(raw[u'Header'])
+
+    def _from_header(self, header):
+        """Parse given header dictionary."""
+        self._client_id = header.get(u'ClientId', None)
+        value = header.get(u'GeneratedAt', None)
+        if value:
+            self._generated = \
+                datetime.strptime(value, r'%Y-%m-%dT%H:%M:%S')
+        ## TODO: Periods are missing!
+
+
+class CmJsonParser(object):
+    """TODO"""
+
+    def __init__(self):
+        """Constructs the given object."""
+        pass
+
+# ------------------------------------------------------------------------------
+    def parse(self, stream):
+        """Parses givem input stream and returns a `CmReportData` object."""
+        with stream as input:
+            raw = json.load(input)
+            return CmReportData(raw)
+
+def main():
+    """This is the program entry-point."""
+    parser = CmJsonParser()
+    data = parser.parse(sys.stdin)
+    print(data)
+
+
+if __name__ == '__main__':
+    main()
+
+# EOF

File wa/__init__.py

 # -*- coding: utf-8 -*-
 #
-# Copyright 2012 Antonio Alvarado Hernández
+# Copyright 2012,2013 Antonio Alvarado Hernández
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may
 # not use this file except in compliance with the License. You may obtain
 TODO
 """
 
-# EOF
+# EOF

File wa/engines/__init__.py

 # -*- coding: utf-8 -*-
 #
-# Copyright 2012 Antonio Alvarado Hernández
+# Copyright 2012,2013 Antonio Alvarado Hernández
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may
 # not use this file except in compliance with the License. You may obtain
 TODO
 """
 
-# EOF
+# EOF

File wa/engines/coremetrics.py

 # -*- coding: utf-8 -*-
 #
-# Copyright 2012 Antonio Alvarado Hernández
+# Copyright 2012,2013 Antonio Alvarado Hernández
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may
 # not use this file except in compliance with the License. You may obtain
     except Exception as e:
         print("Oops: %s" % str(e))
 
-# EOF
+# EOF
 # -*- coding: utf-8 -*-
 #
-# Copyright 2012 Antonio Alvarado Hernández
+# Copyright 2012,2013 Antonio Alvarado Hernández
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may
 # not use this file except in compliance with the License. You may obtain
 __all__ = ['main']
 
 
-from argparse import ArgumentParser, FileType
+from argparse import ArgumentParser, ArgumentError, FileType
 
 import sys
 import json
         args = None
         try:
             args = self._parser.parse_args()
-        except ArgurmentError as e:
+        except ArgumentError as e:
             print("Oops: bad command line arguments", str(e))
             sys.exit(E_BADARGS)
 
     sh = BasicShell()
     sh.run()
 
-# EOF
+# EOF
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright 2012 Antonio Alvarado Hernández
+# Copyright 2012,2013 Antonio Alvarado Hernández
 #
 # Licensed under the Apache License, Version 2.0 (the "License"); you may
 # not use this file except in compliance with the License. You may obtain
 
 shell.main()
 
-# EOF
+# EOF