Exports a preflib format file that contains all the information of the current Profile.

        :ivar str fileName: The name of the output file to be exported.
357803
def exportPreflibFile(self, fileName):
        

        elecType = self.getElecType()

        if elecType != "soc" and elecType != "toc" and elecType != "soi" and elecType != "toi":
            print("ERROR: printing current type to preflib format is not supported")
            exit()

        # Generate a list of reverse rankMaps, one for each vote. This will allow us to easiliy
        # identify ties.
        reverseRankMaps = self.getReverseRankMaps()

        outfileObj = open(fileName, 'w')

        # Print the number of candidates and the integer representation and name of each candidate.
        outfileObj.write(str(self.numCands))
        for candInt, cand in self.candMap.items():
            outfileObj.write("\n" + str(candInt) + "," + cand)

        # Sum up the number of preferences that are represented.
        preferenceCount = 0
        for preference in self.preferences:
            preferenceCount += preference.count

        # Print the number of voters, the sum of vote count, and the number of unique orders.
        outfileObj.write("\n" + str(self.numVoters) + "," + str(preferenceCount) + "," + str(len(self.preferences)))

        for i in range(0, len(reverseRankMaps)):

            # First, print the number of times the preference appears.
            outfileObj.write("\n" + str(self.preferences[i].count))
            
            reverseRankMap = reverseRankMaps[i]

            # We sort the positions in increasing order and print the candidates at each position
            # in order.
            sortedKeys = sorted(reverseRankMap.keys())
            for key in sortedKeys:

                cands = reverseRankMap[key]

                # If only one candidate is in a particular position, we assume there is no tie.
                if len(cands) == 1:
                    outfileObj.write("," + str(cands[0]))

                # If more than one candidate is in a particular position, they are tied. We print
                # brackets around the candidates.
                elif len(cands) > 1:
                    outfileObj.write(",{" + str(cands[0]))
                    for j in range(1, len(cands)):
                        outfileObj.write("," + str(cands[j]))
                    outfileObj.write("}")
                    
        outfileObj.close()
136753
def profileFromPNG(inp):
    
    r = png.Reader(file=inp)
    _, chunk = r.chunk('iCCP')
    i = chunk.index(b'\x00')
    name = chunk[: i]
    compression = chunk[i + 1]
    assert compression == 0
    profile = zlib.decompress(chunk[i + 2:])
    return profile, name
1082115
def _clean_file_name(self, model_instance, filename):
        
        available_name = self.storage.get_available_name(
            self.generate_filename(model_instance, filename))
        return os.path.basename(available_name)
518520
def getFilenameSet(self):
        
        result = set(self._mergeFileTiming())
        # Ignore profiling code. __file__ does not always provide consistent
        # results with f_code.co_filename (ex: easy_install with zipped egg),
        # so inspect current frame instead.
        # Get current file from one of pprofile methods. Compatible with
        # implementations that do not have the inspect.currentframe() method
        # (e.g. IronPython).
        # XXX: Assumes that all of pprofile code is in a single file.
        # XXX: Assumes that _initStack exists in pprofile module.
        result.discard(inspect.getsourcefile(_initStack))
        return result
