summaryrefslogtreecommitdiff
path: root/src/projManagement/Validation.py
blob: a3d84979311ee8c6fd3036cd565a48af5db97c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89

#===============================================================================
#
#          FILE: Validation.py
# 
#         USAGE: --- 
# 
#   DESCRIPTION: This module is use to create validation for openProject,newProject and other activity. 
# 
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Fahim Khan, fahim.elex@gmail.com
#  ORGANIZATION: eSim team at FOSSEE, IIT Bombay.
#       CREATED: Wednesday 12 February 2015 
#      REVISION:  ---
#===============================================================================
import os
import re 


class Validation:
    """
    This is Validation class use for validating Project.
    e.g if .proj is present in project directory
    or if new project name is already exist in workspace etc
    """
    def __init__(self):
        pass
    
    def validateOpenproj(self,projDir):
        """
        This function validate Open Project Information.
        """
        print "Validating Open Project Information"
        projName = os.path.basename(str(projDir))
        lookProj = os.path.join(str(projDir),projName+".proj")
        #Check existence of project
        if os.path.exists(lookProj):
            return True
        else:
            return False
       
        
    
    def validateNewproj(self,projDir):
        """This Project Validate New Project Information
        """
        print "Validating New Project Information"
        #print "Project Directory : ",projDir
        #Checking existence of project with same name
        
        if os.path.exists(projDir):
            return "CHECKEXIST" #Project with name already exist
        else:
            #Check Proper name for project. It should not have space
            if re.search(r"\s",projDir ):
                return "CHECKNAME"
            else:
                return "VALID"
            
    def validateKicad(self,projDir):
        """
        This function validate if Kicad components are present
        """
        print "Validation for Kicad components"
        if projDir == None:
            return False
        else:
            return True
        
    def validateCir(self,projDir):
        """
        This function checks if ".cir" file is present.
        """
        #print "Checking if .cir file is present or not"
        projName = os.path.basename(str(projDir))
        lookCir = os.path.join(str(projDir),projName+".cir")
        #Check existence of project
        if os.path.exists(lookCir):
            return True
        else:
            return False