File tree Expand file tree Collapse file tree 4 files changed +25
-3
lines changed
Expand file tree Collapse file tree 4 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ omit = fs/test.py
55exclude_lines =
66 pragma: no cover
77 if False:
8+ @typing.overload
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ )
55and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
66
7+ ## [ 2.0.21] - Unreleased
8+
9+ ### Added
10+
11+ - Added ext attribute to info
12+
713## [ 2.0.20] - 2018-03-13
814
915### Fixed
Original file line number Diff line number Diff line change @@ -182,6 +182,19 @@ def name(self):
182182 """
183183 return self .get ('basic' , 'name' )
184184
185+ @property
186+ def ext (self ):
187+ # type: () -> Text
188+ """`str`: the resource extension (including dot).
189+
190+ Example:
191+ >>> info.ext
192+ '.py'
193+ """
194+ name = self .get ('basic' , 'name' )
195+ basename , dot , ext = name .rpartition ('.' )
196+ return dot + ext if dot else ''
197+
185198 @property
186199 def is_dir (self ):
187200 # type: () -> bool
Original file line number Diff line number Diff line change @@ -67,14 +67,15 @@ def test_basic(self):
6767 # Check simple file
6868 info = Info ({
6969 "basic" : {
70- "name" : "bar" ,
70+ "name" : "bar.py " ,
7171 "is_dir" : False
7272 }
7373 })
74- self .assertEqual (info .name , "bar" )
74+ self .assertEqual (info .name , "bar.py " )
7575 self .assertIsInstance (info .is_dir , bool )
7676 self .assertFalse (info .is_dir )
77- self .assertEqual (repr (info ), "<file 'bar'>" )
77+ self .assertEqual (repr (info ), "<file 'bar.py'>" )
78+ self .assertEqual (info .ext , '.py' )
7879
7980 # Check dir
8081 info = Info ({
@@ -85,6 +86,7 @@ def test_basic(self):
8586 })
8687 self .assertTrue (info .is_dir )
8788 self .assertEqual (repr (info ), "<dir 'foo'>" )
89+ self .assertEqual (info .ext , '' )
8890
8991 def test_details (self ):
9092 dates = [
You can’t perform that action at this time.
0 commit comments