1116244
def processFilenames(input=None,output=None,infilesOnly=False):
    
    ivmlist = None
    oldasndict = None

    if input is None:
        print("No input files provided to processInput")
        raise ValueError

    if not isinstance(input, list) and ('_asn' in input or '_asc' in input):
        # Input is an association table
        # Get the input files, and run makewcs on them
        oldasndict = asnutil.readASNTable(input, prodonly=infilesOnly)

        if not infilesOnly:
            if output in ["",None,"None"]:
                output = oldasndict['output'].lower() # insure output name is lower case

        asnhdr = fits.getheader(input, memmap=False)
        # Only perform duplication check if not already completed...
        dupcheck = asnhdr.get('DUPCHECK',default="PERFORM") == "PERFORM"

        #filelist = [fileutil.buildRootname(fname) for fname in oldasndict['order']]
        filelist = buildASNList(oldasndict['order'],input,check_for_duplicates=dupcheck)

    elif (not isinstance(input, list)) and \
       (input[0] == '@') :
        # input is an @ file
        f = open(input[1:])
        # Read the first line in order to determine whether
        # IVM files have been specified in a second column...
        line = f.readline()
        f.close()
        # Parse the @-file with irafglob to extract the input filename
        filelist = irafglob.irafglob(input, atfile=util.atfile_sci)
        # If there is a second column...
        if len(line.split()) == 2:
            # ...parse out the names of the IVM files as well
            ivmlist = irafglob.irafglob(input, atfile=util.atfile_ivm)
        if output in ['',None,"None"]:
            if len(filelist) == 1:
                output = fileutil.buildNewRootname(filelist[0])
            else:
                output = 'final'
    else:
        #input is a string or a python list
        try:
            filelist, output = parseinput.parseinput(input, outputname=output)
            if output in ['',None,"None"]:
                if len(filelist) == 1:
                    output = fileutil.buildNewRootname(filelist[0])
                else:
                    output = 'final'
            if not isinstance(input, list):
                filelist.sort()
        except IOError: raise

    # sort the list of input files
    # this ensures the list of input files has the same order on all platforms
    # it can have ifferent order because listdir() uses inode order, not unix type order
    #filelist.sort()



    return filelist, output, ivmlist, oldasndict
573370
def output(self, original_filename):
        

        for contract in self.contracts:
            for function in contract.functions + contract.modifiers:
                filename = "{}-{}-{}.dot".format(original_filename, contract.name, function.full_name)
                self.info('Export {}'.format(filename))
                function.slithir_cfg_to_dot(filename)
1030313
def export_ipynb(self, pathname):
        

        if pathname == '-':
            nbf.write(self.nb, sys.__stdout__)
        else:
            with codecs.open(pathname, 'w', encoding='utf-8') as f:
                ret = nbf.write(self.nb, f)
                pass

        logging.info("Jupyter notebook exported to '{}'".format(pathname))
1241271
def export(g, csv_fname):
    
    with open(csv_fname, "w") as f:
        num_tuples = 0
        f.write('"num","subject","predicate","object"\n')
        for subj, pred, obj in g:
            num_tuples += 1
            f.write('"' + str(num_tuples) + '",')
            f.write('"' + get_string_from_rdf(subj) + '",')
            f.write('"' + get_string_from_rdf(pred) + '",')
            f.write('"' + get_string_from_rdf(obj) + '"\n')
    print("Finished exporting " , num_tuples, " tuples")
1068828
def format_file_params(files):
        '''
            
        '''
        files_payload = {}
        if files:
            for idx, filename in enumerate(files):
                files_payload["file[" + str(idx) + "]"] = open(filename, 'rb')
        return files_payload
351188
def exportJsonFile(self, fileName):
        

        # Because our Profile class is not directly JSON serializable, we exporrt the underlying 
        # dictionary. 
        data = dict()
        for key in self.__dict__.keys():
            if key != "preferences":
                data[key] = self.__dict__[key]
        
        # The Preference class is also not directly JSON serializable, so we export the underlying
        # dictionary for each Preference object.
        preferenceDicts = []
        for preference in self.preferences:
            preferenceDict = dict()
            for key in preference.__dict__.keys():
                preferenceDict[key] = preference.__dict__[key]
            preferenceDicts.append(preferenceDict)
        data["preferences"] = preferenceDicts

        outfile = open(fileName, 'w')
        json.dump(data, outfile)
        outfile.close()
1145038
def export_debug(self, output_path):
        

        file_hash = hashlib.md5(open(output_path, 'rb').read()).hexdigest()
        avm_name = os.path.splitext(os.path.basename(output_path))[0]

        json_data = self.generate_debug_json(avm_name, file_hash)

        mapfilename = output_path.replace('.avm', '.debug.json')
        with open(mapfilename, 'w+') as out_file:
            out_file.write(json_data)
