Skip to content

Commit

Permalink
Merge pull request #33 from Catrobat/develop
Browse files Browse the repository at this point in the history
Release v0.8.0
  • Loading branch information
rsamer authored Feb 16, 2017
2 parents 68ebeba + 7bc759c commit 83be30d
Show file tree
Hide file tree
Showing 11 changed files with 815 additions and 121 deletions.
6 changes: 3 additions & 3 deletions config/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
[APPLICATION]
name: Scratch2Catrobat Converter
short_name: S2CC
version: 0.7.2
version: 0.8.0
build_name: Aegean cat
build_number: 747
build_number: 812-develop

;-------------------------------------------------------------------------------
[CATROBAT]
Expand Down Expand Up @@ -124,7 +124,7 @@ password:

;-------------------------------------------------------------------------------
[CONVERTER_JOB]
max_num_scheduled_jobs_per_client: 5
max_num_scheduled_jobs_per_client: 3
auth_key: __TODO:_INSERT_YOUR_CLIENT_KEY_HERE__

listening_queues.1.name: high
Expand Down
Binary file modified lib/catroid_class_hierarchy.jar
Binary file not shown.
8 changes: 6 additions & 2 deletions sourcecodefilter/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ class_to_preserved_methods_mapping:
- addScript
- updateUserVariableReferencesInUserVariableBricks
- getListWithAllBricks
- addUserBrick
UserVariablesContainer:
- addSpriteUserVariableToSprite
- getOrCreateVariableListForSprite
Expand Down Expand Up @@ -591,8 +592,12 @@ class_to_preserved_methods_mapping:
- updateUserBrickParametersAndVariables
- updateUserVariableValues
- updateUserBrickParameters
- appendBrickToScript
UserScriptDefinitionBrick:
- setUserBrick
- appendBrickToScript
- getScriptSafe
- getUserScript
UserScriptDefinitionBrickElement:
- getUserScriptDefinitionBrickElementList
- isVariable
Expand All @@ -603,6 +608,7 @@ class_to_preserved_methods_mapping:
- spriteExists
XmlHeader:
- setlandscapeMode
- setUrl
NfcTagData:
- compareTo
WhenBackgroundChangesScript:
Expand Down Expand Up @@ -635,8 +641,6 @@ remove_methods_mapping:
- setCommentedOut
XStreamToSupportCatrobatLanguageVersion0991AndBefore:
- updateCollisionReceiverBrickMessage
UserScriptDefinitionBrick:
- appendBrickToScript
Sprite:
- cloneUserBricks
Script:
Expand Down
1 change: 1 addition & 0 deletions src/scratchtocatrobat/converter/catrobat.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

_log = common.log


def simple_name_for(brick):
if isinstance(brick, (list, tuple)):
return map(simple_name_for, brick)
Expand Down
352 changes: 308 additions & 44 deletions src/scratchtocatrobat/converter/converter.py

Large diffs are not rendered by default.

433 changes: 415 additions & 18 deletions src/scratchtocatrobat/converter/test_converter.py

Large diffs are not rendered by default.

36 changes: 19 additions & 17 deletions src/scratchtocatrobat/scratch/scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def replace_timer_blocks(block_list):

for script in self.scripts:
if has_timer_reset_block(script.blocks): workaround_info[ADD_TIMER_RESET_SCRIPT_KEY] = True
if has_timer_block(script.blocks): workaround_info[ADD_TIMER_SCRIPT_KEY] = True
if has_timer_block(script.blocks) or 'timer' in script.arguments: workaround_info[ADD_TIMER_SCRIPT_KEY] = True

script.blocks = replace_timer_blocks(script.blocks)

# parse again ScriptElement tree
# rebuild ScriptElement tree
script.script_element = ScriptElement.from_raw_block(script.blocks)

