ravens/tasks/task.py
def fill_template(self, template, replace):
        """Read template file and replace string keys.

        The replace[field] needs to be a tuple. Use (item,) for a single
        item, but you can combine keys with NAMEX where X starts from 0.
        """
        filepath = os.path.dirname(os.path.abspath(__file__))
        template = os.path.join(filepath, '..', template)
        with open(template, 'r') as file:
            fdata = file.read()
        for field in replace:
            for i in range(len(replace[field])):
                fdata = fdata.replace(f'{field}{i}', str(replace[field][i]))
        alphabet = string.ascii_lowercase + string.digits
        rname = ''.join(random.choices(alphabet, k=16))
        fname = f'{template}.{rname}'
        with open(fname, 'w') as file:
            file.write(fdata)
        return fname
Read template file and replace string keys.

        The replace[field] needs to be a tuple. Use (item,) for a single
        item, but you can combine keys with NAMEX where X starts from 0.
        
Read template file and replace string keys.
The replace[field] needs to be a tuple. Use (item,) for a single
item, but you can combine keys with NAMEX where X starts from 0.
Read template file and replace string keys . The replace [ field ] needs to be a tuple . Use ( item ) for a single item but you can combine keys with NAMEX where X starts from 0 .
def fill_template(self, template, replace):
        filepath = os.path.dirname(os.path.abspath(__file__))
        template = os.path.join(filepath, '..', template)
        with open(template, 'r') as file:
            fdata = file.read()
        for field in replace:
            for i in range(len(replace[field])):
                fdata = fdata.replace(f'{field}{i}', str(replace[field][i]))
        alphabet = string.ascii_lowercase + string.digits
        rname = ''.join(random.choices(alphabet, k=16))
        fname = f'{template}.{rname}'
        with open(fname, 'w') as file:
            file.write(fdata)
        return fname
def fill_template ( self , template , replace ) : filepath = os . path . dirname ( os . path . abspath ( __file__ ) ) template = os . path . join ( filepath , '..' , template ) with open ( template , 'r' ) as file : fdata = file . read ( ) for field in replace : for i in range ( len ( replace [ field ] ) ) : fdata = fdata . replace ( f'{field}{i}' , str ( replace [ field ] [ i ] ) ) alphabet = string . ascii_lowercase + string . digits rname = '' . join ( random . choices ( alphabet , k = 16 ) ) fname = f'{template}.{rname}' with open ( fname , 'w' ) as file : file . write ( fdata ) return fname
Read template file and replace string keys.
Read template file and replace string keys .
"""Read template file and replace string keys.

        The replace[field] needs to be a tuple. Use (item,) for a single
        item, but you can combine keys with NAMEX where X starts from 0.
        """
self
template
replace