prompt
large_stringlengths 72
9.34k
| completion
large_stringlengths 0
7.61k
|
---|---|
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
<|fim_middle|>
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc) |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
<|fim_middle|>
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.att = attachment.Attachment(att_j['value'][0]) |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
<|fim_middle|>
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.assertTrue(self.att.isType('txt')) |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
<|fim_middle|>
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.assertEqual(self.att.getType(),'.txt') |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
<|fim_middle|>
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f) |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
<|fim_middle|>
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | for i in range(4):
val = str(randint(0,9)) + val
return val |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
<|fim_middle|>
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.assertEqual(self.att.getByteString(),b'testing w00t!') |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
<|fim_middle|>
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n') |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
<|fim_middle|>
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc) |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
<|fim_middle|>
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc) |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | unittest.main() |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def <|fim_middle|>(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | setUp |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def <|fim_middle|>(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_isType |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def <|fim_middle|>(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_getType |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def <|fim_middle|>(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_save |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def <|fim_middle|>(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | newFileName |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def <|fim_middle|>(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_getByteString |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def <|fim_middle|>(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_getBase64 |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def <|fim_middle|>(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def setBase64(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_setByteString |
<|file_name|>test_attachment.py<|end_file_name|><|fim▁begin|>from O365 import attachment
import unittest
import json
import base64
from random import randint
att_rep = open('attachment.json','r').read()
att_j = json.loads(att_rep)
class TestAttachment (unittest.TestCase):
def setUp(self):
self.att = attachment.Attachment(att_j['value'][0])
def test_isType(self):
self.assertTrue(self.att.isType('txt'))
def test_getType(self):
self.assertEqual(self.att.getType(),'.txt')
def test_save(self):
name = self.att.json['Name']
name1 = self.newFileName(name)
self.att.json['Name'] = name1
self.assertTrue(self.att.save('/tmp'))
with open('/tmp/'+name1,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
name2 = self.newFileName(name)
self.att.json['Name'] = name2
self.assertTrue(self.att.save('/tmp/'))
with open('/tmp/'+name2,'r') as ins:
f = ins.read()
self.assertEqual('testing w00t!',f)
def newFileName(self,val):
for i in range(4):
val = str(randint(0,9)) + val
return val
def test_getByteString(self):
self.assertEqual(self.att.getByteString(),b'testing w00t!')
def test_getBase64(self):
self.assertEqual(self.att.getBase64(),'dGVzdGluZyB3MDB0IQ==\n')
def test_setByteString(self):
test_string = b'testing testie test'
self.att.setByteString(test_string)
enc = base64.encodebytes(test_string)
self.assertEqual(self.att.json['ContentBytes'],enc)
def <|fim_middle|>(self):
wrong_test_string = 'I am sooooo not base64 encoded.'
right_test_string = 'Base64 <3 all around!'
enc = base64.encodestring(right_test_string)
self.assertRaises(self.att.setBase64(wrong_test_string))
self.assertEqual(self.att.json['ContentBytes'],'dGVzdGluZyB3MDB0IQ==\n')
self.att.setBase64(enc)
self.assertEqual(self.att.json['ContentBytes'],enc)
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | setBase64 |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved.
from __future__ import absolute_import
from wtforms import validators
from ..forms import ModelForm
from digits import utils
class ImageModelForm(ModelForm):
"""
Defines the form used to create a new ImageModelJob
"""<|fim▁hole|> validators=[
validators.NumberRange(min=1),
validators.Optional()
],
tooltip=("If specified, during training a random square crop will be "
"taken from the input image before using as input for the network.")
)
use_mean = utils.forms.SelectField(
'Subtract Mean',
choices=[
('none', 'None'),
('image', 'Image'),
('pixel', 'Pixel'),
],
default='image',
tooltip="Subtract the mean file or mean pixel for this dataset from each image."
)
aug_flip = utils.forms.SelectField(
'Flipping',
choices=[
('none', 'None'),
('fliplr', 'Horizontal'),
('flipud', 'Vertical'),
('fliplrud', 'Horizontal and/or Vertical'),
],
default='none',
tooltip="Randomly flips each image during batch preprocessing."
)
aug_quad_rot = utils.forms.SelectField(
'Quadrilateral Rotation',
choices=[
('none', 'None'),
('rot90', '0, 90 or 270 degrees'),
('rot180', '0 or 180 degrees'),
('rotall', '0, 90, 180 or 270 degrees.'),
],
default='none',
tooltip="Randomly rotates (90 degree steps) each image during batch preprocessing."
)
aug_rot = utils.forms.IntegerField(
'Rotation (+- deg)',
default=0,
validators=[
validators.NumberRange(min=0, max=180)
],
tooltip="The uniform-random rotation angle that will be performed during batch preprocessing."
)
aug_scale = utils.forms.FloatField(
'Rescale (stddev)',
default=0,
validators=[
validators.NumberRange(min=0, max=1)
],
tooltip=("Retaining image size, the image is rescaled with a "
"+-stddev of this parameter. Suggested value is 0.07.")
)
aug_noise = utils.forms.FloatField(
'Noise (stddev)',
default=0,
validators=[
validators.NumberRange(min=0, max=1)
],
tooltip=("Adds AWGN (Additive White Gaussian Noise) during batch "
"preprocessing, assuming [0 1] pixel-value range. Suggested value is 0.03.")
)
aug_hsv_use = utils.forms.BooleanField(
'HSV Shifting',
default=False,
tooltip=("Augmentation by normal-distributed random shifts in HSV "
"color space, assuming [0 1] pixel-value range."),
)
aug_hsv_h = utils.forms.FloatField(
'Hue',
default=0.02,
validators=[
validators.NumberRange(min=0, max=0.5)
],
tooltip=("Standard deviation of a shift that will be performed during "
"preprocessing, assuming [0 1] pixel-value range.")
)
aug_hsv_s = utils.forms.FloatField(
'Saturation',
default=0.04,
validators=[
validators.NumberRange(min=0, max=0.5)
],
tooltip=("Standard deviation of a shift that will be performed during "
"preprocessing, assuming [0 1] pixel-value range.")
)
aug_hsv_v = utils.forms.FloatField(
'Value',
default=0.06,
validators=[
validators.NumberRange(min=0, max=0.5)
],
tooltip=("Standard deviation of a shift that will be performed during "
"preprocessing, assuming [0 1] pixel-value range.")
)<|fim▁end|> |
crop_size = utils.forms.IntegerField(
'Crop Size', |
<|file_name|>forms.py<|end_file_name|><|fim▁begin|># Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved.
from __future__ import absolute_import
from wtforms import validators
from ..forms import ModelForm
from digits import utils
class ImageModelForm(ModelForm):
<|fim_middle|>
<|fim▁end|> | """
Defines the form used to create a new ImageModelJob
"""
crop_size = utils.forms.IntegerField(
'Crop Size',
validators=[
validators.NumberRange(min=1),
validators.Optional()
],
tooltip=("If specified, during training a random square crop will be "
"taken from the input image before using as input for the network.")
)
use_mean = utils.forms.SelectField(
'Subtract Mean',
choices=[
('none', 'None'),
('image', 'Image'),
('pixel', 'Pixel'),
],
default='image',
tooltip="Subtract the mean file or mean pixel for this dataset from each image."
)
aug_flip = utils.forms.SelectField(
'Flipping',
choices=[
('none', 'None'),
('fliplr', 'Horizontal'),
('flipud', 'Vertical'),
('fliplrud', 'Horizontal and/or Vertical'),
],
default='none',
tooltip="Randomly flips each image during batch preprocessing."
)
aug_quad_rot = utils.forms.SelectField(
'Quadrilateral Rotation',
choices=[
('none', 'None'),
('rot90', '0, 90 or 270 degrees'),
('rot180', '0 or 180 degrees'),
('rotall', '0, 90, 180 or 270 degrees.'),
],
default='none',
tooltip="Randomly rotates (90 degree steps) each image during batch preprocessing."
)
aug_rot = utils.forms.IntegerField(
'Rotation (+- deg)',
default=0,
validators=[
validators.NumberRange(min=0, max=180)
],
tooltip="The uniform-random rotation angle that will be performed during batch preprocessing."
)
aug_scale = utils.forms.FloatField(
'Rescale (stddev)',
default=0,
validators=[
validators.NumberRange(min=0, max=1)
],
tooltip=("Retaining image size, the image is rescaled with a "
"+-stddev of this parameter. Suggested value is 0.07.")
)
aug_noise = utils.forms.FloatField(
'Noise (stddev)',
default=0,
validators=[
validators.NumberRange(min=0, max=1)
],
tooltip=("Adds AWGN (Additive White Gaussian Noise) during batch "
"preprocessing, assuming [0 1] pixel-value range. Suggested value is 0.03.")
)
aug_hsv_use = utils.forms.BooleanField(
'HSV Shifting',
default=False,
tooltip=("Augmentation by normal-distributed random shifts in HSV "
"color space, assuming [0 1] pixel-value range."),
)
aug_hsv_h = utils.forms.FloatField(
'Hue',
default=0.02,
validators=[
validators.NumberRange(min=0, max=0.5)
],
tooltip=("Standard deviation of a shift that will be performed during "
"preprocessing, assuming [0 1] pixel-value range.")
)
aug_hsv_s = utils.forms.FloatField(
'Saturation',
default=0.04,
validators=[
validators.NumberRange(min=0, max=0.5)
],
tooltip=("Standard deviation of a shift that will be performed during "
"preprocessing, assuming [0 1] pixel-value range.")
)
aug_hsv_v = utils.forms.FloatField(
'Value',
default=0.06,
validators=[
validators.NumberRange(min=0, max=0.5)
],
tooltip=("Standard deviation of a shift that will be performed during "
"preprocessing, assuming [0 1] pixel-value range.")
) |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):<|fim▁hole|> stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())<|fim▁end|> | stripped_path = path[:-1]
else: |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
<|fim_middle|>
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1] |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
<|fim_middle|>
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | if parent.endswith('/'):
return parent + base
return parent + '/' + base |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
<|fim_middle|>
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest()) |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
<|fim_middle|>
<|fim▁end|> | hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest()) |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
<|fim_middle|>
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1) |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
<|fim_middle|>
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | stripped_path = path[:-1] |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
<|fim_middle|>
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | stripped_path = path |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
<|fim_middle|>
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | raise ValueError('Invalid path') |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
<|fim_middle|>
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1] |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
<|fim_middle|>
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1])) |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
<|fim_middle|>
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1])) |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
<|fim_middle|>
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | return parent + base |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def <|fim_middle|>(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | getParentAndBase |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def <|fim_middle|>(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | pathJoin |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def <|fim_middle|>(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def md5_for_str(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | md5_for_file |
<|file_name|>util.py<|end_file_name|><|fim▁begin|>import re
import hashlib
FNAME_MATCH = re.compile(r'/([^/]+)$') # From the last slash to the end of the string
PREFIX = re.compile(r'([^:]+://)(/)?(.+)') # Check for a prefix like data://
def getParentAndBase(path):
match = PREFIX.match(path)
if match is None:
if path.endswith('/'):
stripped_path = path[:-1]
else:
stripped_path = path
base = FNAME_MATCH.search(stripped_path)
if base is None:
raise ValueError('Invalid path')
parent = FNAME_MATCH.sub('', stripped_path)
return parent, base.group(1)
else:
prefix, leading_slash, uri = match.groups()
parts = uri.split('/')
parent_path = '/'.join(parts[:-1])
if leading_slash is not None:
parent_path = '{prefix}/{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
else:
parent_path = '{prefix}{uri}'.format(prefix=prefix, uri='/'.join(parts[:-1]))
return parent_path, parts[-1]
def pathJoin(parent, base):
if parent.endswith('/'):
return parent + base
return parent + '/' + base
def md5_for_file(fname):
hash_md5 = hashlib.md5()
with open(fname, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return str(hash_md5.hexdigest())
def <|fim_middle|>(content):
hash_md5 = hashlib.md5()
hash_md5.update(content.encode())
return str(hash_md5.hexdigest())
<|fim▁end|> | md5_for_str |
<|file_name|>nuoc.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
from heapq import heapify, heappop, heappush
with open('NUOC.INP') as f:
m, n = map(int, f.readline().split())
height = [[int(i) for i in line.split()] for line in f]
queue = ([(h, 0, i) for i, h in enumerate(height[0])]
+ [(h, m - 1, i) for i, h in enumerate(height[-1])]
+ [(height[i][0], i, 0) for i in range(m)]
+ [(height[i][-1], i, n - 1) for i in range(m)])
heapify(queue)<|fim▁hole|> + [[True] * n])
result = 0
while queue:
h, i, j = heappop(queue)
for x, y in (i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1):
if 0 <= x < m and 0 <= y < n and not visited[x][y]:
result += max(0, h - height[x][y])
heappush(queue, (max(height[x][y], h), x, y))
visited[x][y] = True
with open('NUOC.OUT', 'w') as f: print(result, file=f)<|fim▁end|> | visited = ([[True] * n]
+ [[True] + [False] * (n - 2) + [True] for _ in range(m - 2)] |
<|file_name|>nuoc.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
from heapq import heapify, heappop, heappush
with open('NUOC.INP') as f:
m, n = map(int, f.readline().split())
height = [[int(i) for i in line.split()] for line in f]
queue = ([(h, 0, i) for i, h in enumerate(height[0])]
+ [(h, m - 1, i) for i, h in enumerate(height[-1])]
+ [(height[i][0], i, 0) for i in range(m)]
+ [(height[i][-1], i, n - 1) for i in range(m)])
heapify(queue)
visited = ([[True] * n]
+ [[True] + [False] * (n - 2) + [True] for _ in range(m - 2)]
+ [[True] * n])
result = 0
while queue:
h, i, j = heappop(queue)
for x, y in (i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1):
if 0 <= x < m and 0 <= y < n and not visited[x][y]:
<|fim_middle|>
with open('NUOC.OUT', 'w') as f: print(result, file=f)
<|fim▁end|> | result += max(0, h - height[x][y])
heappush(queue, (max(height[x][y], h), x, y))
visited[x][y] = True |
<|file_name|>use_sax.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3<|fim▁hole|>
from xml.parsers.expat import ParserCreate
class DefaultSaxHandler(object):
def start_element(self, name, attrs):
print('sax:start_element: %s, attrs: %s' % (name, str(attrs)))
def end_element(self, name):
print('sax:end_element: %s' % name)
def char_data(self, text):
print('sax:char_data: %s' % text)
xml = r'''<?xml version="1.0"?>
<ol>
<li><a href="/python">Python</a></li>
<li><a href="/ruby">Ruby</a></li>
</ol>
'''
handler = DefaultSaxHandler()
parser = ParserCreate()
parser.StartElementHandler = handler.start_element
parser.EndElementHandler = handler.end_element
parser.CharacterDataHandler = handler.char_data
parser.Parse(xml)<|fim▁end|> | # -*- coding: utf-8 -*- |
<|file_name|>use_sax.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from xml.parsers.expat import ParserCreate
class DefaultSaxHandler(object):
<|fim_middle|>
xml = r'''<?xml version="1.0"?>
<ol>
<li><a href="/python">Python</a></li>
<li><a href="/ruby">Ruby</a></li>
</ol>
'''
handler = DefaultSaxHandler()
parser = ParserCreate()
parser.StartElementHandler = handler.start_element
parser.EndElementHandler = handler.end_element
parser.CharacterDataHandler = handler.char_data
parser.Parse(xml)
<|fim▁end|> | def start_element(self, name, attrs):
print('sax:start_element: %s, attrs: %s' % (name, str(attrs)))
def end_element(self, name):
print('sax:end_element: %s' % name)
def char_data(self, text):
print('sax:char_data: %s' % text) |
<|file_name|>use_sax.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from xml.parsers.expat import ParserCreate
class DefaultSaxHandler(object):
def start_element(self, name, attrs):
<|fim_middle|>
def end_element(self, name):
print('sax:end_element: %s' % name)
def char_data(self, text):
print('sax:char_data: %s' % text)
xml = r'''<?xml version="1.0"?>
<ol>
<li><a href="/python">Python</a></li>
<li><a href="/ruby">Ruby</a></li>
</ol>
'''
handler = DefaultSaxHandler()
parser = ParserCreate()
parser.StartElementHandler = handler.start_element
parser.EndElementHandler = handler.end_element
parser.CharacterDataHandler = handler.char_data
parser.Parse(xml)
<|fim▁end|> | print('sax:start_element: %s, attrs: %s' % (name, str(attrs))) |
<|file_name|>use_sax.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from xml.parsers.expat import ParserCreate
class DefaultSaxHandler(object):
def start_element(self, name, attrs):
print('sax:start_element: %s, attrs: %s' % (name, str(attrs)))
def end_element(self, name):
<|fim_middle|>
def char_data(self, text):
print('sax:char_data: %s' % text)
xml = r'''<?xml version="1.0"?>
<ol>
<li><a href="/python">Python</a></li>
<li><a href="/ruby">Ruby</a></li>
</ol>
'''
handler = DefaultSaxHandler()
parser = ParserCreate()
parser.StartElementHandler = handler.start_element
parser.EndElementHandler = handler.end_element
parser.CharacterDataHandler = handler.char_data
parser.Parse(xml)
<|fim▁end|> | print('sax:end_element: %s' % name) |
<|file_name|>use_sax.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from xml.parsers.expat import ParserCreate
class DefaultSaxHandler(object):
def start_element(self, name, attrs):
print('sax:start_element: %s, attrs: %s' % (name, str(attrs)))
def end_element(self, name):
print('sax:end_element: %s' % name)
def char_data(self, text):
<|fim_middle|>
xml = r'''<?xml version="1.0"?>
<ol>
<li><a href="/python">Python</a></li>
<li><a href="/ruby">Ruby</a></li>
</ol>
'''
handler = DefaultSaxHandler()
parser = ParserCreate()
parser.StartElementHandler = handler.start_element
parser.EndElementHandler = handler.end_element
parser.CharacterDataHandler = handler.char_data
parser.Parse(xml)
<|fim▁end|> | print('sax:char_data: %s' % text) |
<|file_name|>use_sax.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from xml.parsers.expat import ParserCreate
class DefaultSaxHandler(object):
def <|fim_middle|>(self, name, attrs):
print('sax:start_element: %s, attrs: %s' % (name, str(attrs)))
def end_element(self, name):
print('sax:end_element: %s' % name)
def char_data(self, text):
print('sax:char_data: %s' % text)
xml = r'''<?xml version="1.0"?>
<ol>
<li><a href="/python">Python</a></li>
<li><a href="/ruby">Ruby</a></li>
</ol>
'''
handler = DefaultSaxHandler()
parser = ParserCreate()
parser.StartElementHandler = handler.start_element
parser.EndElementHandler = handler.end_element
parser.CharacterDataHandler = handler.char_data
parser.Parse(xml)
<|fim▁end|> | start_element |
<|file_name|>use_sax.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from xml.parsers.expat import ParserCreate
class DefaultSaxHandler(object):
def start_element(self, name, attrs):
print('sax:start_element: %s, attrs: %s' % (name, str(attrs)))
def <|fim_middle|>(self, name):
print('sax:end_element: %s' % name)
def char_data(self, text):
print('sax:char_data: %s' % text)
xml = r'''<?xml version="1.0"?>
<ol>
<li><a href="/python">Python</a></li>
<li><a href="/ruby">Ruby</a></li>
</ol>
'''
handler = DefaultSaxHandler()
parser = ParserCreate()
parser.StartElementHandler = handler.start_element
parser.EndElementHandler = handler.end_element
parser.CharacterDataHandler = handler.char_data
parser.Parse(xml)
<|fim▁end|> | end_element |
<|file_name|>use_sax.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from xml.parsers.expat import ParserCreate
class DefaultSaxHandler(object):
def start_element(self, name, attrs):
print('sax:start_element: %s, attrs: %s' % (name, str(attrs)))
def end_element(self, name):
print('sax:end_element: %s' % name)
def <|fim_middle|>(self, text):
print('sax:char_data: %s' % text)
xml = r'''<?xml version="1.0"?>
<ol>
<li><a href="/python">Python</a></li>
<li><a href="/ruby">Ruby</a></li>
</ol>
'''
handler = DefaultSaxHandler()
parser = ParserCreate()
parser.StartElementHandler = handler.start_element
parser.EndElementHandler = handler.end_element
parser.CharacterDataHandler = handler.char_data
parser.Parse(xml)
<|fim▁end|> | char_data |
<|file_name|>loc.py<|end_file_name|><|fim▁begin|>"""Local settings and globals."""<|fim▁hole|>
# Import secrets -- not needed
#sys.path.append(
# abspath(join(PROJECT_ROOT, '../secrets/TimelineJS/stg'))
#)
#from secrets import *
# Set static URL
STATIC_URL = '/static'<|fim▁end|> | import sys
from os.path import normpath, join
from .base import * |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass<|fim▁hole|> pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()<|fim▁end|> |
@abc.abstractmethod
def min(self): |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
<|fim_middle|>
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | @abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
<|fim_middle|>
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
<|fim_middle|>
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
<|fim_middle|>
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
<|fim_middle|>
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
<|fim_middle|>
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
<|fim_middle|>
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | @abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
<|fim_middle|>
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
<|fim_middle|>
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
<|fim_middle|>
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
<|fim_middle|>
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | pass |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
<|fim_middle|>
<|fim▁end|> | if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError() |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
<|fim_middle|>
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors() |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
<|fim_middle|>
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | from .driver_mac import MacMonitors
return MacMonitors() |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
<|fim_middle|>
else:
raise OSError()
<|fim▁end|> | from .driver_linux import LinuxMonitors
return LinuxMonitors() |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
<|fim_middle|>
<|fim▁end|> | raise OSError() |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def <|fim_middle|>(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | current |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def <|fim_middle|>(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | percent |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def <|fim_middle|>(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | reset |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def <|fim_middle|>(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | max |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def <|fim_middle|>(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | min |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def <|fim_middle|>(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | percent |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def <|fim_middle|>(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | reset |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def <|fim_middle|>(self):
pass
@abc.abstractmethod
def min(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | max |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def <|fim_middle|>(self):
pass
def get_monitors():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | min |
<|file_name|>base.py<|end_file_name|><|fim▁begin|># -*- coding:utf-8 -*-
import abc
import platform
from UserList import UserList
class Monitor(object):
@abc.abstractmethod
def current(self):
pass
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
class Monitors(UserList):
@abc.abstractmethod
def percent(self, range):
pass
@abc.abstractmethod
def reset(self):
pass
@abc.abstractmethod
def max(self):
pass
@abc.abstractmethod
def min(self):
pass
def <|fim_middle|>():
if platform.system() == "Windows":
from .driver_win_wmi import WinWMIMonitors
return WinWMIMonitors()
elif platform.system() == "Darwin":
from .driver_mac import MacMonitors
return MacMonitors()
elif platform.system() == "Linux":
from .driver_linux import LinuxMonitors
return LinuxMonitors()
else:
raise OSError()
<|fim▁end|> | get_monitors |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5<|fim▁hole|> """
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'<|fim▁end|> |
def test_load_board(): |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
<|fim_middle|>
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def test_load_board():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | return '\n'.join([i.strip() for i in ascii_board.splitlines()]) |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
<|fim_middle|>
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def test_load_board():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""") |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
<|fim_middle|>
def test_load_board():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5 |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def test_load_board():
<|fim_middle|>
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | """
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
""")) |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def test_load_board():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
<|fim_middle|>
<|fim▁end|> | board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x' |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def <|fim_middle|>(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def test_load_board():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | trim_board |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def <|fim_middle|>():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def test_load_board():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | test_new_board |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def <|fim_middle|>():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def test_load_board():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | test_game |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def <|fim_middle|>():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def test_axis_strings():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | test_load_board |
<|file_name|>test_game.py<|end_file_name|><|fim▁begin|>import game as game
import pytest
import sys
sys.path.insert(0, '..')
def trim_board(ascii_board):
return '\n'.join([i.strip() for i in ascii_board.splitlines()])
t = trim_board
def test_new_board():
game.Board(3,3).ascii() == t("""
...
...
...
""")
game.Board(4,3).ascii() == t("""
....
....
....
""")
game.Board(3,4).ascii() == t("""
...
...
...
...
""")
def test_game():
board = game.Board(3,3,win=3)
assert board.count_tokens == 0
assert board.game_status == 'active'
assert board.turn_color == None
# drop first token
token = board.drop('x',0)
assert board.game_status == 'active'
assert token.position == (0,0)
assert token.color == 'x'
assert board.ascii() == t("""
...
...
x..
""")
assert board.count_tokens == 1
assert board.turn_color == 'o'
# drop second token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,1)
assert token.color == 'o'
assert board.ascii() == t("""
...
o..
x..
""")
assert board.count_tokens == 2
assert board.turn_color == 'x'
# dropping the wrong color should raise an error
with pytest.raises(Exception):
token = board.drop('o',1)
# drop third token
token = board.drop('x',1)
assert board.game_status == 'active'
assert token.position == (1,0)
assert token.color == 'x'
board.ascii() == t("""
...
o..
xx.
""")
assert board.count_tokens == 3
assert board.turn_color == 'o'
# drop fourth token
token = board.drop('o',0)
assert board.game_status == 'active'
assert token.position == (0,2)
assert token.color == 'o'
board.ascii() == t("""
o..
o..
xx.
""")
assert board.count_tokens == 4
# drop fifth token
token = board.drop('x',2)
assert board.game_status == 'over'
assert board.won_by == 'x'
assert token.position == (2,0)
assert token.color == 'x'
board.ascii() == t("""
o..
o..
xxx
""")
assert board.count_tokens == 5
def test_load_board():
"""
The Board class should provide a load method to load a predefined board.
the load method should be implemented as a static method like this:
>>> class Test:
>>> @staticmethod
>>> def a_static_factory():
>>> t = Test()
>>> # do something with t and return it
>>> return t
the load function accepts a board layout. It retrieves the dimensions of the board
and loads the provided data into the board.
"""
board = game.Board.load(t("""
o..
o..
xxx
"""))
def <|fim_middle|>():
board = game.Board.load(t("""
o..
o..
xxx
"""))
# get the axis strings in this order: | \ / -
axis_strings = board.axis_strings(0,0)
assert axis_strings[0] == 'xoo'
assert axis_strings[1] == 'x'
assert axis_strings[2] == 'x..'
assert axis_strings[3] == 'xxx' # the winner :-)
assert board.won_by == 'x'
<|fim▁end|> | test_axis_strings |
<|file_name|>users.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
""""
ProjectName: pydemi
Repo: https://github.com/chrisenytc/pydemi
Copyright (c) 2014 Christopher EnyTC
Licensed under the MIT license.
"""
# Dependencies
import uuid
from api import app
from hashlib import sha1
from flask import request
from flask import jsonify as JSON<|fim▁hole|>
@app.route('/signup', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signup():
# Create new user
new_user = User()
new_user.name = request.form['name']
new_user.email = request.form['email']
new_user.password = sha1(request.form['password']).hexdigest()
new_user.token = str(uuid.uuid4())
new_user.save()
return JSON(message='User created successfully')
@app.route('/signin', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signin():
# Retorna a user data
user_info = User.objects(email=request.form['email'], password=sha1(
request.form['password']).hexdigest())
if user_info.count():
return JSON(token=user_info.get().token, roles=user_info.get().roles)
else:
return JSON(message='User not found')<|fim▁end|> | from api.models.user import User
from cors import cors |
<|file_name|>users.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
""""
ProjectName: pydemi
Repo: https://github.com/chrisenytc/pydemi
Copyright (c) 2014 Christopher EnyTC
Licensed under the MIT license.
"""
# Dependencies
import uuid
from api import app
from hashlib import sha1
from flask import request
from flask import jsonify as JSON
from api.models.user import User
from cors import cors
@app.route('/signup', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signup():
# Create new user
<|fim_middle|>
@app.route('/signin', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signin():
# Retorna a user data
user_info = User.objects(email=request.form['email'], password=sha1(
request.form['password']).hexdigest())
if user_info.count():
return JSON(token=user_info.get().token, roles=user_info.get().roles)
else:
return JSON(message='User not found')
<|fim▁end|> | new_user = User()
new_user.name = request.form['name']
new_user.email = request.form['email']
new_user.password = sha1(request.form['password']).hexdigest()
new_user.token = str(uuid.uuid4())
new_user.save()
return JSON(message='User created successfully') |
<|file_name|>users.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
""""
ProjectName: pydemi
Repo: https://github.com/chrisenytc/pydemi
Copyright (c) 2014 Christopher EnyTC
Licensed under the MIT license.
"""
# Dependencies
import uuid
from api import app
from hashlib import sha1
from flask import request
from flask import jsonify as JSON
from api.models.user import User
from cors import cors
@app.route('/signup', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signup():
# Create new user
new_user = User()
new_user.name = request.form['name']
new_user.email = request.form['email']
new_user.password = sha1(request.form['password']).hexdigest()
new_user.token = str(uuid.uuid4())
new_user.save()
return JSON(message='User created successfully')
@app.route('/signin', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signin():
# Retorna a user data
<|fim_middle|>
<|fim▁end|> | user_info = User.objects(email=request.form['email'], password=sha1(
request.form['password']).hexdigest())
if user_info.count():
return JSON(token=user_info.get().token, roles=user_info.get().roles)
else:
return JSON(message='User not found') |
<|file_name|>users.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
""""
ProjectName: pydemi
Repo: https://github.com/chrisenytc/pydemi
Copyright (c) 2014 Christopher EnyTC
Licensed under the MIT license.
"""
# Dependencies
import uuid
from api import app
from hashlib import sha1
from flask import request
from flask import jsonify as JSON
from api.models.user import User
from cors import cors
@app.route('/signup', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signup():
# Create new user
new_user = User()
new_user.name = request.form['name']
new_user.email = request.form['email']
new_user.password = sha1(request.form['password']).hexdigest()
new_user.token = str(uuid.uuid4())
new_user.save()
return JSON(message='User created successfully')
@app.route('/signin', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signin():
# Retorna a user data
user_info = User.objects(email=request.form['email'], password=sha1(
request.form['password']).hexdigest())
if user_info.count():
<|fim_middle|>
else:
return JSON(message='User not found')
<|fim▁end|> | return JSON(token=user_info.get().token, roles=user_info.get().roles) |
<|file_name|>users.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
""""
ProjectName: pydemi
Repo: https://github.com/chrisenytc/pydemi
Copyright (c) 2014 Christopher EnyTC
Licensed under the MIT license.
"""
# Dependencies
import uuid
from api import app
from hashlib import sha1
from flask import request
from flask import jsonify as JSON
from api.models.user import User
from cors import cors
@app.route('/signup', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signup():
# Create new user
new_user = User()
new_user.name = request.form['name']
new_user.email = request.form['email']
new_user.password = sha1(request.form['password']).hexdigest()
new_user.token = str(uuid.uuid4())
new_user.save()
return JSON(message='User created successfully')
@app.route('/signin', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signin():
# Retorna a user data
user_info = User.objects(email=request.form['email'], password=sha1(
request.form['password']).hexdigest())
if user_info.count():
return JSON(token=user_info.get().token, roles=user_info.get().roles)
else:
<|fim_middle|>
<|fim▁end|> | return JSON(message='User not found') |
<|file_name|>users.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
""""
ProjectName: pydemi
Repo: https://github.com/chrisenytc/pydemi
Copyright (c) 2014 Christopher EnyTC
Licensed under the MIT license.
"""
# Dependencies
import uuid
from api import app
from hashlib import sha1
from flask import request
from flask import jsonify as JSON
from api.models.user import User
from cors import cors
@app.route('/signup', methods=['POST'])
@cors(origin='*', methods=['POST'])
def <|fim_middle|>():
# Create new user
new_user = User()
new_user.name = request.form['name']
new_user.email = request.form['email']
new_user.password = sha1(request.form['password']).hexdigest()
new_user.token = str(uuid.uuid4())
new_user.save()
return JSON(message='User created successfully')
@app.route('/signin', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signin():
# Retorna a user data
user_info = User.objects(email=request.form['email'], password=sha1(
request.form['password']).hexdigest())
if user_info.count():
return JSON(token=user_info.get().token, roles=user_info.get().roles)
else:
return JSON(message='User not found')
<|fim▁end|> | signup |
<|file_name|>users.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
""""
ProjectName: pydemi
Repo: https://github.com/chrisenytc/pydemi
Copyright (c) 2014 Christopher EnyTC
Licensed under the MIT license.
"""
# Dependencies
import uuid
from api import app
from hashlib import sha1
from flask import request
from flask import jsonify as JSON
from api.models.user import User
from cors import cors
@app.route('/signup', methods=['POST'])
@cors(origin='*', methods=['POST'])
def signup():
# Create new user
new_user = User()
new_user.name = request.form['name']
new_user.email = request.form['email']
new_user.password = sha1(request.form['password']).hexdigest()
new_user.token = str(uuid.uuid4())
new_user.save()
return JSON(message='User created successfully')
@app.route('/signin', methods=['POST'])
@cors(origin='*', methods=['POST'])
def <|fim_middle|>():
# Retorna a user data
user_info = User.objects(email=request.form['email'], password=sha1(
request.form['password']).hexdigest())
if user_info.count():
return JSON(token=user_info.get().token, roles=user_info.get().roles)
else:
return JSON(message='User not found')
<|fim▁end|> | signin |
<|file_name|>setup.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
import os
from setuptools import setup
from subprocess import call
from sys import platform, argv
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
SCRIPTS = ["src/bg_daemon/background_daemon.py"]
# only compile quack when none of these options are chosen
if (all([e not in argv for e in ['egg_info', 'sdist', 'register']]) and
platform == 'darwin'):
try:
call(['make', '-C', 'src/bg_daemon/'])
SCRIPTS.append("src/bg_daemon/quack")
except OSError as e:
print "Can't compile quack, reason {}".format(str(e))
<|fim▁hole|> name="bg_daemon",
version="0.0.1",
author="Santiago Torres",
author_email="[email protected]",
description=("An extensible set of classes that can programmatically "
"update the desktop wallpaper"),
license="GPLv2",
keywords="imgur desktop wallpaper background",
url="https://github.com/santiagotorres/bg_daemon",
packages=["bg_daemon", "bg_daemon.fetchers"],
package_dir={"bg_daemon": "src/bg_daemon",
"bg_daemon.fetchers": "src/bg_daemon/fetchers"},
scripts=SCRIPTS,
include_package_data=True,
data_files=[('bg_daemon', ['src/bg_daemon/settings.json',
'src/bg_daemon/mac-update.sh'])],
long_description=read("README.md"),
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Topic :: Utilities",
"License :: ",
"Environment :: No Input/Output (Daemon)",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Operating System :: Unix",
"Topic :: Multimedia",
],
install_requires=[
"imgurpython",
"requests",
"python-crontab",
"mock",
],
)<|fim▁end|> | setup( |
<|file_name|>setup.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
import os
from setuptools import setup
from subprocess import call
from sys import platform, argv
def read(fname):
<|fim_middle|>
SCRIPTS = ["src/bg_daemon/background_daemon.py"]
# only compile quack when none of these options are chosen
if (all([e not in argv for e in ['egg_info', 'sdist', 'register']]) and
platform == 'darwin'):
try:
call(['make', '-C', 'src/bg_daemon/'])
SCRIPTS.append("src/bg_daemon/quack")
except OSError as e:
print "Can't compile quack, reason {}".format(str(e))
setup(
name="bg_daemon",
version="0.0.1",
author="Santiago Torres",
author_email="[email protected]",
description=("An extensible set of classes that can programmatically "
"update the desktop wallpaper"),
license="GPLv2",
keywords="imgur desktop wallpaper background",
url="https://github.com/santiagotorres/bg_daemon",
packages=["bg_daemon", "bg_daemon.fetchers"],
package_dir={"bg_daemon": "src/bg_daemon",
"bg_daemon.fetchers": "src/bg_daemon/fetchers"},
scripts=SCRIPTS,
include_package_data=True,
data_files=[('bg_daemon', ['src/bg_daemon/settings.json',
'src/bg_daemon/mac-update.sh'])],
long_description=read("README.md"),
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Topic :: Utilities",
"License :: ",
"Environment :: No Input/Output (Daemon)",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Operating System :: Unix",
"Topic :: Multimedia",
],
install_requires=[
"imgurpython",
"requests",
"python-crontab",
"mock",
],
)
<|fim▁end|> | return open(os.path.join(os.path.dirname(__file__), fname)).read() |
<|file_name|>setup.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
import os
from setuptools import setup
from subprocess import call
from sys import platform, argv
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
SCRIPTS = ["src/bg_daemon/background_daemon.py"]
# only compile quack when none of these options are chosen
if (all([e not in argv for e in ['egg_info', 'sdist', 'register']]) and
platform == 'darwin'):
<|fim_middle|>
setup(
name="bg_daemon",
version="0.0.1",
author="Santiago Torres",
author_email="[email protected]",
description=("An extensible set of classes that can programmatically "
"update the desktop wallpaper"),
license="GPLv2",
keywords="imgur desktop wallpaper background",
url="https://github.com/santiagotorres/bg_daemon",
packages=["bg_daemon", "bg_daemon.fetchers"],
package_dir={"bg_daemon": "src/bg_daemon",
"bg_daemon.fetchers": "src/bg_daemon/fetchers"},
scripts=SCRIPTS,
include_package_data=True,
data_files=[('bg_daemon', ['src/bg_daemon/settings.json',
'src/bg_daemon/mac-update.sh'])],
long_description=read("README.md"),
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Topic :: Utilities",
"License :: ",
"Environment :: No Input/Output (Daemon)",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Operating System :: Unix",
"Topic :: Multimedia",
],
install_requires=[
"imgurpython",
"requests",
"python-crontab",
"mock",
],
)
<|fim▁end|> | try:
call(['make', '-C', 'src/bg_daemon/'])
SCRIPTS.append("src/bg_daemon/quack")
except OSError as e:
print "Can't compile quack, reason {}".format(str(e)) |
<|file_name|>setup.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
import os
from setuptools import setup
from subprocess import call
from sys import platform, argv
def <|fim_middle|>(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
SCRIPTS = ["src/bg_daemon/background_daemon.py"]
# only compile quack when none of these options are chosen
if (all([e not in argv for e in ['egg_info', 'sdist', 'register']]) and
platform == 'darwin'):
try:
call(['make', '-C', 'src/bg_daemon/'])
SCRIPTS.append("src/bg_daemon/quack")
except OSError as e:
print "Can't compile quack, reason {}".format(str(e))
setup(
name="bg_daemon",
version="0.0.1",
author="Santiago Torres",
author_email="[email protected]",
description=("An extensible set of classes that can programmatically "
"update the desktop wallpaper"),
license="GPLv2",
keywords="imgur desktop wallpaper background",
url="https://github.com/santiagotorres/bg_daemon",
packages=["bg_daemon", "bg_daemon.fetchers"],
package_dir={"bg_daemon": "src/bg_daemon",
"bg_daemon.fetchers": "src/bg_daemon/fetchers"},
scripts=SCRIPTS,
include_package_data=True,
data_files=[('bg_daemon', ['src/bg_daemon/settings.json',
'src/bg_daemon/mac-update.sh'])],
long_description=read("README.md"),
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Topic :: Utilities",
"License :: ",
"Environment :: No Input/Output (Daemon)",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Operating System :: Unix",
"Topic :: Multimedia",
],
install_requires=[
"imgurpython",
"requests",
"python-crontab",
"mock",
],
)
<|fim▁end|> | read |
<|file_name|>parseTest.py<|end_file_name|><|fim▁begin|>#!/usr/bin/python
import re
userInput = raw_input("input equation\n")
numCount = 0
operandCount = 0
entryBracketCount = 0
exitBracketCount = 0
charCount = 0
endOfLine = len(userInput) - 1
for i in range(len(userInput)):
if (re.search('[\s*a-z\s*A-Z]+', userInput[i])):
charCount = charCount + 1
print operandCount, " 1"
elif (re.search('[\s*0-9]+', userInput[i])):
numCount = numCount + 1
print operandCount, " 2"
elif (re.search('[\*]', userInput[i])):
print 'TRUE'
# operandCount = operandCount + 1
# print operandCount, " 3.5"
# elif (re.search('[\s*\+|\s*\-|\s*\/]+', userInput[i])):
elif (re.search('[+-/*]+', userInput[i])):
operandCount = operandCount + 1
print operandCount, " 3"
# if(re.search('[\s*\+|\s*\-|\s*\/]+', userInput[endOfLine])):
if(re.search('[+-/*]+', userInput[endOfLine])):
print "invalid expression"
print "1"
exit(0)
else:
if((re.search('[\s*a-zA-Z]+', userInput[i - 1])) or (re.search('[\s*\d]+', userInput[i - 1]))):
continue
else:
print 'invalid expression'
print '2'
exit(0)
if(re.search('[\s*\d]+', userInput[i - 1])):
continue
else:
print 'invalid expression'
print '3'
exit(0)
if(re.search('[\s*a-zA-Z]+', userInput[i + 1])):
continue
elif(re.search('[\s*\d]+', userInput[i + 1])):
continue
elif (re.search('[\(]+', userInput[i + 1])):
continue
elif (re.search('[\)]+', userInput[i + 1])):
continue
else:
print 'invalid expression'
print '4'
exit(0)
elif (re.search('[\(]+', userInput[i])):
entryBracketCount = entryBracketCount + 1
print operandCount, " 4"
elif (re.search('[\)]+', userInput[i])):
exitBracketCount = exitBracketCount + 1
print operandCount, " 5"
if(re.search('[\)]+', userInput[endOfLine])):
continue
else:
if(re.search('[\(]+', userInput[i + 1])):
print 'invalid expression'
print '5'
exit(0)
print operandCount, " 6"
if (entryBracketCount != exitBracketCount):
print "invalid expression"
print '6'
exit(0)
elif operandCount == 0:
print operandCount
print "invalid expression"
print '7'
exit(0)
elif ((numCount == 0) and (charCount == 0)):<|fim▁hole|> print "valid expression"<|fim▁end|> | print "invalid expression"
print '8'
exit(0)
else: |