<commit_before>#-*- coding: utf-8 -*-
import os, sys
import yaml,json
import logging, logging.handlers
from optparse import OptionParser, OptionGroup

class Networks():
	def __init__(self, name=None): 
		self.networks = {}
		if name :
			self.name = name
		else:
			self.name = 'default'
		self.networks[self.name] = {}
	def driver(self, name="bridge"):
		self.networks[self.name]['driver'] = name
		return(self)
	def ipam(self):
		return(self.Ipam(self.networks[self.name]))
	class Ipam():
		def __init__(self,obj):
			self.networks = obj
			# print(self.networks)
			self.networks['ipam'] = {}
		def driver(self, name="default"):
			self.networks['ipam']['driver'] = name
			return(self)
		def config(self, array):
			self.networks['ipam']['config'] = array
			return(self)

class Volumes():
	def __init__(self, name="None"): 
		self.volumes = {}
		if name :
			self.volumes[name] = None
	def add(self, name):
		self.volumes[name] = None
		return(self)
		
class Services():	
	# service = {}
	def __init__(self, name): 
		self.service = {}
		self.name = name
		self.service[self.name]={}
		self.service[self.name]['depends_on']=[]
	def image(self, name):
		self.service[self.name]['image']= name
		return(self)
	def container_name(self,name=None):
		if not name :
			name = self.name
		self.service[self.name]['container_name'] =name
		return(self)
	def restart(self,value='always'):
		self.service[self.name]['restart'] =value
		return(self)	
	def hostname(self,value='localhost.localdomain'):
		self.service[self.name]['hostname'] =value
		return(self)
	def extra_hosts(self,array=[]):
		self.service[self.name]['extra_hosts'] = array
		return(self)
	def environment(self, array=[]):
		self.service[self.name]['environment'] = array
		return(self)
	def env_file(self, array=[]):
		self.service[self.name]['env_file'] = array
		return(self)
	def ports(self, array):
		self.service[self.name]['ports'] = array
		return(self)
	def working_dir(self, dir='/'):
		self.service[self.name]['working_dir'] = dir
		return(self)
	def volumes(self, array):
		self.service[self.name]['volumes'] = array
		return(self)
	def networks(self, array):
		self.service[self.name]['networks'] = array
		return(self)
	def sysctls(self,array):
		self.service[self.name]['sysctls'] = array
		return(self)<commit_msg>端口支持字符串<commit_after>#-*- coding: utf-8 -*-
import os, sys
import yaml,json
import logging, logging.handlers
from optparse import OptionParser, OptionGroup

class Networks():
	def __init__(self, name=None): 
		self.networks = {}
		if name :
			self.name = name
		else:
			self.name = 'default'
		self.networks[self.name] = {}
	def driver(self, name="bridge"):
		self.networks[self.name]['driver'] = name
		return(self)
	def ipam(self):
		return(self.Ipam(self.networks[self.name]))
	class Ipam():
		def __init__(self,obj):
			self.networks = obj
			# print(self.networks)
			self.networks['ipam'] = {}
		def driver(self, name="default"):
			self.networks['ipam']['driver'] = name
			return(self)
		def config(self, array):
			self.networks['ipam']['config'] = array
			return(self)

class Volumes():
	def __init__(self, name="None"): 
		self.volumes = {}
		if name :
			self.volumes[name] = None
	def add(self, name):
		self.volumes[name] = None
		return(self)
		
class Services():	
	# service = {}
	def __init__(self, name): 
		self.service = {}
		self.name = name
		self.service[self.name]={}
		self.service[self.name]['ports']=[]
		self.service[self.name]['depends_on']=[]
	def image(self, name):
		self.service[self.name]['image']= name
		return(self)
	def container_name(self,name=None):
		if not name :
			name = self.name
		self.service[self.name]['container_name'] =name
		return(self)
	def restart(self,value='always'):
		self.service[self.name]['restart'] =value
		return(self)	
	def hostname(self,value='localhost.localdomain'):
		self.service[self.name]['hostname'] =value
		return(self)
	def extra_hosts(self,array=[]):
		self.service[self.name]['extra_hosts'] = array
		return(self)
	def environment(self, array=[]):
		self.service[self.name]['environment'] = array
		return(self)
	def env_file(self, array=[]):
		self.service[self.name]['env_file'] = array
		return(self)
	def ports(self, obj):
		if type(obj) == str:
			self.service[self.name]['ports'].append(obj)
		else:
			self.service[self.name]['ports'] = obj
		return(self)
	def working_dir(self, dir='/'):
		self.service[self.name]['working_dir'] = dir
		return(self)
	def volumes(self, array):
		self.service[self.name]['volumes'] = array
		return(self)
	def networks(self, array):
		self.service[self.name]['networks'] = array
		return(self)
	def sysctls(self,array):
		self.service[self.name]['sysctls'] = array
		return(self)
{'fraction_non_alphanumeric': 0.17546848381601363, 'fraction_numerical': 0.00042589437819420784, 'mean_word_length': 4.721071863580999, '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': '4359315', 'n_tokens_mistral': 1823, 'n_tokens_neox': 1678, 'n_words': 321}