<commit_before>#!/usr/bin/env ccp4-python

import parse_contactfile
      

class ConstraintfileParser(parse_contactfile.ContactfileParser):
    """Parser class for Rosetta constraints files"""
    
    def __init__(self):
        parse_contactfile.ContactfileParser.__init__(self)
        
    def read(self, constraintfile):
        """Read a constraints file to convert it to an array of
        contact dictionaries"""

        with open(constraintfile, 'r') as fh:
            for line in iter(fh.readline, ''):
                contact = self.contact.copy()       # Universal contact template

                # Read in the contact data 
                if line.startswith("AtomPair"): 
                    self._atompair(contact, line)   # AtomPair specific function
                else: 
                    msg = "Unrecognised format: {0}".format(line.strip())
                    raise ValueError(msg)
                
                # Fulfill with remaining metadata information
                contact['method'] = "ample"
                contact['file'] = constraintfile
                self.contacts.append(contact)       # Store contact
                
        if not self.contacts:<commit_msg>Ignore commented and empty lines<commit_after>#!/usr/bin/env ccp4-python

import parse_contactfile
      

class ConstraintfileParser(parse_contactfile.ContactfileParser):
    """Parser class for Rosetta constraints files"""
    
    def __init__(self):
        parse_contactfile.ContactfileParser.__init__(self)
        
    def read(self, constraintfile):
        """Read a constraints file to convert it to an array of
        contact dictionaries"""

        with open(constraintfile, 'r') as fh:
            for line in iter(fh.readline, ''):
                contact = self.contact.copy()       # Universal contact template

                # Read in the contact data 
                if not line.strip() or line.startswith("#"):
                    continue
                elif line.startswith("AtomPair"): 
                    self._atompair(contact, line)   # AtomPair specific function
                else: 
                    msg = "Unrecognised format: {0}".format(line.strip())
                    raise ValueError(msg)
                
                # Fulfill with remaining metadata information
                contact['method'] = "ample"
                contact['file'] = constraintfile
                self.contacts.append(contact)       # Store contact
                
        if not self.contacts:
{'fraction_non_alphanumeric': 0.08455156064796523, 'fraction_numerical': 0.0015804030027657052, 'mean_word_length': 1.7672131147540984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3193749', 'n_tokens_mistral': 634, 'n_tokens_neox': 598, 'n_words': 167}