############################################################################################
Expand Down Expand Up @@ -383,7 +383,7 @@ class Project(RawProject):
Represents a complete Scratch project including all resource files.
"""

def __init__(self, project_base_path, name=None, id_=None, progress_bar=None):
def __init__(self, project_base_path, name=None, project_id=None, progress_bar=None):
def read_md5_to_resource_path_mapping():
md5_to_resource_path_map = {}
# TODO: clarify that only files with extension are covered
Expand All @@ -401,11 +401,7 @@ def read_md5_to_resource_path_mapping():

super(Project, self).__init__(self.raw_project_code_from_project_folder_path(project_base_path))
self.project_base_path = project_base_path

if id_ != None:
self.project_id = id_
else:
self.project_id = self.get_info().get("projectID")
self.project_id = self.get_info().get("projectID") if project_id is None else project_id

if not self.project_id:
self.project_id = "0"
Expand Down Expand Up @@ -474,7 +470,13 @@ class Script(object):
def __init__(self, script_input):
if not self.is_valid_script_input(script_input):
raise ScriptError("Input is no valid Scratch script.")
self.raw_script = script_input[2] # TODO: remove this...

self.raw_script = script_input[2]
self.type = self.raw_script[0][0]

if self.type not in SCRIPTS:
raise ScriptError("Unknown Scratch script type: {}".format(self.type))

script_block, self.blocks = self.raw_script[0], self.raw_script[1:]
if not self.blocks:
_log.debug("Empty script: %s", script_input)
Expand All @@ -485,14 +487,12 @@ def __init__(self, script_input):

self.script_element = ScriptElement.from_raw_block(self.blocks)
assert isinstance(self.script_element, BlockList)
self.type, self.arguments = script_block[0], script_block[1:]
# FIXME: never reached as is_valid_script_input() fails before
if self.type not in SCRIPTS:
raise ScriptError("Unknown Scratch script type: {}".format(self.type))
self.arguments = script_block[1:]

@classmethod
def is_valid_script_input(cls, json_input):
if (isinstance(json_input, list) and len(json_input) == 3 and all(isinstance(positional_value, (int, float)) for positional_value in json_input[0:2]) and isinstance(json_input[2], list)):
are_all_positional_values_numbers = all(isinstance(positional_value, (int, float)) for positional_value in json_input[0:2])
if (isinstance(json_input, list) and len(json_input) == 3 and are_all_positional_values_numbers and isinstance(json_input[2], list)):
# NOTE: could use a json validator instead
script_content = json_input[2]
if script_content[0][0] in SCRIPTS:
Expand Down Expand Up @@ -580,10 +580,12 @@ def add(self, first, *arguments):
def __iter__(self):
return iter(self.children)

def prettyprint(self, indent="", file_=sys.stdout):
print("{} {}".format(indent, self.name), file=file_)
def prettyprint(self, verbose=False, indent="", file_=sys.stdout):
label = "<{}>\n{} {}\n".format(self.__class__.__name__.upper(), indent, self.name) if verbose else self.name
label = self.name + ("\n" if verbose else "") if isinstance(self, BlockList) else label
print("{} {}".format(indent, label), file=file_)
for child in self:
child.prettyprint(indent + " ", file_=file_)
child.prettyprint(verbose, (indent + " "), file_=file_)

def __repr__(self):
return "%s(%r)" % (self.__class__, self.__dict__)
Expand Down
4 changes: 2 additions & 2 deletions src/scratchtocatrobat/scratch/test_scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_can_extract_project(self):

class TestProjectInit(unittest.TestCase):
def test_can_construct_on_correct_input(self):
assert scratch.Project(common_testing.get_test_project_path("simple"), name="dummy", id_=common_testing.PROJECT_DUMMY_ID)
assert scratch.Project(common_testing.get_test_project_path("simple"), name="dummy", project_id=common_testing.PROJECT_DUMMY_ID)

def test_fail_on_non_existing_input_path(self):
with self.assertRaises(EnvironmentError):
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_can_access_listened_pressed_keys(self):
assert project.listened_keys == set(["d", "c", "a", "4", "8"])

def test_can_access_unused_resources_of_project(self):
project = scratch.Project(common_testing.get_test_project_path("simple"), name="simple", id_=common_testing.PROJECT_DUMMY_ID)
project = scratch.Project(common_testing.get_test_project_path("simple"), name="simple", project_id=common_testing.PROJECT_DUMMY_ID)
assert len(project.unused_resource_paths) > 0
expected_resources = ['0.png', '2.wav', '3.png', '4.png', '5.png', '6.png', '8.png']
assert set(map(os.path.basename, project.unused_resource_paths)) == set(expected_resources)
Expand Down
8 changes: 4 additions & 4 deletions src/scratchtocatrobat/scratch/test_scratchwebapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
}

TEST_PROJECT_ID_TO_IMAGE_URL_MAP = {
"10205819": "https://cdn2.scratch.mit.edu/get_image/project/10205819_144x108.png?v=1368470695.0",
"10132588": "https://cdn2.scratch.mit.edu/get_image/project/10132588_144x108.png?v=1368129031.0",
"2365565" : "https://cdn2.scratch.mit.edu/get_image/project/2365565_144x108.png?v=1368072082.0",
"117300839": "https://cdn2.scratch.mit.edu/get_image/project/117300839_144x108.png?v=1469765618.94"
"10205819": "https://cdn2.scratch.mit.edu/get_image/project/10205819_144x108.png",
"10132588": "https://cdn2.scratch.mit.edu/get_image/project/10132588_144x108.png",
"2365565" : "https://cdn2.scratch.mit.edu/get_image/project/2365565_144x108.png",
"117300839": "https://cdn2.scratch.mit.edu/get_image/project/117300839_144x108.png"
}

TEST_PROJECT_ID_TO_OWNER_MAP = {
Expand Down
59 changes: 29 additions & 30 deletions web/certificates/server.crt
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
-----BEGIN CERTIFICATE-----
MIIFrjCCA5YCCQCtJXm8OtyL3TANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMC
MIIFjDCCA3QCCQDYiT4cqlExVTANBgkqhkiG9w0BAQsFADCBhzELMAkGA1UEBhMC
QVQxEDAOBgNVBAgMB0F1c3RyaWExDTALBgNVBAcMBEdyYXoxETAPBgNVBAoMCENh
dHJvYmF0MSwwKgYDVQQDDCNjYXRyb2JhdC1zY3JhdGNoMi5pc3QudHUtZ3Jhei5h
Yy5hdDEnMCUGCSqGSIb3DQEJARYYd29sZmdhbmcuc2xhbnlAdHVncmF6LmF0MB4X
DTE1MTIyNjE4MzM0NloXDTE2MTIyNTE4MzM0NlowgZgxCzAJBgNVBAYTAkFUMRAw
DgYDVQQIDAdBdXN0cmlhMQ0wCwYDVQQHDARHcmF6MREwDwYDVQQKDAhDYXRyb2Jh
dDEsMCoGA1UEAwwjY2F0cm9iYXQtc2NyYXRjaDIuaXN0LnR1LWdyYXouYWMuYXQx
JzAlBgkqhkiG9w0BCQEWGHdvbGZnYW5nLnNsYW55QHR1Z3Jhei5hdDCCAiIwDQYJ
KoZIhvcNAQEBBQADggIPADCCAgoCggIBAKvb3nNm+EYmSycr6NWDqHvquEN7MQyQ
MkJMjpz4ut+4bjfygG9vb/VDmDUIOubO9mQA2iYZDnQraWvnEydYxbUcIP1A5Ukv
7VMBiQyoGFnIsEnNWASpyvFt0RMBveml2vIb5TpRYZvR4ESKiJ4MAiReTLkLIoUo
mlH68aR8CdlSaNJgXu7dDu/IC+qkXkDX2ZxwtAayb0bIw0oVNUaLt10yfuxYNoXk
/Z2bX5RZ6QxGdNsTUx1cUsmRvkfDSYBV6aFt/4OPCGsZBl5C59PQwVdS/cM0WArK
frOSWFGhCy8G/rVJlnCyKf+W+HWuNrBFn6yVJ/wDYTTLWMq7aHZtn9+wk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orNLWel7k/B6cCAwEAATANBgkqhkiG9w0BAQsFAAOCAgEA
fMszl3bqZrKkYjzOrqfiwLXFH9D/5Om9QNBMYhn1hYhctSmmCq4olu7MUc/vFD7f
82dPTzbo3oWdgrW0aNmMMUJNeW0kpTEBXf1k96IfjF9CSTLJxIx7P1eXCS7cQESM
BidiSOptYol1pIpFSbcNvxFst7ZWSbPS6vNqMw0l26Q1q7wdcLR4e2kvWPd0rXgH
kI0WnhCTUfeS+1bAgB7PBjwDQlht4JA1c1eorql31RpVrif1JXbaNFP/eWooga6i
+ufJA3vGA5DuHI9nFB+IT7cqJF3qdtARhUYMRmebMUjbEnZOsQw9bj4BQaYGBt4d
1Y/wA4Gf6kNKg0p3JAESs3B9tBeiqpDJsNtUiLpGrBKrxqgalBzTXnzPDGYXH+co
uvMwahkfthVhHGY8J2EMShvPpOGOTO8Qboea/1P5JOlZIhccrBK4Img9jwJIKwwv
jnu6w6GXYMkitdPYnNy5ulXzbFGKOKqYd66mWsPXpJ29ew/j31RgL9N9Ye5ulGMj
6TdmNA7xsrGCXSzosx0A9NVNwGUATcSU7JnssJBYXn6kDKkFG39a1P90leKd+on+
5Mm6MBC5DEkfeLUHhIlbNDvmXIHi1/Usw3H4degagA8/uERDB5r73HKExkQTt0Rb
DpEX5tIMsK3Oh9mC+iWMGW+XXc4GY8CTXC/jSfW3Pkk=
-----END CERTIFICATE-----
29 changes: 28 additions & 1 deletion web/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
REDIS_JOB_CLIENT_KEY_TEMPLATE = "jobsOfClient#{}"


# TODO: remove theses data of default programs and fetch/update dynamically
# TODO: remove this data of default programs and fetch/update dynamically
FEATURED_SCRATCH_PROGRAMS = [{
"id": 11656680,
"title": "Dress Up Tera",
Expand All @@ -54,6 +54,33 @@
"remix": {
"root": 10007164
}
}, {
"id": 12297764,
"title": "Full 8 Frame Felipebross Walk Cycle",
"description": "",
"instructions": "After a couple of months work he&#39;s now ready to use in his own game! " \
"follow this link: http://beta.scratch.mit.edu/projects/10118230\n\nWant an " \
"animating Steve from Minecraft? Take a look here: " \
"http://scratch.mit.edu/projects/10128407/",
"author": {
"id": 2542801,
"username": "TheFroster"
},
"image": "https://cdn2.scratch.mit.edu/get_image/project/12297764_480x360.png",
"history": {
"created": "2013-09-11T00:13:19.000Z",
"modified": "2013-09-11T00:15:50.000Z",
"shared": "2013-09-11T00:13:49.000Z"
},
"stats": {
"views":154,
"loves":1,
"favorites":2,
"comments":0
},
"remix": {
"root": 10045024
}
}, {
"id": 82443924,
"title": "Speed Drawing: Nessie (original species)",
Expand Down

0 comments on commit 83be30d

Please sign in to comment.