prompt
large_stringlengths 72
9.34k
| completion
large_stringlengths 0
7.61k
|
---|---|
<|file_name|>test.py<|end_file_name|><|fim▁begin|>from planarprocess import *
from gds_helpers import *
from itertools import cycle
xmin, xmax = -5, 5
layers = gds_cross_section('mypmos.gds', [(0,xmin), (0, xmax)], 'gdsmap.map')
['P-Active-Well', 'Active-Cut', 'N-Well', 'Metal-2', 'Metal-1', 'P-Select',
'N-Select', 'Transistor-Poly', 'Via1']
wafer = Wafer(1., 5., 0, xmax - xmin)
# N-Well
nw = layers['N-Well']
wafer.implant(.7, nw, outdiffusion=5., label='N-Well')
# Field and gate oxides
de = layers['P-Active-Well']
# TODO: channel stop under field oxide
fox = wafer.grow(.5, wafer.blank_mask().difference(de),
y_offset=-.2, outdiffusion=.1)
gox = wafer.grow(.05, de, outdiffusion=.05, base=wafer.wells,
label='Gate oxide')
# Gate poly and N+/P+ implants
gp = layers['Transistor-Poly']
poly = wafer.grow(.25, gp, outdiffusion=.25, label='Gate poly')
np = layers['N-Select'].intersection(
layers['P-Active-Well']).difference(gp)
nplus = wafer.implant(.1, np, outdiffusion=.1, target=wafer.wells, source=gox,
label='N+')
pp = layers['P-Select'].intersection(
layers['P-Active-Well']).difference(gp)
pplus = wafer.implant(.1, pp, outdiffusion=.1, target=wafer.wells, source=gox,
label='P+')
# Multi-level dielectric and contacts
mld_thickness = .5
mld = wafer.grow(mld_thickness, wafer.blank_mask(), outdiffusion=.1)
ct = layers['Active-Cut']
contact = wafer.grow(-mld_thickness*1.1, ct, consuming=[mld, gox], base=wafer.air,
outdiffusion=.05, outdiffusion_vertices=3)
# Metals and vias
m1 = layers['Metal-1']
metal1 = wafer.grow(.6, m1, outdiffusion=.1, label='Metal-1')
ild_thickness = 1.2
ild1 = wafer.grow(ild_thickness, wafer.blank_mask(), outdiffusion=.1)
wafer.planarize()
v1 = layers['Via1']
via1 = wafer.grow(-ild_thickness*1.1, v1, consuming=[ild1], base=wafer.air,
outdiffusion=.05, outdiffusion_vertices=3)
m2 = layers['Metal-2']
metal2 = wafer.grow(1., m2, outdiffusion=.1, label='Metal-2')
# Presentation
custom_style = {s: {} for s in wafer.solids}
for solid, color in {
fox: '.4', gox: 'r', poly: 'g', mld: 'k',
ild1: '.3', contact: '.5', via1: '.5',
metal1: '.7', metal2: '.8'}.items():
custom_style[solid].update(dict(facecolor=color, edgecolor='k'))
for solid in wafer.solids:
if solid not in wafer.wells:
<|fim_middle|>
base_hatches = r'\/' # r'/\|-+xoO.*'
hatches = cycle(list(base_hatches) + [h1+h2 for h1 in base_hatches
for h2 in base_hatches])
colors = cycle('krgbcmy')
plot_geometryref(wafer.air, hatch='.', fill=False, linewidth=0, color=(.9,.9,.9),
zorder=-100)
zorder = -99
for solid in wafer.solids:
style = dict(hatch=next(hatches), fill=False,
edgecolor=next(colors), zorder=zorder)
zorder += 1
style.update(custom_style.get(solid, {}))
plot_geometryref(solid, **style)
pyplot.legend()
pyplot.savefig('mypmos-x.png')
pyplot.show()
<|fim▁end|> | custom_style[solid].update(dict(hatch=None, fill=True)) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):<|fim▁hole|>
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))<|fim▁end|> | expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list() |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
<|fim_middle|>
<|fim▁end|> | def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES")) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
<|fim_middle|>
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected)) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
<|fim_middle|>
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected)) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
<|fim_middle|>
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | self.assertTrue("ADMINISTRATOR" in Permission(2056)) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
<|fim_middle|>
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056)) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
<|fim_middle|>
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | self.assertTrue("USE_VAD" not in Permission(2056)) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
<|fim_middle|>
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056)) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
<|fim_middle|>
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE")) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
<|fim_middle|>
<|fim▁end|> | permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES")) |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def <|fim_middle|>(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | test_permission_from_list_to_list |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def <|fim_middle|>(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | test_permission_from_int_to_list |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def <|fim_middle|>(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | test_permission_in_permission |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def <|fim_middle|>(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | test_permissions_in_permission |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def <|fim_middle|>(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | test_permission_not_in_permission |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def <|fim_middle|>(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | test_permissions_not_in_permission |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def <|fim_middle|>(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def test_permission_remove(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | test_permission_add |
<|file_name|>test_permission.py<|end_file_name|><|fim▁begin|>import unittest
from bolt.discord.permissions import Permission
class TestPermission(unittest.TestCase):
def test_permission_from_list_to_list(self):
expected = ['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS']
permission = Permission(['MANAGE_WEBHOOKS', 'USE_EXTERNAL_EMOJIS'])
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_from_int_to_list(self):
expected = ['ADMINISTRATOR', 'SEND_MESSAGES']
permission = Permission(2056)
actual = permission.to_list()
self.assertListEqual(sorted(actual), sorted(expected))
def test_permission_in_permission(self):
self.assertTrue("ADMINISTRATOR" in Permission(2056))
def test_permissions_in_permission(self):
self.assertTrue(["ADMINISTRATOR", "SEND_MESSAGES"] in Permission(2056))
def test_permission_not_in_permission(self):
self.assertTrue("USE_VAD" not in Permission(2056))
def test_permissions_not_in_permission(self):
self.assertTrue(["SPEAK", "MANAGE_EMOJIS"] not in Permission(2056))
def test_permission_add(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertFalse(permission.allows("MENTION_EVERYONE"))
permission.add("MENTION_EVERYONE")
self.assertTrue(permission.allows("MENTION_EVERYONE"))
def <|fim_middle|>(self):
permission = Permission(2056)
self.assertTrue(permission.allows("ADMINISTRATOR"))
self.assertTrue(permission.allows("SEND_MESSAGES"))
permission.remove("SEND_MESSAGES")
self.assertFalse(permission.allows("SEND_MESSAGES"))
<|fim▁end|> | test_permission_remove |
<|file_name|>after_signup.py<|end_file_name|><|fim▁begin|>import urllib
from canvas import util
def make_cookie_key(key):
return 'after_signup_' + str(key)
<|fim▁hole|>def _get(request, key):
key = make_cookie_key(key)
val = request.COOKIES.get(key)
if val is not None:
val = util.loads(urllib.unquote(val))
return (key, val,)
def get_posted_comment(request):
'''
Gets a comment waiting to be posted, if one exists.
Returns a pair containing the cookie key used to retrieve it and its deserialized JSON.
'''
#TODO use dcramer's django-cookies so that we don't rely on having the response object to mutate cookies.
# That would make this API much cleaner and isolated.
return _get(request, 'post_comment')<|fim▁end|> | |
<|file_name|>after_signup.py<|end_file_name|><|fim▁begin|>import urllib
from canvas import util
def make_cookie_key(key):
<|fim_middle|>
def _get(request, key):
key = make_cookie_key(key)
val = request.COOKIES.get(key)
if val is not None:
val = util.loads(urllib.unquote(val))
return (key, val,)
def get_posted_comment(request):
'''
Gets a comment waiting to be posted, if one exists.
Returns a pair containing the cookie key used to retrieve it and its deserialized JSON.
'''
#TODO use dcramer's django-cookies so that we don't rely on having the response object to mutate cookies.
# That would make this API much cleaner and isolated.
return _get(request, 'post_comment')
<|fim▁end|> | return 'after_signup_' + str(key) |
<|file_name|>after_signup.py<|end_file_name|><|fim▁begin|>import urllib
from canvas import util
def make_cookie_key(key):
return 'after_signup_' + str(key)
def _get(request, key):
<|fim_middle|>
def get_posted_comment(request):
'''
Gets a comment waiting to be posted, if one exists.
Returns a pair containing the cookie key used to retrieve it and its deserialized JSON.
'''
#TODO use dcramer's django-cookies so that we don't rely on having the response object to mutate cookies.
# That would make this API much cleaner and isolated.
return _get(request, 'post_comment')
<|fim▁end|> | key = make_cookie_key(key)
val = request.COOKIES.get(key)
if val is not None:
val = util.loads(urllib.unquote(val))
return (key, val,) |
<|file_name|>after_signup.py<|end_file_name|><|fim▁begin|>import urllib
from canvas import util
def make_cookie_key(key):
return 'after_signup_' + str(key)
def _get(request, key):
key = make_cookie_key(key)
val = request.COOKIES.get(key)
if val is not None:
val = util.loads(urllib.unquote(val))
return (key, val,)
def get_posted_comment(request):
<|fim_middle|>
<|fim▁end|> | '''
Gets a comment waiting to be posted, if one exists.
Returns a pair containing the cookie key used to retrieve it and its deserialized JSON.
'''
#TODO use dcramer's django-cookies so that we don't rely on having the response object to mutate cookies.
# That would make this API much cleaner and isolated.
return _get(request, 'post_comment') |
<|file_name|>after_signup.py<|end_file_name|><|fim▁begin|>import urllib
from canvas import util
def make_cookie_key(key):
return 'after_signup_' + str(key)
def _get(request, key):
key = make_cookie_key(key)
val = request.COOKIES.get(key)
if val is not None:
<|fim_middle|>
return (key, val,)
def get_posted_comment(request):
'''
Gets a comment waiting to be posted, if one exists.
Returns a pair containing the cookie key used to retrieve it and its deserialized JSON.
'''
#TODO use dcramer's django-cookies so that we don't rely on having the response object to mutate cookies.
# That would make this API much cleaner and isolated.
return _get(request, 'post_comment')
<|fim▁end|> | val = util.loads(urllib.unquote(val)) |
<|file_name|>after_signup.py<|end_file_name|><|fim▁begin|>import urllib
from canvas import util
def <|fim_middle|>(key):
return 'after_signup_' + str(key)
def _get(request, key):
key = make_cookie_key(key)
val = request.COOKIES.get(key)
if val is not None:
val = util.loads(urllib.unquote(val))
return (key, val,)
def get_posted_comment(request):
'''
Gets a comment waiting to be posted, if one exists.
Returns a pair containing the cookie key used to retrieve it and its deserialized JSON.
'''
#TODO use dcramer's django-cookies so that we don't rely on having the response object to mutate cookies.
# That would make this API much cleaner and isolated.
return _get(request, 'post_comment')
<|fim▁end|> | make_cookie_key |
<|file_name|>after_signup.py<|end_file_name|><|fim▁begin|>import urllib
from canvas import util
def make_cookie_key(key):
return 'after_signup_' + str(key)
def <|fim_middle|>(request, key):
key = make_cookie_key(key)
val = request.COOKIES.get(key)
if val is not None:
val = util.loads(urllib.unquote(val))
return (key, val,)
def get_posted_comment(request):
'''
Gets a comment waiting to be posted, if one exists.
Returns a pair containing the cookie key used to retrieve it and its deserialized JSON.
'''
#TODO use dcramer's django-cookies so that we don't rely on having the response object to mutate cookies.
# That would make this API much cleaner and isolated.
return _get(request, 'post_comment')
<|fim▁end|> | _get |
<|file_name|>after_signup.py<|end_file_name|><|fim▁begin|>import urllib
from canvas import util
def make_cookie_key(key):
return 'after_signup_' + str(key)
def _get(request, key):
key = make_cookie_key(key)
val = request.COOKIES.get(key)
if val is not None:
val = util.loads(urllib.unquote(val))
return (key, val,)
def <|fim_middle|>(request):
'''
Gets a comment waiting to be posted, if one exists.
Returns a pair containing the cookie key used to retrieve it and its deserialized JSON.
'''
#TODO use dcramer's django-cookies so that we don't rely on having the response object to mutate cookies.
# That would make this API much cleaner and isolated.
return _get(request, 'post_comment')
<|fim▁end|> | get_posted_comment |
<|file_name|>setup.py<|end_file_name|><|fim▁begin|><|fim▁hole|># or saved. Do not modify them directly here.
# NB: PACKAGES is deprecated
NAME = 'ZenPacks.community.DistributedCollectors'
VERSION = '1.7'
AUTHOR = 'Egor Puzanov'
LICENSE = ''
NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.community']
PACKAGES = ['ZenPacks', 'ZenPacks.community', 'ZenPacks.community.DistributedCollectors']
INSTALL_REQUIRES = []
COMPAT_ZENOSS_VERS = '>=2.5'
PREV_ZENPACK_NAME = ''
# STOP_REPLACEMENTS
################################
# Zenoss will not overwrite any changes you make below here.
from setuptools import setup, find_packages
setup(
# This ZenPack metadata should usually be edited with the Zenoss
# ZenPack edit page. Whenever the edit page is submitted it will
# overwrite the values below (the ones it knows about) with new values.
name = NAME,
version = VERSION,
author = AUTHOR,
license = LICENSE,
# This is the version spec which indicates what versions of Zenoss
# this ZenPack is compatible with
compatZenossVers = COMPAT_ZENOSS_VERS,
# previousZenPackName is a facility for telling Zenoss that the name
# of this ZenPack has changed. If no ZenPack with the current name is
# installed then a zenpack of this name if installed will be upgraded.
prevZenPackName = PREV_ZENPACK_NAME,
# Indicate to setuptools which namespace packages the zenpack
# participates in
namespace_packages = NAMESPACE_PACKAGES,
# Tell setuptools what packages this zenpack provides.
packages = find_packages(),
# Tell setuptools to figure out for itself which files to include
# in the binary egg when it is built.
include_package_data = True,
# The MANIFEST.in file is the recommended way of including additional files
# in your ZenPack. package_data is another.
#package_data = {}
# Indicate dependencies on other python modules or ZenPacks. This line
# is modified by zenoss when the ZenPack edit page is submitted. Zenoss
# tries to put add/delete the names it manages at the beginning of this
# list, so any manual additions should be added to the end. Things will
# go poorly if this line is broken into multiple lines or modified to
# dramatically.
install_requires = INSTALL_REQUIRES,
# Every ZenPack egg must define exactly one zenoss.zenpacks entry point
# of this form.
entry_points = {
'zenoss.zenpacks': '%s = %s' % (NAME, NAME),
},
# All ZenPack eggs must be installed in unzipped form.
zip_safe = False,
)<|fim▁end|> | ################################
# These variables are overwritten by Zenoss when the ZenPack is exported |
<|file_name|>training_stsbenchmark_continue_training.py<|end_file_name|><|fim▁begin|>"""
This example loads the pre-trained SentenceTransformer model 'nli-distilroberta-base-v2' from the server.
It then fine-tunes this model for some epochs on the STS benchmark dataset.
Note: In this example, you must specify a SentenceTransformer model.
If you want to fine-tune a huggingface/transformers model like bert-base-uncased, see training_nli.py and training_stsbenchmark.py
"""
from torch.utils.data import DataLoader
import math
from sentence_transformers import SentenceTransformer, LoggingHandler, losses, util, InputExample
from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator
import logging
from datetime import datetime
import os
import gzip
import csv
#### Just some code to print debug information to stdout
logging.basicConfig(format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
level=logging.INFO,
handlers=[LoggingHandler()])
#### /print debug information to stdout
#Check if dataset exsist. If not, download and extract it
sts_dataset_path = 'datasets/stsbenchmark.tsv.gz'
if not os.path.exists(sts_dataset_path):
util.http_get('https://sbert.net/datasets/stsbenchmark.tsv.gz', sts_dataset_path)
# Read the dataset
model_name = 'nli-distilroberta-base-v2'
train_batch_size = 16
num_epochs = 4
model_save_path = 'output/training_stsbenchmark_continue_training-'+model_name+'-'+datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
# Load a pre-trained sentence transformer model
model = SentenceTransformer(model_name)
# Convert the dataset to a DataLoader ready for training
logging.info("Read STSbenchmark train dataset")
train_samples = []
dev_samples = []
test_samples = []
with gzip.open(sts_dataset_path, 'rt', encoding='utf8') as fIn:
reader = csv.DictReader(fIn, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in reader:
score = float(row['score']) / 5.0 # Normalize score to range 0 ... 1
inp_example = InputExample(texts=[row['sentence1'], row['sentence2']], label=score)
if row['split'] == 'dev':
dev_samples.append(inp_example)
elif row['split'] == 'test':
test_samples.append(inp_example)
else:
train_samples.append(inp_example)
train_dataloader = DataLoader(train_samples, shuffle=True, batch_size=train_batch_size)
train_loss = losses.CosineSimilarityLoss(model=model)
# Development set: Measure correlation between cosine score and gold labels
logging.info("Read STSbenchmark dev dataset")
evaluator = EmbeddingSimilarityEvaluator.from_input_examples(dev_samples, name='sts-dev')
# Configure the training. We skip evaluation in this example
warmup_steps = math.ceil(len(train_dataloader) * num_epochs * 0.1) #10% of train data for warm-up
logging.info("Warmup-steps: {}".format(warmup_steps))
# Train the model
model.fit(train_objectives=[(train_dataloader, train_loss)],
evaluator=evaluator,
epochs=num_epochs,
evaluation_steps=1000,
warmup_steps=warmup_steps,
output_path=model_save_path)
##############################################################################
#
# Load the stored model and evaluate its performance on STS benchmark dataset
#
##############################################################################<|fim▁hole|><|fim▁end|> |
model = SentenceTransformer(model_save_path)
test_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(test_samples, name='sts-test')
test_evaluator(model, output_path=model_save_path) |
<|file_name|>training_stsbenchmark_continue_training.py<|end_file_name|><|fim▁begin|>"""
This example loads the pre-trained SentenceTransformer model 'nli-distilroberta-base-v2' from the server.
It then fine-tunes this model for some epochs on the STS benchmark dataset.
Note: In this example, you must specify a SentenceTransformer model.
If you want to fine-tune a huggingface/transformers model like bert-base-uncased, see training_nli.py and training_stsbenchmark.py
"""
from torch.utils.data import DataLoader
import math
from sentence_transformers import SentenceTransformer, LoggingHandler, losses, util, InputExample
from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator
import logging
from datetime import datetime
import os
import gzip
import csv
#### Just some code to print debug information to stdout
logging.basicConfig(format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
level=logging.INFO,
handlers=[LoggingHandler()])
#### /print debug information to stdout
#Check if dataset exsist. If not, download and extract it
sts_dataset_path = 'datasets/stsbenchmark.tsv.gz'
if not os.path.exists(sts_dataset_path):
<|fim_middle|>
# Read the dataset
model_name = 'nli-distilroberta-base-v2'
train_batch_size = 16
num_epochs = 4
model_save_path = 'output/training_stsbenchmark_continue_training-'+model_name+'-'+datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
# Load a pre-trained sentence transformer model
model = SentenceTransformer(model_name)
# Convert the dataset to a DataLoader ready for training
logging.info("Read STSbenchmark train dataset")
train_samples = []
dev_samples = []
test_samples = []
with gzip.open(sts_dataset_path, 'rt', encoding='utf8') as fIn:
reader = csv.DictReader(fIn, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in reader:
score = float(row['score']) / 5.0 # Normalize score to range 0 ... 1
inp_example = InputExample(texts=[row['sentence1'], row['sentence2']], label=score)
if row['split'] == 'dev':
dev_samples.append(inp_example)
elif row['split'] == 'test':
test_samples.append(inp_example)
else:
train_samples.append(inp_example)
train_dataloader = DataLoader(train_samples, shuffle=True, batch_size=train_batch_size)
train_loss = losses.CosineSimilarityLoss(model=model)
# Development set: Measure correlation between cosine score and gold labels
logging.info("Read STSbenchmark dev dataset")
evaluator = EmbeddingSimilarityEvaluator.from_input_examples(dev_samples, name='sts-dev')
# Configure the training. We skip evaluation in this example
warmup_steps = math.ceil(len(train_dataloader) * num_epochs * 0.1) #10% of train data for warm-up
logging.info("Warmup-steps: {}".format(warmup_steps))
# Train the model
model.fit(train_objectives=[(train_dataloader, train_loss)],
evaluator=evaluator,
epochs=num_epochs,
evaluation_steps=1000,
warmup_steps=warmup_steps,
output_path=model_save_path)
##############################################################################
#
# Load the stored model and evaluate its performance on STS benchmark dataset
#
##############################################################################
model = SentenceTransformer(model_save_path)
test_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(test_samples, name='sts-test')
test_evaluator(model, output_path=model_save_path)<|fim▁end|> | util.http_get('https://sbert.net/datasets/stsbenchmark.tsv.gz', sts_dataset_path) |
<|file_name|>training_stsbenchmark_continue_training.py<|end_file_name|><|fim▁begin|>"""
This example loads the pre-trained SentenceTransformer model 'nli-distilroberta-base-v2' from the server.
It then fine-tunes this model for some epochs on the STS benchmark dataset.
Note: In this example, you must specify a SentenceTransformer model.
If you want to fine-tune a huggingface/transformers model like bert-base-uncased, see training_nli.py and training_stsbenchmark.py
"""
from torch.utils.data import DataLoader
import math
from sentence_transformers import SentenceTransformer, LoggingHandler, losses, util, InputExample
from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator
import logging
from datetime import datetime
import os
import gzip
import csv
#### Just some code to print debug information to stdout
logging.basicConfig(format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
level=logging.INFO,
handlers=[LoggingHandler()])
#### /print debug information to stdout
#Check if dataset exsist. If not, download and extract it
sts_dataset_path = 'datasets/stsbenchmark.tsv.gz'
if not os.path.exists(sts_dataset_path):
util.http_get('https://sbert.net/datasets/stsbenchmark.tsv.gz', sts_dataset_path)
# Read the dataset
model_name = 'nli-distilroberta-base-v2'
train_batch_size = 16
num_epochs = 4
model_save_path = 'output/training_stsbenchmark_continue_training-'+model_name+'-'+datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
# Load a pre-trained sentence transformer model
model = SentenceTransformer(model_name)
# Convert the dataset to a DataLoader ready for training
logging.info("Read STSbenchmark train dataset")
train_samples = []
dev_samples = []
test_samples = []
with gzip.open(sts_dataset_path, 'rt', encoding='utf8') as fIn:
reader = csv.DictReader(fIn, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in reader:
score = float(row['score']) / 5.0 # Normalize score to range 0 ... 1
inp_example = InputExample(texts=[row['sentence1'], row['sentence2']], label=score)
if row['split'] == 'dev':
<|fim_middle|>
elif row['split'] == 'test':
test_samples.append(inp_example)
else:
train_samples.append(inp_example)
train_dataloader = DataLoader(train_samples, shuffle=True, batch_size=train_batch_size)
train_loss = losses.CosineSimilarityLoss(model=model)
# Development set: Measure correlation between cosine score and gold labels
logging.info("Read STSbenchmark dev dataset")
evaluator = EmbeddingSimilarityEvaluator.from_input_examples(dev_samples, name='sts-dev')
# Configure the training. We skip evaluation in this example
warmup_steps = math.ceil(len(train_dataloader) * num_epochs * 0.1) #10% of train data for warm-up
logging.info("Warmup-steps: {}".format(warmup_steps))
# Train the model
model.fit(train_objectives=[(train_dataloader, train_loss)],
evaluator=evaluator,
epochs=num_epochs,
evaluation_steps=1000,
warmup_steps=warmup_steps,
output_path=model_save_path)
##############################################################################
#
# Load the stored model and evaluate its performance on STS benchmark dataset
#
##############################################################################
model = SentenceTransformer(model_save_path)
test_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(test_samples, name='sts-test')
test_evaluator(model, output_path=model_save_path)<|fim▁end|> | dev_samples.append(inp_example) |
<|file_name|>training_stsbenchmark_continue_training.py<|end_file_name|><|fim▁begin|>"""
This example loads the pre-trained SentenceTransformer model 'nli-distilroberta-base-v2' from the server.
It then fine-tunes this model for some epochs on the STS benchmark dataset.
Note: In this example, you must specify a SentenceTransformer model.
If you want to fine-tune a huggingface/transformers model like bert-base-uncased, see training_nli.py and training_stsbenchmark.py
"""
from torch.utils.data import DataLoader
import math
from sentence_transformers import SentenceTransformer, LoggingHandler, losses, util, InputExample
from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator
import logging
from datetime import datetime
import os
import gzip
import csv
#### Just some code to print debug information to stdout
logging.basicConfig(format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
level=logging.INFO,
handlers=[LoggingHandler()])
#### /print debug information to stdout
#Check if dataset exsist. If not, download and extract it
sts_dataset_path = 'datasets/stsbenchmark.tsv.gz'
if not os.path.exists(sts_dataset_path):
util.http_get('https://sbert.net/datasets/stsbenchmark.tsv.gz', sts_dataset_path)
# Read the dataset
model_name = 'nli-distilroberta-base-v2'
train_batch_size = 16
num_epochs = 4
model_save_path = 'output/training_stsbenchmark_continue_training-'+model_name+'-'+datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
# Load a pre-trained sentence transformer model
model = SentenceTransformer(model_name)
# Convert the dataset to a DataLoader ready for training
logging.info("Read STSbenchmark train dataset")
train_samples = []
dev_samples = []
test_samples = []
with gzip.open(sts_dataset_path, 'rt', encoding='utf8') as fIn:
reader = csv.DictReader(fIn, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in reader:
score = float(row['score']) / 5.0 # Normalize score to range 0 ... 1
inp_example = InputExample(texts=[row['sentence1'], row['sentence2']], label=score)
if row['split'] == 'dev':
dev_samples.append(inp_example)
elif row['split'] == 'test':
<|fim_middle|>
else:
train_samples.append(inp_example)
train_dataloader = DataLoader(train_samples, shuffle=True, batch_size=train_batch_size)
train_loss = losses.CosineSimilarityLoss(model=model)
# Development set: Measure correlation between cosine score and gold labels
logging.info("Read STSbenchmark dev dataset")
evaluator = EmbeddingSimilarityEvaluator.from_input_examples(dev_samples, name='sts-dev')
# Configure the training. We skip evaluation in this example
warmup_steps = math.ceil(len(train_dataloader) * num_epochs * 0.1) #10% of train data for warm-up
logging.info("Warmup-steps: {}".format(warmup_steps))
# Train the model
model.fit(train_objectives=[(train_dataloader, train_loss)],
evaluator=evaluator,
epochs=num_epochs,
evaluation_steps=1000,
warmup_steps=warmup_steps,
output_path=model_save_path)
##############################################################################
#
# Load the stored model and evaluate its performance on STS benchmark dataset
#
##############################################################################
model = SentenceTransformer(model_save_path)
test_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(test_samples, name='sts-test')
test_evaluator(model, output_path=model_save_path)<|fim▁end|> | test_samples.append(inp_example) |
<|file_name|>training_stsbenchmark_continue_training.py<|end_file_name|><|fim▁begin|>"""
This example loads the pre-trained SentenceTransformer model 'nli-distilroberta-base-v2' from the server.
It then fine-tunes this model for some epochs on the STS benchmark dataset.
Note: In this example, you must specify a SentenceTransformer model.
If you want to fine-tune a huggingface/transformers model like bert-base-uncased, see training_nli.py and training_stsbenchmark.py
"""
from torch.utils.data import DataLoader
import math
from sentence_transformers import SentenceTransformer, LoggingHandler, losses, util, InputExample
from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator
import logging
from datetime import datetime
import os
import gzip
import csv
#### Just some code to print debug information to stdout
logging.basicConfig(format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
level=logging.INFO,
handlers=[LoggingHandler()])
#### /print debug information to stdout
#Check if dataset exsist. If not, download and extract it
sts_dataset_path = 'datasets/stsbenchmark.tsv.gz'
if not os.path.exists(sts_dataset_path):
util.http_get('https://sbert.net/datasets/stsbenchmark.tsv.gz', sts_dataset_path)
# Read the dataset
model_name = 'nli-distilroberta-base-v2'
train_batch_size = 16
num_epochs = 4
model_save_path = 'output/training_stsbenchmark_continue_training-'+model_name+'-'+datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
# Load a pre-trained sentence transformer model
model = SentenceTransformer(model_name)
# Convert the dataset to a DataLoader ready for training
logging.info("Read STSbenchmark train dataset")
train_samples = []
dev_samples = []
test_samples = []
with gzip.open(sts_dataset_path, 'rt', encoding='utf8') as fIn:
reader = csv.DictReader(fIn, delimiter='\t', quoting=csv.QUOTE_NONE)
for row in reader:
score = float(row['score']) / 5.0 # Normalize score to range 0 ... 1
inp_example = InputExample(texts=[row['sentence1'], row['sentence2']], label=score)
if row['split'] == 'dev':
dev_samples.append(inp_example)
elif row['split'] == 'test':
test_samples.append(inp_example)
else:
<|fim_middle|>
train_dataloader = DataLoader(train_samples, shuffle=True, batch_size=train_batch_size)
train_loss = losses.CosineSimilarityLoss(model=model)
# Development set: Measure correlation between cosine score and gold labels
logging.info("Read STSbenchmark dev dataset")
evaluator = EmbeddingSimilarityEvaluator.from_input_examples(dev_samples, name='sts-dev')
# Configure the training. We skip evaluation in this example
warmup_steps = math.ceil(len(train_dataloader) * num_epochs * 0.1) #10% of train data for warm-up
logging.info("Warmup-steps: {}".format(warmup_steps))
# Train the model
model.fit(train_objectives=[(train_dataloader, train_loss)],
evaluator=evaluator,
epochs=num_epochs,
evaluation_steps=1000,
warmup_steps=warmup_steps,
output_path=model_save_path)
##############################################################################
#
# Load the stored model and evaluate its performance on STS benchmark dataset
#
##############################################################################
model = SentenceTransformer(model_save_path)
test_evaluator = EmbeddingSimilarityEvaluator.from_input_examples(test_samples, name='sts-test')
test_evaluator(model, output_path=model_save_path)<|fim▁end|> | train_samples.append(inp_example) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
<|fim▁hole|> items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))<|fim▁end|> | if __name__ == "__main__": |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
<|fim_middle|>
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
<|fim_middle|>
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__artist = artist
self.__title = title
self.__year = year |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
<|fim_middle|>
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | return self.__artist |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
<|fim_middle|>
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__artist = artist |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
<|fim_middle|>
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | return self.__title |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
<|fim_middle|>
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__title = title |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
<|fim_middle|>
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | return self.__year |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
<|fim_middle|>
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__year = year |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
<|fim_middle|>
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
<|fim_middle|>
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
<|fim_middle|>
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | super(Painting, self).__init__(artist, title, year) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
<|fim_middle|>
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
<|fim_middle|>
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | super(Sculpture, self).__init__(artist, title, year)
self.__material = material |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
<|fim_middle|>
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | return self.__material |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
<|fim_middle|>
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__material = material |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
<|fim_middle|>
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
<|fim_middle|>
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
<|fim_middle|>
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__width = width
self.__height = height
self.__depth = depth |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
<|fim_middle|>
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | return self.__width |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
<|fim_middle|>
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__width = width |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
<|fim_middle|>
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | return self.__height |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
<|fim_middle|>
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__height = height |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
<|fim_middle|>
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | return self.__depth |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
<|fim_middle|>
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | self.__depth = depth |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
<|fim_middle|>
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | raise NotImplemented |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
<|fim_middle|>
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | raise NotImplemented |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
<|fim_middle|>
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | year = " in {0}".format(self.__year) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
<|fim_middle|>
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | materialString = " ({0})".format(self.__material) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
<|fim_middle|>
<|fim▁end|> | items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials))) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
<|fim_middle|>
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | uniquematerials.add(item.material()) |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def <|fim_middle|>(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | __init__ |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def <|fim_middle|>(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | artist |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def <|fim_middle|>(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | setArtist |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def <|fim_middle|>(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | title |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def <|fim_middle|>(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | setTitle |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def <|fim_middle|>(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | year |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def <|fim_middle|>(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | setYear |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def <|fim_middle|>(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | __str__ |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def <|fim_middle|>(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | __init__ |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def <|fim_middle|>(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | __init__ |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def <|fim_middle|>(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | material |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def <|fim_middle|>(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | setMaterial |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def <|fim_middle|>(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | __str__ |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def <|fim_middle|>(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | __init__ |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def <|fim_middle|>(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | width |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def <|fim_middle|>(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | setWidth |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def <|fim_middle|>(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | height |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def <|fim_middle|>(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | setHeight |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def <|fim_middle|>(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | depth |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def <|fim_middle|>(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | setDepth |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def <|fim_middle|>(self):
raise NotImplemented
def volume(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | area |
<|file_name|>item.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3
# Copyright (c) 2008-9 Qtrac Ltd. All rights reserved.
# This program or module is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 2 of the License, or
# version 3 of the License, or (at your option) any later version. It is
# provided for educational purposes and is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
"""Provides the Item example classes.
"""
class Item(object):
def __init__(self, artist, title, year=None):
self.__artist = artist
self.__title = title
self.__year = year
def artist(self):
return self.__artist
def setArtist(self, artist):
self.__artist = artist
def title(self):
return self.__title
def setTitle(self, title):
self.__title = title
def year(self):
return self.__year
def setYear(self, year):
self.__year = year
def __str__(self):
year = ""
if self.__year is not None:
year = " in {0}".format(self.__year)
return "{0} by {1}{2}".format(self.__title, self.__artist, year)
class Painting(Item):
def __init__(self, artist, title, year=None):
super(Painting, self).__init__(artist, title, year)
class Sculpture(Item):
def __init__(self, artist, title, year=None, material=None):
super(Sculpture, self).__init__(artist, title, year)
self.__material = material
def material(self):
return self.__material
def setMaterial(self, material):
self.__material = material
def __str__(self):
materialString = ""
if self.__material is not None:
materialString = " ({0})".format(self.__material)
return "{0}{1}".format(super(Sculpture, self).__str__(),
materialString)
class Dimension(object):
def __init__(self, width, height, depth=None):
self.__width = width
self.__height = height
self.__depth = depth
def width(self):
return self.__width
def setWidth(self, width):
self.__width = width
def height(self):
return self.__height
def setHeight(self, height):
self.__height = height
def depth(self):
return self.__depth
def setDepth(self, depth):
self.__depth = depth
def area(self):
raise NotImplemented
def <|fim_middle|>(self):
raise NotImplemented
if __name__ == "__main__":
items = []
items.append(Painting("Cecil Collins", "The Poet", 1941))
items.append(Painting("Cecil Collins", "The Sleeping Fool", 1943))
items.append(Painting("Edvard Munch", "The Scream", 1893))
items.append(Painting("Edvard Munch", "The Sick Child", 1896))
items.append(Painting("Edvard Munch", "The Dance of Life", 1900))
items.append(Sculpture("Auguste Rodin", "Eternal Springtime", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "Naked Balzac", 1917,
"plaster"))
items.append(Sculpture("Auguste Rodin", "The Secret", 1925,
"bronze"))
uniquematerials = set()
for item in items:
print(item)
if hasattr(item, "material"):
uniquematerials.add(item.material())
print("Sculptures use {0} unique materials".format(
len(uniquematerials)))
<|fim▁end|> | volume |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
<|fim▁hole|> """Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]<|fim▁end|> | def get_html_tag(markup): |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
<|fim_middle|>
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | """Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup] |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
<|fim_middle|>
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | """Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
<|fim_middle|>
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | """Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
<|fim_middle|>
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | """Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
<|fim_middle|>
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | """Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
<|fim_middle|>
<|fim▁end|> | """Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme] |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
<|fim_middle|>
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | return scheme in URI_SCHEMES |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def <|fim_middle|>(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | get_html_tag |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def <|fim_middle|>(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | is_parsable |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def <|fim_middle|>(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | is_visible |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def <|fim_middle|>(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | is_single |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def <|fim_middle|>(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def is_scheme(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | is_single_only |
<|file_name|>definitions.py<|end_file_name|><|fim▁begin|># Copyright (C) 2012-2020 Ben Kurtovic <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Contains data about certain markup, like HTML tags and external links.
When updating this file, please also update the the C tokenizer version:
- mwparserfromhell/parser/ctokenizer/definitions.c
- mwparserfromhell/parser/ctokenizer/definitions.h
"""
__all__ = [
"get_html_tag",
"is_parsable",
"is_visible",
"is_single",
"is_single_only",
"is_scheme",
]
URI_SCHEMES = {
# [wikimedia/mediawiki.git]/includes/DefaultSettings.php @ 5c660de5d0
"bitcoin": False,
"ftp": True,
"ftps": True,
"geo": False,
"git": True,
"gopher": True,
"http": True,
"https": True,
"irc": True,
"ircs": True,
"magnet": False,
"mailto": False,
"mms": True,
"news": False,
"nntp": True,
"redis": True,
"sftp": True,
"sip": False,
"sips": False,
"sms": False,
"ssh": True,
"svn": True,
"tel": False,
"telnet": True,
"urn": False,
"worldwind": True,
"xmpp": False,
}
PARSER_BLACKLIST = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"ce",
"chem",
"gallery",
"graph",
"hiero",
"imagemap",
"inputbox",
"math",
"nowiki",
"pre",
"score",
"section",
"source",
"syntaxhighlight",
"templatedata",
"timeline",
]
INVISIBLE_TAGS = [
# https://www.mediawiki.org/wiki/Parser_extension_tags @ 2020-12-21
"categorytree",
"gallery",
"graph",
"imagemap",
"inputbox",
"math",
"score",
"section",
"templatedata",
"timeline",
]
# [wikimedia/mediawiki.git]/includes/parser/Sanitizer.php @ 95e17ee645
SINGLE_ONLY = ["br", "wbr", "hr", "meta", "link", "img"]
SINGLE = SINGLE_ONLY + ["li", "dt", "dd", "th", "td", "tr"]
MARKUP_TO_HTML = {
"#": "li",
"*": "li",
";": "dt",
":": "dd",
}
def get_html_tag(markup):
"""Return the HTML tag associated with the given wiki-markup."""
return MARKUP_TO_HTML[markup]
def is_parsable(tag):
"""Return if the given *tag*'s contents should be passed to the parser."""
return tag.lower() not in PARSER_BLACKLIST
def is_visible(tag):
"""Return whether or not the given *tag* contains visible text."""
return tag.lower() not in INVISIBLE_TAGS
def is_single(tag):
"""Return whether or not the given *tag* can exist without a close tag."""
return tag.lower() in SINGLE
def is_single_only(tag):
"""Return whether or not the given *tag* must exist without a close tag."""
return tag.lower() in SINGLE_ONLY
def <|fim_middle|>(scheme, slashes=True):
"""Return whether *scheme* is valid for external links."""
scheme = scheme.lower()
if slashes:
return scheme in URI_SCHEMES
return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
<|fim▁end|> | is_scheme |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.