4545from distutils .version import LooseVersion
4646from xml .etree import ElementTree as etree
4747
48- from .bolt import Path
48+ from . import bush
49+ from .bolt import GPath
4950from .load_order import cached_is_active
5051
5152__author__ = "Ganda"
@@ -194,7 +195,7 @@ def process_files(cls, files_elem, file_list):
194195 source = file_object .get ("source" )
195196 if source .endswith (("/" , "\\ " )):
196197 source = source [:- 1 ]
197- source = Path (source )
198+ source = GPath (source )
198199 destination = file_object .get ("destination" , None )
199200 if destination is None : # omitted destination
200201 destination = source
@@ -204,10 +205,10 @@ def process_files(cls, files_elem, file_list):
204205 # if empty or with a trailing slash then dest refers
205206 # to a folder. Post-processing to add the filename to the
206207 # end of the path.
207- destination = Path (destination ).join (Path (source ).tail )
208+ destination = GPath (destination ).join (GPath (source ).tail )
208209 else :
209210 # destination still needs normalizing
210- destination = Path (destination )
211+ destination = GPath (destination )
211212 priority = int (file_object .get ("priority" , "0" ))
212213 for fname in file_list :
213214 if fname .lower () == source .s .lower (): # it's a file
@@ -217,7 +218,7 @@ def process_files(cls, files_elem, file_list):
217218 fdest = destination .s + fname [source_len :]
218219 if fdest .startswith (os .sep ):
219220 fdest = fdest [1 :]
220- result .append (cls (Path (fname ), Path (fdest ), priority ))
221+ result .append (cls (GPath (fname ), GPath (fdest ), priority ))
221222 return result
222223
223224
@@ -363,13 +364,17 @@ def _flags(self):
363364 return flag_dict
364365
365366 def _test_file_condition (self , condition ):
366- file_name = condition .get ("file" )
367+ file_name = GPath ( condition .get ("file" ) )
367368 file_type = condition .get ("state" )
368- file_path = self . dst_dir . join ( file_name )
369- if not file_path . exists (): # TODO: ghosts?
369+ # Check if it's missing, ghosted or (in)active
370+ if not self . dst_dir . join ( file_name ). exists ():
370371 actual_type = "Missing"
372+ elif (file_name .cext in bush .game .espm_extensions and
373+ self .dst_dir .join (file_name + u'.ghost' ).exists ()):
374+ actual_type = 'Inactive'
371375 else :
372- actual_type = "Active" if cached_is_active (file_name ) else "Inactive"
376+ actual_type = ("Active" if cached_is_active (file_name )
377+ else "Inactive" )
373378 if actual_type != file_type :
374379 raise FailedCondition (
375380 "File {} should be {} but is {} instead." .format (
0 commit comments