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

Commit

Permalink
long-form-exposing matching
Browse files Browse the repository at this point in the history
  • Loading branch information
eeue56 committed May 5, 2016
1 parent 7215871 commit 812b168
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions update_elm_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,25 @@
import os
import glob

module_pattern = r'module\s+?(\S+)\s*?(.*?)\s+?where'
module_ident = 'module'
space_before_module_name = '\\s+'
module_name = '(\\S+)'
space_between_name_and_expose = '\\s+?'
expose = '(.*?)'
space_between_expose_and_where = '\\s+?'
where_ident = 'where'


module_pattern = ''.join(
[ module_ident
, space_before_module_name
, module_name
, space_between_name_and_expose
, expose
, space_between_expose_and_where
, where_ident
]
)

KNOWN_MOVES = {
'evancz/elm-html' : 'elm-lang/html'
Expand All @@ -31,15 +49,16 @@ def upgrade_module_syntax(module_name, exposing):

if not exposing:
exposing = '(..)'
#print(exposing)

return 'module {name} exposing {exposing}'.format(name=module_name, exposing=exposing)


def replace_module_line(text, replacement):
return re.sub(module_pattern, replacement, text, count=1)
return re.sub(module_pattern, replacement, text, count=1, flags=re.MULTILINE | re.DOTALL)

def get_module_name_and_exposing(text):
matches = re.search(module_pattern, text)
matches = re.search(module_pattern, text, flags=re.MULTILINE | re.DOTALL)

if not matches:
return ('', '')
Expand Down

0 comments on commit 812b168

Please sign in to comment.