Skip to content

Commit

Permalink
restructure to allow easy adding of generators
Browse files Browse the repository at this point in the history
  • Loading branch information
gijzelaerr authored and vanrein committed Nov 17, 2017
1 parent 390098e commit 270bcbc
Show file tree
Hide file tree
Showing 15 changed files with 1,909 additions and 1,628 deletions.
36 changes: 36 additions & 0 deletions python/quick_der/generators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import os.path


class QuickDERgeneric(object):
def __init__(self, outfn, outext):
self.unit, curext = os.path.splitext(outfn)
if curext == '.h':
raise Exception('File cannot overwrite itself -- use another extension than ' + outext + ' for input files')
self.outfile = open(self.unit + outext, 'w')

self.comma1 = None
self.comma0 = None

def write(self, txt):
self.outfile.write(txt)

def writeln(self, txt=''):
self.outfile.write(txt + '\n')

def newcomma(self, comma, firstcomma=''):
self.comma0 = firstcomma
self.comma1 = comma

def comma(self):
self.write(self.comma0)
self.comma0 = self.comma1

def getcomma(self):
return self.comma1, self.comma0

def setcomma(self, comma1, comma0):
self.comma1 = comma1
self.comma0 = comma0

def close(self):
self.outfile.close()
18 changes: 18 additions & 0 deletions python/quick_der/generators/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Stubs for quick_der.generators (Python 3.6)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.

from typing import Any

class QuickDERgeneric:
outfile: Any = ...
comma1: Any = ...
comma0: Any = ...
def __init__(self, outfn, outext) -> None: ...
def write(self, txt): ...
def writeln(self, txt: str = ...): ...
def newcomma(self, comma, firstcomma: str = ...): ...
def comma(self): ...
def getcomma(self): ...
def setcomma(self, comma1, comma0): ...
def close(self): ...
Loading

0 comments on commit 270bcbc

Please sign in to comment.