
import re
import json
import mmap


class BioID:
    defs = None

    def __init__(self, defpath):
        with open(defpath, "r") as deffile:
            conts = deffile.read()
        self.defs = json.loads(conts)["formats"]

    @classmethod
    def identify(cls, files):
        recog = {}
        for file in files:
            with open(file, "r") as infile:
                buff = infile.read()
                mem_map = mmap.mmap(infile.fileno(), 0, mmap.MAP_PRIVATE, mmap.PROT_READ)

            if len(buff) == 0:
                recog[file] = "empty"  # Empty files have no format :)
                continue

            for fdef in cls.defs:
                matched = True
                if "regexen" in fdef:
                    for regex in fdef["regexen"]:
						if not re.findall(regex.replace("\\n", "\n"), buff, re.IGNORECASE):
                            matched = False
                            break
                if "bytes" in fdef:
                    for bytes in fdef["bytes"]:
                        if mem_map.find(bytes.decode("string_escape")) == -1:
                            matched = False
                            break
                if matched:
                    recog[file] = fdef["name"]
                    break

            mem_map.close()
            if file not in recog:
                recog[file] = "unrecognized"

        return recog

import re
import json
import mmap


class BioID:
	defs = None

	def __init__(self, defpath):
		with open(defpath, "r") as deffile:
			conts = deffile.read()
		self.defs = json.loads(conts)["formats"]

	@classmethod
	def identify(cls, files):
		recog = {}
		for file in files:
			with open(file, "r") as infile:
				buff = infile.read()
				mem_map = mmap.mmap(infile.fileno(), 0, mmap.MAP_PRIVATE, mmap.PROT_READ)

			if len(buff) == 0:
				recog[file] = "empty"  # Empty files have no format :)
				continue

			for fdef in cls.defs:
				matched = True
				if "regexen" in fdef:
					for regex in fdef["regexen"]:
						if not re.findall(regex.replace("\\n", "\n"), buff, re.IGNORECASE):
							matched = False
							break
			if "bytes" in fdef:
				for bytes in fdef["bytes"]:
					if mem_map.find(bytes.decode("string_escape")) == -1:
						matched = False
						break
			if matched:
				recog[file] = fdef["name"]
				break

		mem_map.close()
		if file not in recog:
			recog[file] = "unrecognized"

		return recog
Indent return in identify class.
Indent return in identify class.

  
  import re
  import json
  import mmap
  
  
  class BioID:
-     defs = None
+ 	defs = None
  
-     def __init__(self, defpath):
+ 	def __init__(self, defpath):
-         with open(defpath, "r") as deffile:
+ 		with open(defpath, "r") as deffile:
-             conts = deffile.read()
+ 			conts = deffile.read()
-         self.defs = json.loads(conts)["formats"]
+ 		self.defs = json.loads(conts)["formats"]
  
-     @classmethod
+ 	@classmethod
-     def identify(cls, files):
+ 	def identify(cls, files):
-         recog = {}
+ 		recog = {}
-         for file in files:
+ 		for file in files:
-             with open(file, "r") as infile:
+ 			with open(file, "r") as infile:
-                 buff = infile.read()
+ 				buff = infile.read()
-                 mem_map = mmap.mmap(infile.fileno(), 0, mmap.MAP_PRIVATE, mmap.PROT_READ)
+ 				mem_map = mmap.mmap(infile.fileno(), 0, mmap.MAP_PRIVATE, mmap.PROT_READ)
  
-             if len(buff) == 0:
+ 			if len(buff) == 0:
-                 recog[file] = "empty"  # Empty files have no format :)
+ 				recog[file] = "empty"  # Empty files have no format :)
-                 continue
+ 				continue
  
-             for fdef in cls.defs:
-                 matched = True
-                 if "regexen" in fdef:
-                     for regex in fdef["regexen"]:
+ 			for fdef in cls.defs:
+ 				matched = True
+ 				if "regexen" in fdef:
+ 					for regex in fdef["regexen"]:
  						if not re.findall(regex.replace("\\n", "\n"), buff, re.IGNORECASE):
-                             matched = False
-                             break
-                 if "bytes" in fdef:
-                     for bytes in fdef["bytes"]:
+ 							matched = False
+ 							break
+ 			if "bytes" in fdef:
+ 				for bytes in fdef["bytes"]:
-                         if mem_map.find(bytes.decode("string_escape")) == -1:
+ 					if mem_map.find(bytes.decode("string_escape")) == -1:
-                             matched = False
-                             break
-                 if matched:
-                     recog[file] = fdef["name"]
-                     break
+ 						matched = False
+ 						break
+ 			if matched:
+ 				recog[file] = fdef["name"]
+ 				break
  
-             mem_map.close()
+ 		mem_map.close()
-             if file not in recog:
+ 		if file not in recog:
-                 recog[file] = "unrecognized"
+ 			recog[file] = "unrecognized"
  
-         return recog
+ 		return recog
Indent return in identify class.
## Code Before:

import re
import json
import mmap


class BioID:
    defs = None

    def __init__(self, defpath):
        with open(defpath, "r") as deffile:
            conts = deffile.read()
        self.defs = json.loads(conts)["formats"]

    @classmethod
    def identify(cls, files):
        recog = {}
        for file in files:
            with open(file, "r") as infile:
                buff = infile.read()
                mem_map = mmap.mmap(infile.fileno(), 0, mmap.MAP_PRIVATE, mmap.PROT_READ)

            if len(buff) == 0:
                recog[file] = "empty"  # Empty files have no format :)
                continue

            for fdef in cls.defs:
                matched = True
                if "regexen" in fdef:
                    for regex in fdef["regexen"]:
						if not re.findall(regex.replace("\\n", "\n"), buff, re.IGNORECASE):
                            matched = False
                            break
                if "bytes" in fdef:
                    for bytes in fdef["bytes"]:
                        if mem_map.find(bytes.decode("string_escape")) == -1:
                            matched = False
                            break
                if matched:
                    recog[file] = fdef["name"]
                    break

            mem_map.close()
            if file not in recog:
                recog[file] = "unrecognized"

        return recog
## Instruction:
Indent return in identify class.
## Code After:

import re
import json
import mmap


class BioID:
	defs = None

	def __init__(self, defpath):
		with open(defpath, "r") as deffile:
			conts = deffile.read()
		self.defs = json.loads(conts)["formats"]

	@classmethod
	def identify(cls, files):
		recog = {}
		for file in files:
			with open(file, "r") as infile:
				buff = infile.read()
				mem_map = mmap.mmap(infile.fileno(), 0, mmap.MAP_PRIVATE, mmap.PROT_READ)

			if len(buff) == 0:
				recog[file] = "empty"  # Empty files have no format :)
				continue

			for fdef in cls.defs:
				matched = True
				if "regexen" in fdef:
					for regex in fdef["regexen"]:
						if not re.findall(regex.replace("\\n", "\n"), buff, re.IGNORECASE):
							matched = False
							break
			if "bytes" in fdef:
				for bytes in fdef["bytes"]:
					if mem_map.find(bytes.decode("string_escape")) == -1:
						matched = False
						break
			if matched:
				recog[file] = fdef["name"]
				break

		mem_map.close()
		if file not in recog:
			recog[file] = "unrecognized"

		return recog