Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
css parser uses bulk_create to store properties
Browse files Browse the repository at this point in the history
  • Loading branch information
maurodoglio committed Apr 22, 2013
1 parent 86bb33a commit 81afaa3
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions spade/utils/cssparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def parse_rule(self, rule):

return (selector_string, properties_dict)


def parse(self, linkedcss):
"""
Calls parse on the internal CSS, stores css properties into db model
Expand All @@ -58,17 +57,12 @@ def parse(self, linkedcss):

# Create CSS rule in model
current_rule = model.CSSRule.objects.create(linkedcss=linkedcss,
selector=selector)

for property in properties:
prefix = properties[property][0]
unprefixed_name = properties[property][1]
value = properties[property][2]

# Create CSSProperty object for each property belonging to the
# rule
model.CSSProperty.objects.create(
rule=current_rule, prefix=prefix, name=unprefixed_name,
value=value)
selector=selector)

return True
model.CSSProperty.objects.bulk_create(
[model.CSSProperty(
rule=current_rule,
prefix=v[0],
name=v[1],
value=v[2]) for v in properties.values()]
)

0 comments on commit 81afaa3

Please sign in to comment.