1294127
def get_output_file(self, in_file, instance, field, **kwargs):
        """"""
        return NamedTemporaryFile(mode='rb', suffix='_%s_%s%s' % (
            get_model_name(instance), field.name, self.get_ext()), delete=False)
193173
def export(self, filename, fmt="DER"):
        
        f = open(filename, "wb")
        if fmt == "DER":
            f.write(self.der)
        elif fmt == "PEM":
            f.write(self.pem)
        f.close()
1136777
def to_file(self, outputfile=DEFAULT_OUTPUTFILE):
        
    
        if outputfile != NO_OUTPUTFILE:
            if outputfile == DEFAULT_OUTPUTFILE:
                outputfile = 'profile_' + str(hash(self)) + ".html"
            # TODO: should be done in the template
            with codecs.open(outputfile, 'w+b', encoding='utf8') as self.file:
                self.file.write(templates.template('wrapper').render(content=self.html))
758026
def __get_output_filenames(self):
        
        # if there is only one file, use the normal filename with nothing appended.
        if len(self.noaa_data_sorted["Data"]) == 1:
            self.output_filenames.append(self.filename_txt)

        # if there are multiple files that need to be written out, (multiple data table pairs), then append numbers
        elif len(self.noaa_data_sorted["Data"]) > 1:
            for i in range(0, self.output_file_ct):
                tmp_name = "{}-{}.txt".format(self.dsn, i+1)
                self.output_filenames.append(tmp_name)
        return
300325
def initializeProfile(self):
        

        LOGGER.debug("> Building '{0}' profile.".format(self.__file))

        sections_file_parser = SectionsFileParser(self.__file)
        sections_file_parser.parse()

        if sections_file_parser.sections:
            fileStructureParsingError = lambda attribute: foundations.exceptions.FileStructureParsingError(
                "{0} | No '{1}' attribute found, '{2}' file structure seems invalid!".format(
                    self.__class__.__name__, attribute, self.__file))

            self.__directory = os.path.dirname(self.__file)
            self.__name = sections_file_parser.get_value("Name", "Component", default=None)
            if self.__name is None:
                raise fileStructureParsingError("Name")

            self.__title = sections_file_parser.get_value("Title", "Component", default=None)
            if self.__title is None:
                self.__title = self.__name

            self.__package = sections_file_parser.get_value("Module", "Component", default=None)
            if self.__package is None:
                raise fileStructureParsingError("Module")

            self.__attribute = sections_file_parser.get_value("Object", "Component", default=None)
            if self.__attribute is None:
                raise fileStructureParsingError("Object")

            self.__require = sections_file_parser.get_value("Require", "Component", default=None)
            self.__require = list() if self.__require is None else self.__require.split("|")

            self.__version = sections_file_parser.get_value("Version", "Component", default=None)
            if self.__version is None:
                raise fileStructureParsingError("Version")

            self.__author = sections_file_parser.get_value("Author", "Informations", default=None)

            self.__email = sections_file_parser.get_value("Email", "Informations", default=None)

            self.__url = sections_file_parser.get_value("Url", "Informations", default=None)

            self.__description = sections_file_parser.get_value("Description", "Informations", default=None)

            return True
        else:
            raise foundations.exceptions.FileStructureParsingError(
                "{0} | No sections found, '{1}' file structure seems invalid!".format(self.__class__.__name__,
                                                                                      self.__file))
288930
def _set_format(profile):
    
    x = set()
    for sample in profile:
        x = x.union(set(profile[sample].keys()))
    if not x:
        return ''
    end, start = max(x), min(x)
    x = range(start, end, 4)
    scaled_profile = defaultdict(list)
    for pos in x:
        for sample in profile:
            y = _get_closer(profile[sample], pos)
            if y:
                scaled_profile[sample].append(profile[sample][y])
            else:
                scaled_profile[sample].append(0)
    return {'x': list(x), 'y': scaled_profile, 'names': scaled_profile.keys()}