コード例 #1
0
 def testStrings(self):
     orig = hamlet.split()
     result = ['To', 'or', 'to', 'is']
     self.assertEqual(main.filter(lambda x: len(x) < 3, orig), result)
コード例 #2
0
 def testEmpty(self):
     orig = []
     result = []
     self.assertEqual(main.filter(lambda x: x > 3, orig), result)
コード例 #3
0
 def testNumbers(self):
     orig = [1, 2, 3, 4, 5, 7, 0, 9]
     result = [3, 0, 9]
     self.assertEqual(main.filter(lambda x: x % 3 == 0, orig), result)
コード例 #4
0
ファイル: sampletests.py プロジェクト: BobbyJohansen/Snippets
 def testNumbers(self):
     orig = [1,2,3,4,5,7,0,9]
     result = [3,0,9]
     self.assertEqual(main.filter(lambda x: x%3==0, orig), result)
コード例 #5
0
ファイル: sampletests.py プロジェクト: BobbyJohansen/Snippets
 def testStrings(self):
     orig = hamlet.split()
     result = ['To', 'or', 'to', 'is']
     self.assertEqual(main.filter(lambda x: len(x)<3, orig), result)
コード例 #6
0
 def testDict(self):
     orig = {'foo': 'foo', 'bar': 'bar', 'foobar': 'foobar'}
     result = ['foo', 'bar']
     self.assertEqual(main.filter(lambda x: len(x) == 3, orig.keys()),
                      result)
コード例 #7
0
ファイル: sampletests.py プロジェクト: BobbyJohansen/Snippets
 def testEmpty(self):
     orig = []
     result = []
     self.assertEqual(main.filter(lambda x: x>3, orig), result)
コード例 #8
0
 def testFloats(self):
     orig = [1.0, 2.0, 3.0, 4.0, 5.0, 7.0, 0.0, 9.0]
     result = [3.0, 0.0, 9.0]
     self.assertEqual(main.filter(lambda x: x % 3.0 == 0.0, orig), result)
コード例 #9
0
 def testLists(self):
     orig = [[1], [2, 3], [4, 5], [7, 0, 9]]
     result = [[2, 3], [4, 5]]
     self.assertEqual(main.filter(lambda x: len(x) == 2, orig), result)
コード例 #10
0
The second condition can check arguments and retrieve others arguments who will them send in the file main.py
The third condition can check arguments, manage configuration file "image.ini" and retrieve arguments file
    who will them send in the file main.py
"""

args = sys.argv
menu_help = "usage: imagefilter \n -h,--help \n -i,--img-dir <directory> \n -o,--output-dir <directory> \n -f, " \
            "--filters \n --config-file, <file> \n --list-filters"

if args[1] == "-h":
    print(menu_help)
elif args[1] == "-i" and args[3] == "-o" and args[5] == "-f":
    input_arg = args[2]
    output_arg = args[4]
    filter_arg = args[6]
    main.filter(input_arg, output_arg, filter_arg)
elif args[1] == "--config-file":
    ini_file = args[2]
    if not os.path.isfile(ini_file):
        print(f"The file does not exist : {ini_file}")
    elif not ini_file.endswith(".ini"):
        print(f"The file is not in good format : {ini_file.split('.')[1]} !")
    else:
        config = configparser.ConfigParser()
        config.read(ini_file)
        with open(ini_file, 'w') as configfile:
            config.write(configfile)
            content = config['filters']['content']
            input = config['general']["input_dir"]
            output = config['general']["output_dir"]
            main.filter(input, output, content)
コード例 #11
0
ファイル: read_stat.py プロジェクト: nvol/tiqtaq
import json
import main as tt

with open('tiqtaq.json') as f:
    j = json.load(f)
gs = [[int(i) for i in g] for g in j]

# # look for symmetrical combinations
# for g in gs:
#     symm = tt.transform(g, 'd')
#     if symm in gs:
#         print('ALARM!', g, symm)

print('dict len:', len(j))
print('   X won:', tt.filter(j, 1))
print('   O won:', tt.filter(j, -1))
print('    draw:', tt.filter(j, 0))

コード例 #12
0
ファイル: mytester.py プロジェクト: z0mi3ie/Python_Various
 def testDict(self):
   orig = {'foo': 'foo', 'bar': 'bar', 'foobar': 'foobar'}
   result = ['foo', 'bar']
   self.assertEqual(main.filter(lambda x: len(x) == 3, orig.keys()), result)
コード例 #13
0
ファイル: mytester.py プロジェクト: z0mi3ie/Python_Various
 def testLists(self):
   orig = [[1],[2,3],[4,5],[7,0,9]]
   result = [[2,3],[4,5]]
   self.assertEqual(main.filter(lambda x: len(x) == 2, orig), result)
コード例 #14
0
ファイル: mytester.py プロジェクト: z0mi3ie/Python_Various
 def testFloats(self):
   orig = [1.0,2.0,3.0,4.0,5.0,7.0,0.0,9.0]
   result = [3.0,0.0,9.0]
   self.assertEqual(main.filter(lambda x: x%3.0==0.0, orig), result)